reset_classifier() and checkpoint reconstruction: fixes across ViT, EVA, BEiT, NaFlexViT, RepViT and iFormer
preserve normalization placement and distillation settings when exporting / reloading models after changing the
classifier or pooling. Also fix unpooled PiT export and EfficientFormerV2 with distillation disabled.
NaFlex: fix ViT / EVA norm placement during conversion, support SwiGLU alignment for DINOv3 / Lingbot checkpoints,
and preserve grayscale / non-RGB input channels in data loaders.
Fix layer-wise LR decay grouping for RepViT, HGNet, MViTv2 and pre-norm ViTs, and InceptionNeXt feature sizes with
output_stride=8/16.
Release 1.0.31.
October 24, 2026
forward_intermediates() and prune_intermediate_layers() are now supported by every model. Newly added for CSPNet, NFNet, DLA, DenseNet (#2870, thanks ghaith-mq), CoaT, ConViT, ConvMixer, CrossViT, HRNet, Inception-v3, Inception-ResNet-v2, NASNet, PNASNet, SelecSLS, SENet, Sequencer2d, VGG, Visformer, Xception and Aligned Xception, with prune_intermediate_layers() for NaFlexViT and MobileNetV5 encoders. CoaT, ConViT, ConvMixer, CrossViT and Visformer gain features_only support.
prune_intermediate_layers() fixes
prune_head=True removes the whole head (head norm, pre-logits layers, attention pooling) so the pruned model leaves no unused params (DDP w/o find_unused_parameters), except CoaT, CrossViT and HRNet when only some of their parallel scales / branches are taken. Pass to keep it.
prune_head=False
Pruning a hierarchical model to an earlier stage removes the final norm and head sized for the last stage, forward_features() ends at the last kept feature and num_features / head_hidden_size match it. Pruning to the stem feature removes the stem pooling after it.
Fixes for grad checkpointing, stop_early, class token / post network removal, and TorchScript of pruned / feature_cls='getter' models across many families.
head_hidden_size is the actual pre-logits (pooled) width in all models, including concat pooling (catavgmax) and after reset_classifier(). Pool types a model can't apply now raise at creation / reset instead of being silently ignored or failing in forward.
Other fixes: VOLO num_classes=0 output is the class token embedding (matching forward_head(pre_logits=True)), vit_pe_corereset_classifier() w/ a non map pool removes the attention pool, pool type export via save_for_hf reads the head's current pooling, and headless (num_classes=0) Swin, SwinV2, DaViT and NextViT checkpoints reload correctly.
October 13, 2026
Hyperparameter sweeps via a new sweep.py: grid / random search over any train.py argument, one effective --config per job, run on a pool of local GPUs and resumable. WSD sweeps train one stable trunk per hyperparameter combination and branch independent cooldowns from its milestone checkpoints, comparing annealing at several budgets for a fraction of the cost of full runs. See the training docs.
train.py: --resume auto resumes in place from the experiment's own last.pth.tar (checkpoint history, model_best and summary.csv stay consistent), --stop-epoch N stops without changing the schedule, --save-epochs N [N ...] keeps milestone-N.pth.tar snapshots, and YAML --config values are validated against the script's arguments.
Deprecate PlateauLRScheduler (--sched plateau). timm schedulers are stateless functions of the epoch or update count, the metric-driven plateau schedule never fit that and its state is not checkpointed, so resume was never exact. Use cosine or wsd.
Docs: new Model API page, generated model family pages for every model module replacing the old per-model pages, and expanded data / loss / models reference pages.
Model API consistency fixes: reset_classifier() keeps the current pooling in all models, unknown constructor args raise TypeError everywhere, Swin family dynamic_img_size, LeViT layer-wise lr decay, no_weight_decay names that matched no params (NesT, SwinV2, XCiT, FocalNet), resize state recorded for all set_input_size families.
Fixes: GCViT global query mixed images within a batch, gradient checkpointing for RDNet and MobileNetV5, save_for_hf stale test input size, EfficientViT (MSRA) rectangular resize, ImageDataset image conversion errors (#2846). reparameterize_model moved to timm.models.
October 9, 2026
Add CSPNeXt (RTMDet backbone) cspnext_{tiny,s,m,l,x} with ImageNet-1k classification weights converted from OpenMMLab. Thanks Munehiro Kobayashi.
Optimizer improvements
Foreach (multi-tensor) impls for RMSpropTF, LaProp, LAMB, LARS, AdaBelief. Foreach steps are chunked by device L2 cache size (TIMM_FOREACH_CHUNK_SIZE to override).
RMS update clipping (clipping_threshold) for AdamWLegacy / NAdamW, new decoupled / corrected weight decay NovoGrad variants (novogradw, novogradc).
Correctness fixes across many optimizers, including corrected weight decay w/ in-place updated tensor lr, FP16 update stalls at small lr, low precision state handling (Kron, AdaBelief, NovoGrad), and no more in-place p.grad
modification.
torch.compile / CUDA graph fixes for Adopt, SGDW, AdafactorBV.
New optimizer docs covering usage, naming conventions, and families.
Add WSD (warmup-stable-decay) LR scheduler (--sched wsd, --lr-decay-fn, --lr-stable-timescale).
Model EMA fixes for bfloat16 / float16 models. ModelEmaV3 bfloat16 EMAs use stochastic rounding by default, float16 models keep a float32 EMA.
Model resizing via set_input_size()
Expanded support for windowed models (MaxViT, CoAtNet, BEiT, EfficientViT-MSRA, relpos ViT, Swin family).
Swin / SwinV2 / SwinV2-CR keep each stage's window to grid ratio on resize, a call at the current size is now a no-op. Per-stage window_size / window_ratio supported. Fixes Swin S3 and SwinV2 window16 / window12 models
changing outputs on a same-size call.
Fix SwinV2 NaN w/ a window size of 1, odd stage feature sizes, and hybrid ViT resize on CUDA / low precision.
Fix grad accumulation remainder handling (#2821), distributed sampling / repeated augmentation on small datasets, pretrained source overrides and distillation teacher setup, train.py w/ --sched none, and eval center crop
interpolation for non-square inputs.
ONNX export compatibility fixes across PyTorch versions, dropout consistency fixes, and more meta-device init fixes.
September 25, 2026
Multi-label classification support
Add --task multilabel to train.py / validate.py, trained with BCE (MultiLabelClassificationTask). See the
training docs for details.
Targets can be lists of class indices, dense multi-hot vectors (--target-format multihot), or one binary field
per class (--target-key a,b,c), with / paths into nested fields. Supported by the hfds, hfids, tfds
(multi-field keys), and wds readers.
Mixup / CutMix and NaFlex loaders support multi-label targets. Label smoothing moves each target towards 0.5
and defaults to 0 for multi-label.
Validation reports mAP (the default --eval-metric) plus micro, macro, and sample F1, with an F1 threshold set by
--multilabel-threshold.
New dataset-level evaluators compute metrics over the full validation set across distributed ranks, excluding
distributed sampler padding.
Poly-1, Two-way, ZLPR, and Distribution-Balanced losses.
Class-frequency weighting for BCE / ASL, computed from label counts gathered by class_weights.py.
ASL is now fp16-safe and defaults to batchmean reduction
RoPE Refactor
Extend training-only RoPE coordinate augmentation (shift, jitter, rescale) to axial, mixed, and MRoPE embeddings,
sharing helpers with DINOv3 while preserving its existing augmentation behavior.
Add grid_type and normalize_coords options to the Fourier / rotary builders (build_fourier_pos_embed,
build_rotary_pos_embed) and axial RoPE modules, and configurable MRoPE sections in EVA.
Support rotate_half in the tuple-output RotaryEmbedding and the base factory variant.
Correct rotation-layout forwarding in EVA, NaFlexViT, and MRoPE attention pooling.
Keep non-learned RoPE frequency and coordinate buffers at least float32 in half/bfloat16 models, and compute mixed
RoPE phases in float32 under autocast. These precision fixes can change low-precision model outputs.
Fix batched RoPE embeddings for pixel grids and reference-shape rescaling. DINOv3 grid_indexing='xy' now swaps
coordinate channels as requested; outputs for these previously incorrect configurations change.
Make apply_rot_embed, apply_rot_embed_cat, and apply_rot_embed_list return each input's dtype, casting after
the rotation without first downcasting sin/cos.
Consolidate the two axial RoPE modules behind a private base. Existing calls remain compatible, but the bands
buffer is now retained in both cached and dynamic modes (rope.bands is no longer None in cached mode).
Train/eval mode switch and dtype change fixes for LeViT and related models (EfficentFormer*, EfficientViT-MSRA, TinyViT) w/ cached attention biases.
September 22, 2026
Add Qwen-Drive-1.0-4B vision tower weights.
Fix prefetch loader stream reuse/synchronization and AugMix for non-square and single-band images.
Fix AdaMuon conv LR scaling, AdafactorBigVision clipping, MARS gradient history, and Kron checkpoint loading.
Fix stale eval attention bias caches, pruned model feature metadata, dilated max-pool padding, and asymmetric loss gradient mode.
Release 1.0.30
September 10-11, 2026
Add Qwen3-VL / Qwen3.5 / Qwen3.8 ViT classifier and encoder variants, including classifiers w/ and w/o the native spatial merger.
Add Sapiens2 ViTs with EVA and NaFlexViT support. Both model additions include native timm Hub weights. Thanks Yonghye Kwon.
Add iFormer with native timm Hub weights. Thanks Ryan Hou.
Add EfficientViM with native timm Hub weights. Thanks smellslikeml.
Add DeepSeek-V4 / V4.1 ViT classifiers and encoders with native timm Hub weights. Thanks Yonghye Kwon.
Switch default NaFlex SigLIP position interpolation, inference.py input-size selection, and improve --model-kwargs parsing.
Fix meta-device construction and device/dtype factory support for a few models; move config tests to meta for faster CI, meta context coverage.
Factor non-persistent param init out of __init__ into a common method that can be externally called via init_non_persistent_buffers() after meta-device init.
extra flexibility and improved handling for conv weights and fallbacks for weight shapes not suited for orthogonalization
small speedup for NS iterations by reducing allocs and using fused (b)add(b)mm ops
by default uses AdamW (or NAdamW if nesterov=True) updates if muon not suitable for parameter shape (or excluded via param group flag)
like torch impl, select from several LR scale adjustment fns via adjust_lr_fn
select from several NS coefficient presets or specify your own via ns_coefficients
First 2 steps of 'meta' device model initialization supported
Fix several ops that were breaking creation under 'meta' device context
Add device & dtype factory kwarg support to all models and modules (anything inherting from nn.Module) in timm
License fields added to pretrained cfgs in code
Release 1.0.21
Sept 21, 2025
Remap DINOv3 ViT weight tags from lvd_1689m -> lvd1689m to match (same for sat_493m -> sat493m)
Release 1.0.20
Introduction
PyTorch Image Models (timm) is a collection of image models, layers, utilities, optimizers, schedulers, data-loaders / augmentations, and reference training / validation scripts that aim to pull together a wide variety of SOTA models with ability to reproduce ImageNet training results.
The work of many others is present here. I've tried to make sure all source material is acknowledged via links to github, arxiv papers, etc in the README, documentation, and code docstrings. Please let me know if I missed anything.
Features
Models
All model architecture families include variants with pretrained weights. There are specific model variants without any weights, it is NOT a bug. Help training new or better weights is always appreciated.
Several (less common) features that I often utilize in my projects are included. Many of their additions are the reason why I maintain my own set of models, instead of using others' via PIP:
All models have a common default configuration interface and API for
accessing/changing the classifier - get_classifier and reset_classifier
doing a forward pass on just the features - forward_features (see documentation)
these makes it easy to write consistent network wrappers that work with any of the models
All models support multi-scale feature map extraction (feature pyramids) via create_model (see documentation)
out_indices creation arg specifies which feature maps to return, these indices are 0 based and generally correspond to the C(i + 1) feature level.
output_stride creation arg controls output stride of the network by using dilated convolutions. Most networks are stride 32 by default. Not all networks support this.
feature map channel counts, reduction level (stride) can be queried AFTER model creation via the .feature_info member
All models have a consistent pretrained weight loader that adapts last linear if necessary, and from 3 to 1 channel input if desired
NVIDIA DDP w/ a single GPU per process, multiple processes with APEX present (AMP mixed-precision optional)
PyTorch DistributedDataParallel w/ multi-gpu, single process (AMP disabled as it crashes when enabled)
PyTorch w/ single GPU single process (AMP optional)
A dynamic global pool implementation that allows selecting from average pooling, max pooling, average + max, or concat([average, max]) at model creation. All global pooling is adaptive average by default and compatible with pretrained weights.
A 'Test Time Pool' wrapper that can wrap any of the included models and usually provides improved performance doing inference with input images larger than the training size. Idea adapted from original DPN implementation when I ported (https://github.com/cypw/DPNs)
timmdocs is an alternate set of documentation for timm. A big thanks to Aman Arora for his efforts creating timmdocs.
paperswithcode is a good resource for browsing the models within timm.
Train, Validation, Inference Scripts
The root folder of the repository contains reference train, validation, and inference scripts that work with the included models and other features of this repository. They are adaptable for other datasets and use cases with a little hacking. See documentation.
Awesome PyTorch Resources
One of the greatest assets of PyTorch is the community and their contributions. A few of my favourite resources that pair well with the models and components here are listed below.
Object Detection, Instance and Semantic Segmentation
The code here is licensed Apache 2.0. I've taken care to make sure any third party code included or adapted has compatible (permissive) licenses such as MIT, BSD, etc. I've made an effort to avoid any GPL / LGPL conflicts. That said, it is your responsibility to ensure you comply with licenses here and conditions of any dependent licenses. Where applicable, I've linked the sources/references for various components in docstrings. If you think I've missed anything please create an issue.
Pretrained Weights
So far all of the pretrained weights available here are pretrained on ImageNet with a select few that have some additional pretraining (see extra note below). ImageNet was released for non-commercial research purposes only (https://image-net.org/download). It's not clear what the implications of that are for the use of pretrained weights from that dataset. Any models I have trained with ImageNet are done for research purposes and one should assume that the original dataset license applies to the weights. It's best to seek legal advice if you intend to use the pretrained weights in a commercial product.
Pretrained on more than ImageNet
Several weights included or references here were pretrained with proprietary datasets that I do not have access to. These include the Facebook WSL, SSL, SWSL ResNe(Xt) and the Google Noisy Student EfficientNet models. The Facebook models have an explicit non-commercial license (CC-BY-NC 4.0, https://github.com/facebookresearch/semi-supervised-ImageNet1K-models, https://github.com/facebookresearch/WSL-Images). The Google models do not appear to have any restriction beyond the Apache 2.0 license (and ImageNet concerns). In either case, you should contact Facebook or Google with any questions.
Citing
BibTeX
@misc{rw2019timm,
author = {Ross Wightman},
title = {PyTorch Image Models},
year = {2019},
publisher = {GitHub},
journal = {GitHub repository},
doi = {10.5281/zenodo.4414861},
howpublished = {\url{https://github.com/rwightman/pytorch-image-models}}
}
Latest DOI
Alternatives
Use instead of timm: tools that do the same job, closest first.