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
0013d931
Unverified
Commit
0013d931
authored
Jun 07, 2021
by
Nicolas Hug
Committed by
GitHub
Jun 07, 2021
Browse files
Port test_backbone_utils.py to pytest (#3991)
parent
182f80df
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
20 deletions
+6
-20
test/test_backbone_utils.py
test/test_backbone_utils.py
+6
-20
No files found.
test/test_backbone_utils.py
View file @
0013d931
import
unittest
import
torch
from
torchvision.models.detection.backbone_utils
import
resnet_fpn_backbone
import
pytest
class
ResnetFPNBackboneTester
(
unittest
.
TestCase
):
@
classmethod
def
setUpClass
(
cls
):
cls
.
dtype
=
torch
.
float32
def
test_resnet18_fpn_backbone
(
self
):
device
=
torch
.
device
(
'cpu'
)
x
=
torch
.
rand
(
1
,
3
,
300
,
300
,
dtype
=
self
.
dtype
,
device
=
device
)
resnet18_fpn
=
resnet_fpn_backbone
(
backbone_name
=
'resnet18'
,
pretrained
=
False
)
y
=
resnet18_fpn
(
x
)
self
.
assertEqual
(
list
(
y
.
keys
()),
[
'0'
,
'1'
,
'2'
,
'3'
,
'pool'
])
def
test_resnet50_fpn_backbone
(
self
):
device
=
torch
.
device
(
'cpu'
)
x
=
torch
.
rand
(
1
,
3
,
300
,
300
,
dtype
=
self
.
dtype
,
device
=
device
)
resnet50_fpn
=
resnet_fpn_backbone
(
backbone_name
=
'resnet50'
,
pretrained
=
False
)
y
=
resnet50_fpn
(
x
)
self
.
assertEqual
(
list
(
y
.
keys
()),
[
'0'
,
'1'
,
'2'
,
'3'
,
'pool'
])
@
pytest
.
mark
.
parametrize
(
'backbone_name'
,
(
'resnet18'
,
'resnet50'
))
def
test_resnet_fpn_backbone
(
backbone_name
):
x
=
torch
.
rand
(
1
,
3
,
300
,
300
,
dtype
=
torch
.
float32
,
device
=
'cpu'
)
y
=
resnet_fpn_backbone
(
backbone_name
=
backbone_name
,
pretrained
=
False
)(
x
)
assert
list
(
y
.
keys
())
==
[
'0'
,
'1'
,
'2'
,
'3'
,
'pool'
]
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