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
a78b05b9
Commit
a78b05b9
authored
Jul 24, 2020
by
Vighnesh Birodkar
Committed by
TF Object Detection Team
Jul 24, 2020
Browse files
Fix CenterNetMaskTargetAssigner for images with no annotations.
PiperOrigin-RevId: 323059388
parent
da23acba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
research/object_detection/core/target_assigner.py
research/object_detection/core/target_assigner.py
+2
-0
research/object_detection/core/target_assigner_test.py
research/object_detection/core/target_assigner_test.py
+16
-0
No files found.
research/object_detection/core/target_assigner.py
View file @
a78b05b9
...
@@ -1659,6 +1659,8 @@ class CenterNetMaskTargetAssigner(object):
...
@@ -1659,6 +1659,8 @@ class CenterNetMaskTargetAssigner(object):
# Shape: [h, w, num_classes].
# Shape: [h, w, num_classes].
segmentations_for_image
=
tf
.
reduce_max
(
segmentations_for_image
=
tf
.
reduce_max
(
gt_masks
*
gt_classes_reshaped
,
axis
=
0
)
gt_masks
*
gt_classes_reshaped
,
axis
=
0
)
# Avoid the case where max of an empty array is -inf.
segmentations_for_image
=
tf
.
maximum
(
segmentations_for_image
,
0.0
)
segmentation_targets_list
.
append
(
segmentations_for_image
)
segmentation_targets_list
.
append
(
segmentations_for_image
)
segmentation_target
=
tf
.
stack
(
segmentation_targets_list
,
axis
=
0
)
segmentation_target
=
tf
.
stack
(
segmentation_targets_list
,
axis
=
0
)
...
...
research/object_detection/core/target_assigner_test.py
View file @
a78b05b9
...
@@ -1905,6 +1905,22 @@ class CenterNetMaskTargetAssignerTest(test_case.TestCase):
...
@@ -1905,6 +1905,22 @@ class CenterNetMaskTargetAssignerTest(test_case.TestCase):
np
.
testing
.
assert_array_almost_equal
(
np
.
testing
.
assert_array_almost_equal
(
expected_seg_target
,
segmentation_target
)
expected_seg_target
,
segmentation_target
)
def
test_assign_segmentation_targets_no_objects
(
self
):
def
graph_fn
():
gt_masks_list
=
[
tf
.
zeros
((
0
,
5
,
5
))]
gt_classes_list
=
[
tf
.
zeros
((
0
,
10
))]
cn_assigner
=
targetassigner
.
CenterNetMaskTargetAssigner
(
stride
=
1
)
segmentation_target
=
cn_assigner
.
assign_segmentation_targets
(
gt_masks_list
=
gt_masks_list
,
gt_classes_list
=
gt_classes_list
,
mask_resize_method
=
targetassigner
.
ResizeMethod
.
NEAREST_NEIGHBOR
)
return
segmentation_target
segmentation_target
=
self
.
execute
(
graph_fn
,
[])
expected_seg_target
=
np
.
zeros
((
1
,
5
,
5
,
10
))
np
.
testing
.
assert_array_almost_equal
(
expected_seg_target
,
segmentation_target
)
class
CenterNetDensePoseTargetAssignerTest
(
test_case
.
TestCase
):
class
CenterNetDensePoseTargetAssignerTest
(
test_case
.
TestCase
):
...
...
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