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
82f93573
Commit
82f93573
authored
Feb 22, 2021
by
A. Unique TensorFlower
Browse files
Internal change
PiperOrigin-RevId: 358901400
parent
59e25c9d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
official/vision/beta/serving/detection.py
official/vision/beta/serving/detection.py
+9
-8
official/vision/beta/serving/detection_test.py
official/vision/beta/serving/detection_test.py
+3
-2
No files found.
official/vision/beta/serving/detection.py
View file @
82f93573
...
...
@@ -70,8 +70,6 @@ class DetectionModule(export_base.ExportModule):
aug_scale_min
=
1.0
,
aug_scale_max
=
1.0
)
image_shape
=
image_info
[
1
,
:]
# Shape of original image.
input_anchor
=
anchor
.
build_anchor_generator
(
min_level
=
model_params
.
min_level
,
max_level
=
model_params
.
max_level
,
...
...
@@ -81,7 +79,7 @@ class DetectionModule(export_base.ExportModule):
anchor_boxes
=
input_anchor
(
image_size
=
(
self
.
_input_image_size
[
0
],
self
.
_input_image_size
[
1
]))
return
image
,
anchor_boxes
,
image_
shape
return
image
,
anchor_boxes
,
image_
info
def
_run_inference_on_image_tensors
(
self
,
images
:
tf
.
Tensor
):
"""Cast image to float and run inference.
...
...
@@ -111,20 +109,22 @@ class DetectionModule(export_base.ExportModule):
dtype
=
tf
.
float32
)
anchor_shapes
.
append
((
str
(
level
),
anchor_level_spec
))
image_
shape
_spec
=
tf
.
TensorSpec
(
shape
=
[
2
,
],
dtype
=
tf
.
float32
)
image_
info
_spec
=
tf
.
TensorSpec
(
shape
=
[
4
,
2
],
dtype
=
tf
.
float32
)
images
,
anchor_boxes
,
image_
shape
=
tf
.
nest
.
map_structure
(
images
,
anchor_boxes
,
image_
info
=
tf
.
nest
.
map_structure
(
tf
.
identity
,
tf
.
map_fn
(
self
.
_build_inputs
,
elems
=
images
,
fn_output_signature
=
(
images_spec
,
dict
(
anchor_shapes
),
image_
shape
_spec
),
image_
info
_spec
),
parallel_iterations
=
32
))
input_image_shape
=
image_info
[:,
1
,
:]
detections
=
self
.
_model
.
call
(
images
=
images
,
image_shape
=
image_shape
,
image_shape
=
input_
image_shape
,
anchor_boxes
=
anchor_boxes
,
training
=
False
)
...
...
@@ -132,7 +132,8 @@ class DetectionModule(export_base.ExportModule):
'detection_boxes'
:
detections
[
'detection_boxes'
],
'detection_scores'
:
detections
[
'detection_scores'
],
'detection_classes'
:
detections
[
'detection_classes'
],
'num_detections'
:
detections
[
'num_detections'
]
'num_detections'
:
detections
[
'num_detections'
],
'image_info'
:
image_info
}
if
'detection_masks'
in
detections
.
keys
():
final_outputs
[
'detection_masks'
]
=
detections
[
'detection_masks'
]
...
...
official/vision/beta/serving/detection_test.py
View file @
82f93573
...
...
@@ -125,10 +125,11 @@ class DetectionExportTest(tf.test.TestCase, parameterized.TestCase):
images
=
self
.
_get_dummy_input
(
input_type
,
batch_size
,
image_size
)
processed_images
,
anchor_boxes
,
image_
shape
=
module
.
_build_inputs
(
processed_images
,
anchor_boxes
,
image_
info
=
module
.
_build_inputs
(
tf
.
zeros
((
224
,
224
,
3
),
dtype
=
tf
.
uint8
))
processed_images
=
tf
.
expand_dims
(
processed_images
,
0
)
image_shape
=
image_info
[
1
,
:]
image_shape
=
tf
.
expand_dims
(
image_shape
,
0
)
processed_images
=
tf
.
expand_dims
(
processed_images
,
0
)
for
l
,
l_boxes
in
anchor_boxes
.
items
():
anchor_boxes
[
l
]
=
tf
.
expand_dims
(
l_boxes
,
0
)
...
...
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