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
34810c0c
Unverified
Commit
34810c0c
authored
Jun 01, 2020
by
Francisco Massa
Committed by
GitHub
Jun 01, 2020
Browse files
Add more tests to NMS (#2279)
* Add more tests to NMS * Fix lint
parent
b40f49fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
test/test_ops.py
test/test_ops.py
+4
-0
torchvision/csrc/nms.h
torchvision/csrc/nms.h
+18
-0
No files found.
test/test_ops.py
View file @
34810c0c
...
...
@@ -393,6 +393,10 @@ class NMSTester(unittest.TestCase):
keep_ref
=
self
.
reference_nms
(
boxes
,
scores
,
iou
)
keep
=
ops
.
nms
(
boxes
,
scores
,
iou
)
self
.
assertTrue
(
torch
.
allclose
(
keep
,
keep_ref
),
err_msg
.
format
(
iou
))
self
.
assertRaises
(
RuntimeError
,
ops
.
nms
,
torch
.
rand
(
4
),
torch
.
rand
(
3
),
0.5
)
self
.
assertRaises
(
RuntimeError
,
ops
.
nms
,
torch
.
rand
(
3
,
5
),
torch
.
rand
(
3
),
0.5
)
self
.
assertRaises
(
RuntimeError
,
ops
.
nms
,
torch
.
rand
(
3
,
4
),
torch
.
rand
(
3
,
2
),
0.5
)
self
.
assertRaises
(
RuntimeError
,
ops
.
nms
,
torch
.
rand
(
3
,
4
),
torch
.
rand
(
4
),
0.5
)
@
unittest
.
skipIf
(
not
torch
.
cuda
.
is_available
(),
"CUDA unavailable"
)
def
test_nms_cuda
(
self
):
...
...
torchvision/csrc/nms.h
View file @
34810c0c
...
...
@@ -12,6 +12,24 @@ at::Tensor nms(
const
at
::
Tensor
&
dets
,
const
at
::
Tensor
&
scores
,
const
double
iou_threshold
)
{
TORCH_CHECK
(
dets
.
dim
()
==
2
,
"boxes should be a 2d tensor, got "
,
dets
.
dim
(),
"D"
);
TORCH_CHECK
(
dets
.
size
(
1
)
==
4
,
"boxes should have 4 elements in dimension 1, got "
,
dets
.
size
(
1
));
TORCH_CHECK
(
scores
.
dim
()
==
1
,
"scores should be a 1d tensor, got "
,
scores
.
dim
(),
"D"
);
TORCH_CHECK
(
dets
.
size
(
0
)
==
scores
.
size
(
0
),
"boxes and scores should have same number of elements in "
,
"dimension 0, got "
,
dets
.
size
(
0
),
" and "
,
scores
.
size
(
0
));
if
(
dets
.
is_cuda
())
{
#if defined(WITH_CUDA)
if
(
dets
.
numel
()
==
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