Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
e21b3e9e
Commit
e21b3e9e
authored
Apr 05, 2021
by
Fan Yang
Committed by
A. Unique TensorFlower
Apr 05, 2021
Browse files
Internal change.
PiperOrigin-RevId: 366889393
parent
ccd05aca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
official/vision/beta/serving/image_classification.py
official/vision/beta/serving/image_classification.py
+2
-1
official/vision/beta/serving/image_classification_test.py
official/vision/beta/serving/image_classification_test.py
+5
-2
No files found.
official/vision/beta/serving/image_classification.py
View file @
e21b3e9e
...
@@ -77,5 +77,6 @@ class ClassificationModule(export_base.ExportModule):
...
@@ -77,5 +77,6 @@ class ClassificationModule(export_base.ExportModule):
)
)
logits
=
self
.
inference_step
(
images
)
logits
=
self
.
inference_step
(
images
)
probs
=
tf
.
nn
.
softmax
(
logits
)
return
dict
(
outputs
=
logits
)
return
{
'logits'
:
logits
,
'probs'
:
probs
}
official/vision/beta/serving/image_classification_test.py
View file @
e21b3e9e
...
@@ -97,13 +97,16 @@ class ImageClassificationExportTest(tf.test.TestCase, parameterized.TestCase):
...
@@ -97,13 +97,16 @@ class ImageClassificationExportTest(tf.test.TestCase, parameterized.TestCase):
elems
=
tf
.
zeros
((
1
,
224
,
224
,
3
),
dtype
=
tf
.
uint8
),
elems
=
tf
.
zeros
((
1
,
224
,
224
,
3
),
dtype
=
tf
.
uint8
),
fn_output_signature
=
tf
.
TensorSpec
(
fn_output_signature
=
tf
.
TensorSpec
(
shape
=
[
224
,
224
,
3
],
dtype
=
tf
.
float32
)))
shape
=
[
224
,
224
,
3
],
dtype
=
tf
.
float32
)))
expected_output
=
module
.
model
(
processed_images
,
training
=
False
)
expected_logits
=
module
.
model
(
processed_images
,
training
=
False
)
expected_prob
=
tf
.
nn
.
softmax
(
expected_logits
)
out
=
classification_fn
(
tf
.
constant
(
images
))
out
=
classification_fn
(
tf
.
constant
(
images
))
# The imported model should contain any trackable attrs that the original
# The imported model should contain any trackable attrs that the original
# model had.
# model had.
self
.
assertTrue
(
hasattr
(
imported
.
model
,
'test_trackable'
))
self
.
assertTrue
(
hasattr
(
imported
.
model
,
'test_trackable'
))
self
.
assertAllClose
(
out
[
'outputs'
].
numpy
(),
expected_output
.
numpy
())
self
.
assertAllClose
(
out
[
'logits'
].
numpy
(),
expected_logits
.
numpy
())
self
.
assertAllClose
(
out
[
'probs'
].
numpy
(),
expected_prob
.
numpy
())
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
tf
.
test
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment