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
86e0e0f9
Commit
86e0e0f9
authored
Jun 11, 2021
by
A. Unique TensorFlower
Committed by
TF Object Detection Team
Jun 11, 2021
Browse files
Remove num anchors assertion from AnchorGenerator
PiperOrigin-RevId: 378977617
parent
9d1fe069
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
29 deletions
+3
-29
research/object_detection/core/anchor_generator.py
research/object_detection/core/anchor_generator.py
+3
-29
No files found.
research/object_detection/core/anchor_generator.py
View file @
86e0e0f9
...
...
@@ -37,7 +37,6 @@ from abc import ABCMeta
from
abc
import
abstractmethod
import
six
from
six.moves
import
zip
import
tensorflow.compat.v1
as
tf
...
...
@@ -107,11 +106,9 @@ class AnchorGenerator(six.with_metaclass(ABCMeta, object)):
with
tf
.
name_scope
(
self
.
name_scope
()):
anchors_list
=
self
.
_generate
(
feature_map_shape_list
,
**
params
)
if
self
.
check_num_anchors
:
with
tf
.
control_dependencies
([
self
.
_assert_correct_number_of_anchors
(
anchors_list
,
feature_map_shape_list
)]):
for
item
in
anchors_list
:
item
.
set
(
tf
.
identity
(
item
.
get
()))
return
anchors_list
@
abstractmethod
...
...
@@ -146,26 +143,3 @@ class AnchorGenerator(six.with_metaclass(ABCMeta, object)):
feature_map_indices_list
.
append
(
i
*
tf
.
ones
([
boxes
.
num_boxes
()],
dtype
=
tf
.
int32
))
return
tf
.
concat
(
feature_map_indices_list
,
axis
=
0
)
def
_assert_correct_number_of_anchors
(
self
,
anchors_list
,
feature_map_shape_list
):
"""Assert that correct number of anchors was generated.
Args:
anchors_list: A list of box_list.BoxList object holding anchors generated.
feature_map_shape_list: list of (height, width) pairs in the format
[(height_0, width_0), (height_1, width_1), ...] that the generated
anchors must align with.
Returns:
Op that raises InvalidArgumentError if the number of anchors does not
match the number of expected anchors.
"""
expected_num_anchors
=
0
actual_num_anchors
=
0
for
num_anchors_per_location
,
feature_map_shape
,
anchors
in
zip
(
self
.
num_anchors_per_location
(),
feature_map_shape_list
,
anchors_list
):
expected_num_anchors
+=
(
num_anchors_per_location
*
feature_map_shape
[
0
]
*
feature_map_shape
[
1
])
actual_num_anchors
+=
anchors
.
num_boxes
()
return
tf
.
assert_equal
(
expected_num_anchors
,
actual_num_anchors
)
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