Skip to content

Commit aaa63a2

Browse files
authored
Merge branch 'main' into bkorbar/5245
2 parents 851bf7b + 61a52b9 commit aaa63a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+956
-301
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.circleci/config.yml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ jobs:
351351
- install_torchvision
352352
- install_prototype_dependencies
353353
- pip_install:
354-
args: scipy pycocotools
354+
args: scipy pycocotools h5py
355355
descr: Install optional dependencies
356356
- run:
357357
name: Enable prototype tests

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ supported Python versions.
2323
+==========================+==========================+=================================+
2424
| ``main`` / ``nightly`` | ``main`` / ``nightly`` | ``>=3.7``, ``<=3.9`` |
2525
+--------------------------+--------------------------+---------------------------------+
26+
| ``1.10.2`` | ``0.11.3`` | ``>=3.6``, ``<=3.9`` |
27+
+--------------------------+--------------------------+---------------------------------+
2628
| ``1.10.1`` | ``0.11.2`` | ``>=3.6``, ``<=3.9`` |
2729
+--------------------------+--------------------------+---------------------------------+
2830
| ``1.10.0`` | ``0.11.1`` | ``>=3.6``, ``<=3.9`` |

docs/source/models.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ You can construct a model with random weights by calling its constructor:
8989
vit_b_32 = models.vit_b_32()
9090
vit_l_16 = models.vit_l_16()
9191
vit_l_32 = models.vit_l_32()
92+
convnext_tiny = models.convnext_tiny()
93+
convnext_small = models.convnext_small()
94+
convnext_base = models.convnext_base()
95+
convnext_large = models.convnext_large()
9296
9397
We provide pre-trained models, using the PyTorch :mod:`torch.utils.model_zoo`.
9498
These can be constructed by passing ``pretrained=True``:
@@ -136,6 +140,10 @@ These can be constructed by passing ``pretrained=True``:
136140
vit_b_32 = models.vit_b_32(pretrained=True)
137141
vit_l_16 = models.vit_l_16(pretrained=True)
138142
vit_l_32 = models.vit_l_32(pretrained=True)
143+
convnext_tiny = models.convnext_tiny(pretrained=True)
144+
convnext_small = models.convnext_small(pretrained=True)
145+
convnext_base = models.convnext_base(pretrained=True)
146+
convnext_large = models.convnext_large(pretrained=True)
139147
140148
Instancing a pre-trained model will download its weights to a cache directory.
141149
This directory can be set using the `TORCH_HOME` environment variable. See
@@ -248,7 +256,10 @@ vit_b_16 81.072 95.318
248256
vit_b_32 75.912 92.466
249257
vit_l_16 79.662 94.638
250258
vit_l_32 76.972 93.070
251-
convnext_tiny (prototype) 82.520 96.146
259+
convnext_tiny 82.520 96.146
260+
convnext_small 83.616 96.650
261+
convnext_base 84.062 96.870
262+
convnext_large 84.414 96.976
252263
================================ ============= =============
253264

254265

@@ -464,6 +475,18 @@ VisionTransformer
464475
vit_l_16
465476
vit_l_32
466477

478+
ConvNeXt
479+
--------
480+
481+
.. autosummary::
482+
:toctree: generated/
483+
:template: function.rst
484+
485+
convnext_tiny
486+
convnext_small
487+
convnext_base
488+
convnext_large
489+
467490
Quantized Models
468491
----------------
469492

docs/source/utils.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ vizualization <sphx_glr_auto_examples_plot_visualization_utils.py>`.
1515
draw_bounding_boxes
1616
draw_segmentation_masks
1717
draw_keypoints
18+
flow_to_image
1819
make_grid
1920
save_image

hubconf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
dependencies = ["torch"]
33

44
from torchvision.models.alexnet import alexnet
5+
from torchvision.models.convnext import convnext_tiny, convnext_small, convnext_base, convnext_large
56
from torchvision.models.densenet import densenet121, densenet169, densenet201, densenet161
67
from torchvision.models.efficientnet import (
78
efficientnet_b0,

references/classification/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,12 @@ and `--batch_size 64`.
201201
### ConvNeXt
202202
```
203203
torchrun --nproc_per_node=8 train.py\
204-
--model convnext_tiny --batch-size 128 --opt adamw --lr 1e-3 --lr-scheduler cosineannealinglr \
204+
--model $MODEL --batch-size 128 --opt adamw --lr 1e-3 --lr-scheduler cosineannealinglr \
205205
--lr-warmup-epochs 5 --lr-warmup-method linear --auto-augment ta_wide --epochs 600 --random-erase 0.1 \
206206
--label-smoothing 0.1 --mixup-alpha 0.2 --cutmix-alpha 1.0 --weight-decay 0.05 --norm-weight-decay 0.0 \
207-
--train-crop-size 176 --model-ema --val-resize-size 236 --ra-sampler --ra-reps 4
207+
--train-crop-size 176 --model-ema --val-resize-size 232 --ra-sampler --ra-reps 4
208208
```
209+
Here `$MODEL` is one of `convnext_tiny`, `convnext_small`, `convnext_base` and `convnext_large`. Note that each variant had its `--val-resize-size` optimized in a post-training step, see their `Weights` entry for their exact value.
209210

210211
Note that the above command corresponds to training on a single node with 8 GPUs.
211212
For generatring the pre-trained weights, we trained with 2 nodes, each with 8 GPUs (for a total of 16 GPUs),

references/classification/train_quantization.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313

1414

1515
try:
16-
from torchvision.prototype import models as PM
16+
from torchvision import prototype
1717
except ImportError:
18-
PM = None
18+
prototype = None
1919

2020

2121
def main(args):
22-
if args.weights and PM is None:
22+
if args.prototype and prototype is None:
2323
raise ImportError("The prototype module couldn't be found. Please install the latest torchvision nightly.")
24+
if not args.prototype and args.weights:
25+
raise ValueError("The weights parameter works only in prototype mode. Please pass the --prototype argument.")
2426
if args.output_dir:
2527
utils.mkdir(args.output_dir)
2628

@@ -54,10 +56,10 @@ def main(args):
5456

5557
print("Creating model", args.model)
5658
# when training quantized models, we always start from a pre-trained fp32 reference model
57-
if not args.weights:
59+
if not args.prototype:
5860
model = torchvision.models.quantization.__dict__[args.model](pretrained=True, quantize=args.test_only)
5961
else:
60-
model = PM.quantization.__dict__[args.model](weights=args.weights, quantize=args.test_only)
62+
model = prototype.models.quantization.__dict__[args.model](weights=args.weights, quantize=args.test_only)
6163
model.to(device)
6264

6365
if not (args.test_only or args.post_training_quantize):
@@ -264,6 +266,12 @@ def get_args_parser(add_help=True):
264266
parser.add_argument("--clip-grad-norm", default=None, type=float, help="the maximum gradient norm (default None)")
265267

266268
# Prototype models only
269+
parser.add_argument(
270+
"--prototype",
271+
dest="prototype",
272+
help="Use prototype model builders instead those from main area",
273+
action="store_true",
274+
)
267275
parser.add_argument("--weights", default=None, type=str, help="the weights enum name to load")
268276

269277
return parser

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def write_version_file():
5858
pytorch_dep += "==" + os.getenv("PYTORCH_VERSION")
5959

6060
requirements = [
61+
"typing_extensions",
6162
"numpy",
6263
"requests",
6364
pytorch_dep,

test/assets/expected_flow.pt

30 KB
Binary file not shown.

0 commit comments

Comments
 (0)