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
8ce327f8
"vscode:/vscode.git/clone" did not exist on "0e006a9fc9eae6d3cc13fceb3a205af29b06d703"
Commit
8ce327f8
authored
Jun 25, 2020
by
syiming
Browse files
Add test for multilevel_native_crop_and_resize
parent
eb4b727d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
research/object_detection/utils/spatial_transform_ops_test.py
...arch/object_detection/utils/spatial_transform_ops_test.py
+51
-0
No files found.
research/object_detection/utils/spatial_transform_ops_test.py
View file @
8ce327f8
...
@@ -515,6 +515,28 @@ class MatMulCropAndResizeTest(test_case.TestCase):
...
@@ -515,6 +515,28 @@ class MatMulCropAndResizeTest(test_case.TestCase):
class
NativeCropAndResizeTest
(
test_case
.
TestCase
):
class
NativeCropAndResizeTest
(
test_case
.
TestCase
):
# def testBatchCropAndResize3x3To2x2_2Channels(self):
# def graph_fn(image, boxes):
# return spatial_ops.native_crop_and_resize(image, boxes, crop_size=[2, 2])
# image = np.array([[[[1, 0], [2, 1], [3, 2]],
# [[4, 3], [5, 4], [6, 5]],
# [[7, 6], [8, 7], [9, 8]]],
# [[[1, 0], [2, 1], [3, 2]],
# [[4, 3], [5, 4], [6, 5]],
# [[7, 6], [8, 7], [9, 8]]]], dtype=np.float32)
# boxes = np.array([[[0, 0, 1, 1],
# [0, 0, .5, .5]],
# [[1, 1, 0, 0],
# [.5, .5, 0, 0]]], dtype=np.float32)
# expected_output = [[[[[1, 0], [3, 2]], [[7, 6], [9, 8]]],
# [[[1, 0], [2, 1]], [[4, 3], [5, 4]]]],
# [[[[9, 8], [7, 6]], [[3, 2], [1, 0]]],
# [[[5, 4], [4, 3]], [[2, 1], [1, 0]]]]]
# crop_output = self.execute_cpu(graph_fn, [image, boxes])
# self.assertAllClose(crop_output, expected_output)
def
testBatchCropAndResize3x3To2x2_2Channels
(
self
):
def
testBatchCropAndResize3x3To2x2_2Channels
(
self
):
def
graph_fn
(
image
,
boxes
):
def
graph_fn
(
image
,
boxes
):
...
@@ -536,6 +558,35 @@ class NativeCropAndResizeTest(test_case.TestCase):
...
@@ -536,6 +558,35 @@ class NativeCropAndResizeTest(test_case.TestCase):
[[[
5
,
4
],
[
4
,
3
]],
[[
2
,
1
],
[
1
,
0
]]]]]
[[[
5
,
4
],
[
4
,
3
]],
[[
2
,
1
],
[
1
,
0
]]]]]
crop_output
=
self
.
execute_cpu
(
graph_fn
,
[
image
,
boxes
])
crop_output
=
self
.
execute_cpu
(
graph_fn
,
[
image
,
boxes
])
self
.
assertAllClose
(
crop_output
,
expected_output
)
self
.
assertAllClose
(
crop_output
,
expected_output
)
def
testMultilevelBatchCropAndResize3x3To2x2_2Channels
(
self
):
def
graph_fn
(
image1
,
image2
,
boxes
,
box_levels
):
return
spatial_ops
.
multilevel_native_crop_and_resize
([
image1
,
image2
],
boxes
,
box_levels
,
crop_size
=
[
2
,
2
])
image
=
[
np
.
array
([[[[
1
,
0
],
[
2
,
1
],
[
3
,
2
]],
[[
4
,
3
],
[
5
,
4
],
[
6
,
5
]],
[[
7
,
6
],
[
8
,
7
],
[
9
,
8
]]],
[[[
1
,
0
],
[
2
,
1
],
[
3
,
2
]],
[[
4
,
3
],
[
5
,
4
],
[
6
,
5
]],
[[
7
,
6
],
[
8
,
7
],
[
9
,
8
]]]],
dtype
=
np
.
float32
),
np
.
array
([[[[
1
,
0
],
[
2
,
1
]],
[[
4
,
3
],
[
5
,
4
]]],
[[[
1
,
0
],
[
2
,
1
]],
[[
4
,
3
],
[
5
,
4
]]]],
dtype
=
np
.
float32
)]
boxes
=
np
.
array
([[[
0
,
0
,
1
,
1
],
[
0
,
0
,
.
5
,
.
5
]],
[[
1
,
1
,
0
,
0
],
[.
5
,
.
5
,
0
,
0
]]],
dtype
=
np
.
float32
)
box_levels
=
np
.
array
([[
0
,
1
],
[
0
,
0
]],
dtype
=
np
.
float32
)
expected_output
=
[[[[[
1
,
0
],
[
3
,
2
]],
[[
7
,
6
],
[
9
,
8
]]],
[[[
1
,
0
],
[
1.5
,
0.5
]],
[[
2.5
,
1.5
],
[
3
,
2
]]]],
[[[[
9
,
8
],
[
7
,
6
]],
[[
3
,
2
],
[
1
,
0
]]],
[[[
5
,
4
],
[
4
,
3
]],
[[
2
,
1
],
[
1
,
0
]]]]]
crop_output
=
self
.
execute_cpu
(
graph_fn
,
[
*
image
,
boxes
,
box_levels
])
self
.
assertAllClose
(
crop_output
,
expected_output
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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