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
0a49aee8
Commit
0a49aee8
authored
Oct 27, 2017
by
Vivek Rathod
Browse files
remove new anchor generator builder changes.
parent
8b31db60
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
85 deletions
+6
-85
research/object_detection/builders/anchor_generator_builder.py
...rch/object_detection/builders/anchor_generator_builder.py
+3
-19
research/object_detection/builders/anchor_generator_builder_test.py
...bject_detection/builders/anchor_generator_builder_test.py
+3
-66
No files found.
research/object_detection/builders/anchor_generator_builder.py
View file @
0a49aee8
...
@@ -54,29 +54,13 @@ def build(anchor_generator_config):
...
@@ -54,29 +54,13 @@ def build(anchor_generator_config):
elif
anchor_generator_config
.
WhichOneof
(
elif
anchor_generator_config
.
WhichOneof
(
'anchor_generator_oneof'
)
==
'ssd_anchor_generator'
:
'anchor_generator_oneof'
)
==
'ssd_anchor_generator'
:
ssd_anchor_generator_config
=
anchor_generator_config
.
ssd_anchor_generator
ssd_anchor_generator_config
=
anchor_generator_config
.
ssd_anchor_generator
anchor_strides
=
None
if
ssd_anchor_generator_config
.
height_stride
:
anchor_strides
=
zip
(
ssd_anchor_generator_config
.
height_stride
,
ssd_anchor_generator_config
.
width_stride
)
anchor_offsets
=
None
if
ssd_anchor_generator_config
.
height_offset
:
anchor_offsets
=
zip
(
ssd_anchor_generator_config
.
height_offset
,
ssd_anchor_generator_config
.
width_offset
)
return
multiple_grid_anchor_generator
.
create_ssd_anchors
(
return
multiple_grid_anchor_generator
.
create_ssd_anchors
(
num_layers
=
ssd_anchor_generator_config
.
num_layers
,
num_layers
=
ssd_anchor_generator_config
.
num_layers
,
min_scale
=
ssd_anchor_generator_config
.
min_scale
,
min_scale
=
ssd_anchor_generator_config
.
min_scale
,
max_scale
=
ssd_anchor_generator_config
.
max_scale
,
max_scale
=
ssd_anchor_generator_config
.
max_scale
,
scales
=
[
float
(
scale
)
for
scale
in
ssd_anchor_generator_config
.
scales
],
aspect_ratios
=
ssd_anchor_generator_config
.
aspect_ratios
,
aspect_ratios
=
ssd_anchor_generator_config
.
aspect_ratios
,
interpolated_scale_aspect_ratio
=
(
reduce_boxes_in_lowest_layer
=
(
ssd_anchor_generator_config
ssd_anchor_generator_config
.
interpolated_scale_aspect_ratio
),
.
reduce_boxes_in_lowest_layer
))
base_anchor_size
=
[
ssd_anchor_generator_config
.
base_anchor_height
,
ssd_anchor_generator_config
.
base_anchor_width
],
anchor_strides
=
anchor_strides
,
anchor_offsets
=
anchor_offsets
,
reduce_boxes_in_lowest_layer
=
(
ssd_anchor_generator_config
.
reduce_boxes_in_lowest_layer
))
else
:
else
:
raise
ValueError
(
'Empty anchor generator.'
)
raise
ValueError
(
'Empty anchor generator.'
)
research/object_detection/builders/anchor_generator_builder_test.py
View file @
0a49aee8
...
@@ -15,8 +15,6 @@
...
@@ -15,8 +15,6 @@
"""Tests for anchor_generator_builder."""
"""Tests for anchor_generator_builder."""
import
math
import
tensorflow
as
tf
import
tensorflow
as
tf
from
google.protobuf
import
text_format
from
google.protobuf
import
text_format
...
@@ -118,52 +116,7 @@ class AnchorGeneratorBuilderTest(tf.test.TestCase):
...
@@ -118,52 +116,7 @@ class AnchorGeneratorBuilderTest(tf.test.TestCase):
base_anchor_size
=
sess
.
run
(
anchor_generator_object
.
_base_anchor_size
)
base_anchor_size
=
sess
.
run
(
anchor_generator_object
.
_base_anchor_size
)
self
.
assertAllClose
(
base_anchor_size
,
[
1.0
,
1.0
])
self
.
assertAllClose
(
base_anchor_size
,
[
1.0
,
1.0
])
def
test_build_ssd_anchor_generator_with_custom_scales
(
self
):
def
test_build_ssd_anchor_generator_withoud_reduced_boxes
(
self
):
anchor_generator_text_proto
=
"""
ssd_anchor_generator {
aspect_ratios: [1.0]
scales: [0.1, 0.15, 0.2, 0.4, 0.6, 0.8]
reduce_boxes_in_lowest_layer: false
}
"""
anchor_generator_proto
=
anchor_generator_pb2
.
AnchorGenerator
()
text_format
.
Merge
(
anchor_generator_text_proto
,
anchor_generator_proto
)
anchor_generator_object
=
anchor_generator_builder
.
build
(
anchor_generator_proto
)
self
.
assertTrue
(
isinstance
(
anchor_generator_object
,
multiple_grid_anchor_generator
.
MultipleGridAnchorGenerator
))
for
actual_scales
,
expected_scales
in
zip
(
list
(
anchor_generator_object
.
_scales
),
[(
0.1
,
math
.
sqrt
(
0.1
*
0.15
)),
(
0.15
,
math
.
sqrt
(
0.15
*
0.2
)),
(
0.2
,
math
.
sqrt
(
0.2
*
0.4
)),
(
0.4
,
math
.
sqrt
(
0.4
*
0.6
)),
(
0.6
,
math
.
sqrt
(
0.6
*
0.8
)),
(
0.8
,
math
.
sqrt
(
0.8
*
1.0
))]):
self
.
assert_almost_list_equal
(
expected_scales
,
actual_scales
,
delta
=
1e-2
)
def
test_build_ssd_anchor_generator_with_custom_interpolated_scale
(
self
):
anchor_generator_text_proto
=
"""
ssd_anchor_generator {
aspect_ratios: [0.5]
interpolated_scale_aspect_ratio: 0.5
reduce_boxes_in_lowest_layer: false
}
"""
anchor_generator_proto
=
anchor_generator_pb2
.
AnchorGenerator
()
text_format
.
Merge
(
anchor_generator_text_proto
,
anchor_generator_proto
)
anchor_generator_object
=
anchor_generator_builder
.
build
(
anchor_generator_proto
)
self
.
assertTrue
(
isinstance
(
anchor_generator_object
,
multiple_grid_anchor_generator
.
MultipleGridAnchorGenerator
))
for
actual_aspect_ratio
,
expected_aspect_ratio
in
zip
(
list
(
anchor_generator_object
.
_aspect_ratios
),
6
*
[(
0.5
,
0.5
)]):
self
.
assert_almost_list_equal
(
expected_aspect_ratio
,
actual_aspect_ratio
)
def
test_build_ssd_anchor_generator_without_reduced_boxes
(
self
):
anchor_generator_text_proto
=
"""
anchor_generator_text_proto
=
"""
ssd_anchor_generator {
ssd_anchor_generator {
aspect_ratios: [1.0]
aspect_ratios: [1.0]
...
@@ -204,14 +157,6 @@ class AnchorGeneratorBuilderTest(tf.test.TestCase):
...
@@ -204,14 +157,6 @@ class AnchorGeneratorBuilderTest(tf.test.TestCase):
min_scale: 0.3
min_scale: 0.3
max_scale: 0.8
max_scale: 0.8
aspect_ratios: [2.0]
aspect_ratios: [2.0]
height_stride: 16
height_stride: 32
width_stride: 20
width_stride: 30
height_offset: 8
height_offset: 16
width_offset: 0
width_offset: 10
}
}
"""
"""
anchor_generator_proto
=
anchor_generator_pb2
.
AnchorGenerator
()
anchor_generator_proto
=
anchor_generator_pb2
.
AnchorGenerator
()
...
@@ -224,22 +169,14 @@ class AnchorGeneratorBuilderTest(tf.test.TestCase):
...
@@ -224,22 +169,14 @@ class AnchorGeneratorBuilderTest(tf.test.TestCase):
for
actual_scales
,
expected_scales
in
zip
(
for
actual_scales
,
expected_scales
in
zip
(
list
(
anchor_generator_object
.
_scales
),
list
(
anchor_generator_object
.
_scales
),
[(
0.1
,
0.3
,
0.3
),
(
0.8
,
0.894
)]):
[(
0.1
,
0.3
,
0.3
),
(
0.8
,)]):
self
.
assert_almost_list_equal
(
expected_scales
,
actual_scales
,
delta
=
1e-2
)
self
.
assert_almost_list_equal
(
expected_scales
,
actual_scales
,
delta
=
1e-2
)
for
actual_aspect_ratio
,
expected_aspect_ratio
in
zip
(
for
actual_aspect_ratio
,
expected_aspect_ratio
in
zip
(
list
(
anchor_generator_object
.
_aspect_ratios
),
list
(
anchor_generator_object
.
_aspect_ratios
),
[(
1.0
,
2.0
,
0.5
),
(
2.0
,
1.0
)]):
[(
1.0
,
2.0
,
0.5
),
(
2.0
,)]):
self
.
assert_almost_list_equal
(
expected_aspect_ratio
,
actual_aspect_ratio
)
self
.
assert_almost_list_equal
(
expected_aspect_ratio
,
actual_aspect_ratio
)
for
actual_strides
,
expected_strides
in
zip
(
list
(
anchor_generator_object
.
_anchor_strides
),
[(
16
,
20
),
(
32
,
30
)]):
self
.
assert_almost_list_equal
(
expected_strides
,
actual_strides
)
for
actual_offsets
,
expected_offsets
in
zip
(
list
(
anchor_generator_object
.
_anchor_offsets
),
[(
8
,
0
),
(
16
,
10
)]):
self
.
assert_almost_list_equal
(
expected_offsets
,
actual_offsets
)
with
self
.
test_session
()
as
sess
:
with
self
.
test_session
()
as
sess
:
base_anchor_size
=
sess
.
run
(
anchor_generator_object
.
_base_anchor_size
)
base_anchor_size
=
sess
.
run
(
anchor_generator_object
.
_base_anchor_size
)
self
.
assertAllClose
(
base_anchor_size
,
[
1.0
,
1.0
])
self
.
assertAllClose
(
base_anchor_size
,
[
1.0
,
1.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