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
e5459a6b
Commit
e5459a6b
authored
Apr 13, 2021
by
Vighnesh Birodkar
Committed by
TF Object Detection Team
Apr 13, 2021
Browse files
Clip values in strided box predictions.
PiperOrigin-RevId: 368215027
parent
87796817
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
research/object_detection/meta_architectures/center_net_meta_arch.py
...ject_detection/meta_architectures/center_net_meta_arch.py
+12
-4
research/object_detection/meta_architectures/center_net_meta_arch_tf2_test.py
...ction/meta_architectures/center_net_meta_arch_tf2_test.py
+1
-1
No files found.
research/object_detection/meta_architectures/center_net_meta_arch.py
View file @
e5459a6b
...
...
@@ -361,6 +361,8 @@ def prediction_tensors_to_boxes(y_indices, x_indices, height_width_predictions,
the raw bounding box coordinates of boxes.
"""
batch_size
,
num_boxes
=
_get_shape
(
y_indices
,
2
)
_
,
height
,
width
,
_
=
_get_shape
(
height_width_predictions
,
4
)
height
,
width
=
tf
.
cast
(
height
,
tf
.
float32
),
tf
.
cast
(
width
,
tf
.
float32
)
# TF Lite does not support tf.gather with batch_dims > 0, so we need to use
# tf_gather_nd instead and here we prepare the indices for that.
...
...
@@ -382,10 +384,16 @@ def prediction_tensors_to_boxes(y_indices, x_indices, height_width_predictions,
heights
,
widths
=
tf
.
unstack
(
height_width
,
axis
=
2
)
y_offsets
,
x_offsets
=
tf
.
unstack
(
offsets
,
axis
=
2
)
boxes
=
tf
.
stack
([
y_indices
+
y_offsets
-
heights
/
2.0
,
x_indices
+
x_offsets
-
widths
/
2.0
,
y_indices
+
y_offsets
+
heights
/
2.0
,
x_indices
+
x_offsets
+
widths
/
2.0
],
axis
=
2
)
ymin
=
y_indices
+
y_offsets
-
heights
/
2.0
xmin
=
x_indices
+
x_offsets
-
widths
/
2.0
ymax
=
y_indices
+
y_offsets
+
heights
/
2.0
xmax
=
x_indices
+
x_offsets
+
widths
/
2.0
ymin
=
tf
.
clip_by_value
(
ymin
,
0.
,
height
)
xmin
=
tf
.
clip_by_value
(
xmin
,
0.
,
width
)
ymax
=
tf
.
clip_by_value
(
ymax
,
0.
,
height
)
xmax
=
tf
.
clip_by_value
(
xmax
,
0.
,
width
)
boxes
=
tf
.
stack
([
ymin
,
xmin
,
ymax
,
xmax
],
axis
=
2
)
return
boxes
...
...
research/object_detection/meta_architectures/center_net_meta_arch_tf2_test.py
View file @
e5459a6b
...
...
@@ -600,7 +600,7 @@ class CenterNetMetaArchHelpersTest(test_case.TestCase, parameterized.TestCase):
boxes
=
self
.
execute
(
graph_fn
,
[])
np
.
testing
.
assert_allclose
(
[[
-
9
,
-
8
,
31
,
52
],
[
25
,
35
,
75
,
85
]],
boxes
[
0
])
[[
0
,
0
,
31
,
52
],
[
25
,
35
,
75
,
85
]],
boxes
[
0
])
np
.
testing
.
assert_allclose
(
[[
96
,
98
,
106
,
108
],
[
96
,
98
,
106
,
108
]],
boxes
[
1
])
np
.
testing
.
assert_allclose
(
...
...
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