Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions references/classification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ torchrun --nproc_per_node=8 train.py --model inception_v3\
--val-resize-size 342 --val-crop-size 299 --train-crop-size 299 --test-only --pretrained
```

### ResNext-50 32x4d
### ResNet
```
torchrun --nproc_per_node=8 train.py\
--model resnext50_32x4d --epochs 100
torchrun --nproc_per_node=8 train.py --model $MODEL
```

Here `$MODEL` is one of `resnet18`, `resnet34`, `resnet50`, `resnet101` or `resnet152`.

### ResNext-101 32x8d

### ResNext
```
torchrun --nproc_per_node=8 train.py\
--model resnext101_32x8d --epochs 100
--model $MODEL --epochs 100
```

Here `$MODEL` is one of `resnext50_32x4d` or `resnext101_32x8d`.
Note that the above command corresponds to a single node with 8 GPUs. If you use
a different number of GPUs and/or a different batch size, then the learning rate
should be scaled accordingly. For example, the pretrained model provided by
Expand Down
7 changes: 3 additions & 4 deletions torchvision/prototype/models/alexnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
__all__ = ["AlexNet", "AlexNetWeights", "alexnet"]


_common_meta = {"size": (224, 224), "categories": _IMAGENET_CATEGORIES, "interpolation": InterpolationMode.BILINEAR}


class AlexNetWeights(Weights):
ImageNet1K_RefV1 = WeightEntry(
url="https://download.pytorch.org/models/alexnet-owt-7be5be79.pth",
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"size": (224, 224),
"categories": _IMAGENET_CATEGORIES,
"interpolation": InterpolationMode.BILINEAR,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#alexnet-and-vgg",
"acc@1": 56.522,
"acc@5": 79.066,
Expand Down
27 changes: 14 additions & 13 deletions torchvision/prototype/models/densenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,55 +63,56 @@ def _densenet(
return model


_common_meta = {"size": (224, 224), "categories": _IMAGENET_CATEGORIES, "interpolation": InterpolationMode.BILINEAR}
_common_meta = {
"size": (224, 224),
"categories": _IMAGENET_CATEGORIES,
"interpolation": InterpolationMode.BILINEAR,
"recipe": None, # weights ported from LuaTorch
}


class DenseNet121Weights(Weights):
ImageNet1K_RefV1 = WeightEntry(
ImageNet1K_Community = WeightEntry(
url="https://download.pytorch.org/models/densenet121-a639ec97.pth",
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"recipe": "",
"acc@1": 74.434,
"acc@5": 91.972,
},
)


class DenseNet161Weights(Weights):
ImageNet1K_RefV1 = WeightEntry(
ImageNet1K_Community = WeightEntry(
url="https://download.pytorch.org/models/densenet161-8d451a50.pth",
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"recipe": "",
"acc@1": 77.138,
"acc@5": 93.560,
},
)


class DenseNet169Weights(Weights):
ImageNet1K_RefV1 = WeightEntry(
ImageNet1K_Community = WeightEntry(
url="https://download.pytorch.org/models/densenet169-b2777c0a.pth",
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"recipe": "",
"acc@1": 75.600,
"acc@5": 92.806,
},
)


class DenseNet201Weights(Weights):
ImageNet1K_RefV1 = WeightEntry(
ImageNet1K_Community = WeightEntry(
url="https://download.pytorch.org/models/densenet201-c1103571.pth",
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"recipe": "",
"acc@1": 76.896,
"acc@5": 93.370,
},
Expand All @@ -121,7 +122,7 @@ class DenseNet201Weights(Weights):
def densenet121(weights: Optional[DenseNet121Weights] = None, progress: bool = True, **kwargs: Any) -> DenseNet:
if "pretrained" in kwargs:
warnings.warn("The argument pretrained is deprecated, please use weights instead.")
weights = DenseNet121Weights.ImageNet1K_RefV1 if kwargs.pop("pretrained") else None
weights = DenseNet121Weights.ImageNet1K_Community if kwargs.pop("pretrained") else None
weights = DenseNet121Weights.verify(weights)

return _densenet(32, (6, 12, 24, 16), 64, weights, progress, **kwargs)
Expand All @@ -130,7 +131,7 @@ def densenet121(weights: Optional[DenseNet121Weights] = None, progress: bool = T
def densenet161(weights: Optional[DenseNet161Weights] = None, progress: bool = True, **kwargs: Any) -> DenseNet:
if "pretrained" in kwargs:
warnings.warn("The argument pretrained is deprecated, please use weights instead.")
weights = DenseNet161Weights.ImageNet1K_RefV1 if kwargs.pop("pretrained") else None
weights = DenseNet161Weights.ImageNet1K_Community if kwargs.pop("pretrained") else None
weights = DenseNet161Weights.verify(weights)

return _densenet(48, (6, 12, 36, 24), 96, weights, progress, **kwargs)
Expand All @@ -139,7 +140,7 @@ def densenet161(weights: Optional[DenseNet161Weights] = None, progress: bool = T
def densenet169(weights: Optional[DenseNet169Weights] = None, progress: bool = True, **kwargs: Any) -> DenseNet:
if "pretrained" in kwargs:
warnings.warn("The argument pretrained is deprecated, please use weights instead.")
weights = DenseNet169Weights.ImageNet1K_RefV1 if kwargs.pop("pretrained") else None
weights = DenseNet169Weights.ImageNet1K_Community if kwargs.pop("pretrained") else None
weights = DenseNet169Weights.verify(weights)

return _densenet(32, (6, 12, 32, 32), 64, weights, progress, **kwargs)
Expand All @@ -148,7 +149,7 @@ def densenet169(weights: Optional[DenseNet169Weights] = None, progress: bool = T
def densenet201(weights: Optional[DenseNet201Weights] = None, progress: bool = True, **kwargs: Any) -> DenseNet:
if "pretrained" in kwargs:
warnings.warn("The argument pretrained is deprecated, please use weights instead.")
weights = DenseNet201Weights.ImageNet1K_RefV1 if kwargs.pop("pretrained") else None
weights = DenseNet201Weights.ImageNet1K_Community if kwargs.pop("pretrained") else None
weights = DenseNet201Weights.verify(weights)

return _densenet(32, (6, 12, 48, 32), 64, weights, progress, **kwargs)
14 changes: 5 additions & 9 deletions torchvision/prototype/models/efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def _efficientnet(
return model


_common_meta = {"categories": _IMAGENET_CATEGORIES, "interpolation": InterpolationMode.BICUBIC}
_common_meta = {
"categories": _IMAGENET_CATEGORIES,
"interpolation": InterpolationMode.BICUBIC,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#efficientnet",
}


class EfficientNetB0Weights(Weights):
Expand All @@ -72,7 +76,6 @@ class EfficientNetB0Weights(Weights):
meta={
**_common_meta,
"size": (224, 224),
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#efficientnet",
"acc@1": 77.692,
"acc@5": 93.532,
},
Expand All @@ -86,7 +89,6 @@ class EfficientNetB1Weights(Weights):
meta={
**_common_meta,
"size": (240, 240),
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#efficientnet",
"acc@1": 78.642,
"acc@5": 94.186,
},
Expand All @@ -100,7 +102,6 @@ class EfficientNetB2Weights(Weights):
meta={
**_common_meta,
"size": (288, 288),
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#efficientnet",
"acc@1": 80.608,
"acc@5": 95.310,
},
Expand All @@ -114,7 +115,6 @@ class EfficientNetB3Weights(Weights):
meta={
**_common_meta,
"size": (300, 300),
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#efficientnet",
"acc@1": 82.008,
"acc@5": 96.054,
},
Expand All @@ -128,7 +128,6 @@ class EfficientNetB4Weights(Weights):
meta={
**_common_meta,
"size": (380, 380),
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#efficientnet",
"acc@1": 83.384,
"acc@5": 96.594,
},
Expand All @@ -142,7 +141,6 @@ class EfficientNetB5Weights(Weights):
meta={
**_common_meta,
"size": (456, 456),
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#efficientnet",
"acc@1": 83.444,
"acc@5": 96.628,
},
Expand All @@ -156,7 +154,6 @@ class EfficientNetB6Weights(Weights):
meta={
**_common_meta,
"size": (528, 528),
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#efficientnet",
"acc@1": 84.008,
"acc@5": 96.916,
},
Expand All @@ -170,7 +167,6 @@ class EfficientNetB7Weights(Weights):
meta={
**_common_meta,
"size": (600, 600),
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#efficientnet",
"acc@1": 84.122,
"acc@5": 96.908,
},
Expand Down
7 changes: 3 additions & 4 deletions torchvision/prototype/models/googlenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
__all__ = ["GoogLeNet", "GoogLeNetOutputs", "_GoogLeNetOutputs", "GoogLeNetWeights", "googlenet"]


_common_meta = {"size": (224, 224), "categories": _IMAGENET_CATEGORIES, "interpolation": InterpolationMode.BILINEAR}


class GoogLeNetWeights(Weights):
ImageNet1K_Community = WeightEntry(
url="https://download.pytorch.org/models/googlenet-1378be20.pth",
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"size": (224, 224),
"categories": _IMAGENET_CATEGORIES,
"interpolation": InterpolationMode.BILINEAR,
"recipe": "https://github.com/TheCodez/examples/blob/inception/imagenet/README.md#googlenet",
"acc@1": 69.778,
"acc@5": 89.530,
Expand Down
7 changes: 3 additions & 4 deletions torchvision/prototype/models/inception.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
__all__ = ["Inception3", "InceptionOutputs", "_InceptionOutputs", "Inception3Weights", "inception_v3"]


_common_meta = {"size": (299, 299), "categories": _IMAGENET_CATEGORIES, "interpolation": InterpolationMode.BILINEAR}


class Inception3Weights(Weights):
ImageNet1K_TFV1 = WeightEntry(
url="https://download.pytorch.org/models/inception_v3_google-0cc3c7bd.pth",
transforms=partial(ImageNetEval, crop_size=299, resize_size=342),
meta={
**_common_meta,
"size": (299, 299),
"categories": _IMAGENET_CATEGORIES,
"interpolation": InterpolationMode.BILINEAR,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#inception-v3",
"acc@1": 77.294,
"acc@5": 93.450,
Expand Down
9 changes: 6 additions & 3 deletions torchvision/prototype/models/mnasnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
]


_common_meta = {"size": (224, 224), "categories": _IMAGENET_CATEGORIES, "interpolation": InterpolationMode.BILINEAR}
_common_meta = {
"size": (224, 224),
"categories": _IMAGENET_CATEGORIES,
"interpolation": InterpolationMode.BILINEAR,
"recipe": "https://github.com/1e100/mnasnet_trainer",
}


class MNASNet0_5Weights(Weights):
Expand All @@ -32,7 +37,6 @@ class MNASNet0_5Weights(Weights):
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"recipe": "https://github.com/1e100/mnasnet_trainer",
"acc@1": 67.734,
"acc@5": 87.490,
},
Expand All @@ -50,7 +54,6 @@ class MNASNet1_0Weights(Weights):
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"recipe": "https://github.com/1e100/mnasnet_trainer",
"acc@1": 73.456,
"acc@5": 91.510,
},
Expand Down
7 changes: 3 additions & 4 deletions torchvision/prototype/models/mobilenetv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
__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,
"size": (224, 224),
"categories": _IMAGENET_CATEGORIES,
"interpolation": InterpolationMode.BILINEAR,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv2",
"acc@1": 71.878,
"acc@5": 90.286,
Expand Down
9 changes: 6 additions & 3 deletions torchvision/prototype/models/mobilenetv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ def _mobilenet_v3(
return model


_common_meta = {"size": (224, 224), "categories": _IMAGENET_CATEGORIES, "interpolation": InterpolationMode.BILINEAR}
_common_meta = {
"size": (224, 224),
"categories": _IMAGENET_CATEGORIES,
"interpolation": InterpolationMode.BILINEAR,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv3-large--small",
}


class MobileNetV3LargeWeights(Weights):
Expand All @@ -46,7 +51,6 @@ class MobileNetV3LargeWeights(Weights):
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv3-large--small",
"acc@1": 74.042,
"acc@5": 91.340,
},
Expand All @@ -59,7 +63,6 @@ class MobileNetV3SmallWeights(Weights):
transforms=partial(ImageNetEval, crop_size=224),
meta={
**_common_meta,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv3-large--small",
"acc@1": 67.668,
"acc@5": 87.402,
},
Expand Down
Loading