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
OpenDAS
vision
Commits
c991db82
Unverified
Commit
c991db82
authored
Mar 04, 2021
by
Nicolas Hug
Committed by
GitHub
Mar 04, 2021
Browse files
[OPS, TEST] Add onnx test for batched_nms (#3483)
parent
668927ef
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
test/test_onnx.py
test/test_onnx.py
+17
-3
No files found.
test/test_onnx.py
View file @
c991db82
...
@@ -82,9 +82,10 @@ class ONNXExporterTester(unittest.TestCase):
...
@@ -82,9 +82,10 @@ class ONNXExporterTester(unittest.TestCase):
raise
raise
def
test_nms
(
self
):
def
test_nms
(
self
):
boxes
=
torch
.
rand
(
5
,
4
)
num_boxes
=
100
boxes
[:,
2
:]
+=
torch
.
rand
(
5
,
2
)
boxes
=
torch
.
rand
(
num_boxes
,
4
)
scores
=
torch
.
randn
(
5
)
boxes
[:,
2
:]
+=
boxes
[:,
:
2
]
scores
=
torch
.
randn
(
num_boxes
)
class
Module
(
torch
.
nn
.
Module
):
class
Module
(
torch
.
nn
.
Module
):
def
forward
(
self
,
boxes
,
scores
):
def
forward
(
self
,
boxes
,
scores
):
...
@@ -92,6 +93,19 @@ class ONNXExporterTester(unittest.TestCase):
...
@@ -92,6 +93,19 @@ class ONNXExporterTester(unittest.TestCase):
self
.
run_model
(
Module
(),
[(
boxes
,
scores
)])
self
.
run_model
(
Module
(),
[(
boxes
,
scores
)])
def
test_batched_nms
(
self
):
num_boxes
=
100
boxes
=
torch
.
rand
(
num_boxes
,
4
)
boxes
[:,
2
:]
+=
boxes
[:,
:
2
]
scores
=
torch
.
randn
(
num_boxes
)
idxs
=
torch
.
randint
(
0
,
5
,
size
=
(
num_boxes
,))
class
Module
(
torch
.
nn
.
Module
):
def
forward
(
self
,
boxes
,
scores
,
idxs
):
return
ops
.
batched_nms
(
boxes
,
scores
,
idxs
,
0.5
)
self
.
run_model
(
Module
(),
[(
boxes
,
scores
,
idxs
)])
def
test_clip_boxes_to_image
(
self
):
def
test_clip_boxes_to_image
(
self
):
boxes
=
torch
.
randn
(
5
,
4
)
*
500
boxes
=
torch
.
randn
(
5
,
4
)
*
500
boxes
[:,
2
:]
+=
boxes
[:,
:
2
]
boxes
[:,
2
:]
+=
boxes
[:,
:
2
]
...
...
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