Unverified Commit 2b5ab1bc authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

Adding improved MobileNetV2 weights (#5560)

* Adding improved MobileNetV2 weights

* Fix eval sizes.

* Update accuracy with batch-size 1 run
parent 358fc6dd
...@@ -13,11 +13,7 @@ from ._utils import handle_legacy_interface, _ovewrite_named_param ...@@ -13,11 +13,7 @@ from ._utils import handle_legacy_interface, _ovewrite_named_param
__all__ = ["MobileNetV2", "MobileNet_V2_Weights", "mobilenet_v2"] __all__ = ["MobileNetV2", "MobileNet_V2_Weights", "mobilenet_v2"]
class MobileNet_V2_Weights(WeightsEnum): _COMMON_META = {
IMAGENET1K_V1 = Weights(
url="https://download.pytorch.org/models/mobilenet_v2-b0353104.pth",
transforms=partial(ImageNetEval, crop_size=224),
meta={
"task": "image_classification", "task": "image_classification",
"architecture": "MobileNetV2", "architecture": "MobileNetV2",
"publication_year": 2018, "publication_year": 2018,
...@@ -26,12 +22,31 @@ class MobileNet_V2_Weights(WeightsEnum): ...@@ -26,12 +22,31 @@ class MobileNet_V2_Weights(WeightsEnum):
"min_size": (1, 1), "min_size": (1, 1),
"categories": _IMAGENET_CATEGORIES, "categories": _IMAGENET_CATEGORIES,
"interpolation": InterpolationMode.BILINEAR, "interpolation": InterpolationMode.BILINEAR,
}
class MobileNet_V2_Weights(WeightsEnum):
IMAGENET1K_V1 = Weights(
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", "recipe": "https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv2",
"acc@1": 71.878, "acc@1": 71.878,
"acc@5": 90.286, "acc@5": 90.286,
}, },
) )
DEFAULT = IMAGENET1K_V1 IMAGENET1K_V2 = Weights(
url="https://download.pytorch.org/models/mobilenet_v2-7ebf99e0.pth",
transforms=partial(ImageNetEval, crop_size=224, resize_size=232),
meta={
**_COMMON_META,
"recipe": "https://github.com/pytorch/vision/issues/3995#new-recipe-with-reg-tuning",
"acc@1": 72.154,
"acc@5": 90.822,
},
)
DEFAULT = IMAGENET1K_V2
@handle_legacy_interface(weights=("pretrained", MobileNet_V2_Weights.IMAGENET1K_V1)) @handle_legacy_interface(weights=("pretrained", MobileNet_V2_Weights.IMAGENET1K_V1))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment