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
082f37ee
Unverified
Commit
082f37ee
authored
Oct 28, 2021
by
Joao Gomes
Committed by
GitHub
Oct 28, 2021
Browse files
Adding multiweight support for mobilenetv2 prototype (#4784)
parent
79b350eb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
torchvision/prototype/models/__init__.py
torchvision/prototype/models/__init__.py
+1
-0
torchvision/prototype/models/mobilenetv2.py
torchvision/prototype/models/mobilenetv2.py
+46
-0
No files found.
torchvision/prototype/models/__init__.py
View file @
082f37ee
...
@@ -4,6 +4,7 @@ from .densenet import *
...
@@ -4,6 +4,7 @@ from .densenet import *
from
.vgg
import
*
from
.vgg
import
*
from
.efficientnet
import
*
from
.efficientnet
import
*
from
.mobilenetv3
import
*
from
.mobilenetv3
import
*
from
.mobilenetv2
import
*
from
.mnasnet
import
*
from
.mnasnet
import
*
from
.
import
detection
from
.
import
detection
from
.
import
quantization
from
.
import
quantization
...
...
torchvision/prototype/models/mobilenetv2.py
0 → 100644
View file @
082f37ee
import
warnings
from
functools
import
partial
from
typing
import
Any
,
Optional
from
torchvision.transforms.functional
import
InterpolationMode
from
...models.mobilenetv2
import
MobileNetV2
from
..transforms.presets
import
ImageNetEval
from
._api
import
Weights
,
WeightEntry
from
._meta
import
_IMAGENET_CATEGORIES
__all__
=
[
"MobileNetV2"
,
"MobileNetV2Weights"
,
"mobilenet_v2"
]
_common_meta
=
{
"size"
:
(
224
,
224
),
"categories"
:
_IMAGENET_CATEGORIES
,
"interpolation"
:
InterpolationMode
.
BILINEAR
}
class
MobileNetV2Weights
(
Weights
):
ImageNet1K_RefV1
=
WeightEntry
(
url
=
"https://download.pytorch.org/models/mobilenet_v2-b0353104.pth"
,
transforms
=
partial
(
ImageNetEval
,
crop_size
=
224
),
meta
=
{
**
_common_meta
,
"recipe"
:
"https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv2"
,
"acc@1"
:
71.878
,
"acc@5"
:
90.286
,
},
)
def
mobilenet_v2
(
weights
:
Optional
[
MobileNetV2Weights
]
=
None
,
progress
:
bool
=
True
,
**
kwargs
:
Any
)
->
MobileNetV2
:
if
"pretrained"
in
kwargs
:
warnings
.
warn
(
"The argument pretrained is deprecated, please use weights instead."
)
weights
=
MobileNetV2Weights
.
ImageNet1K_RefV1
if
kwargs
.
pop
(
"pretrained"
)
else
None
weights
=
MobileNetV2Weights
.
verify
(
weights
)
if
weights
is
not
None
:
kwargs
[
"num_classes"
]
=
len
(
weights
.
meta
[
"categories"
])
model
=
MobileNetV2
(
**
kwargs
)
if
weights
is
not
None
:
model
.
load_state_dict
(
weights
.
state_dict
(
progress
=
progress
))
return
model
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