Skip to content

Latest commit

 

History

3,247 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTorch Image Models

What's New

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.
    • See the timm multi-label image datasets collection on the Hub for example / benchmark datasets that work out of the box.
  • New loss options via --loss
    • 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.

August 27, 2026

  • Add LowFormer model and weights
  • Fix or merge a host of real but small or not commonly encountered bugs surfaced by agents
  • Release 1.0.29

August 11, 2026

  • Add model defs and pretrained weights for
  • Add per-batch image and batch size scheduling for non-NaFlex training, including progressive small-to-large resolution schedules.
  • Improve NaFlexViT with key-only attention masks, compile-friendly and memory-efficient position sampling, and cached variable-patch interpolation.
  • Improve model factory path and checkpoint handling; fix equal-token positional embedding resampling.

July 10, 2026

  • Improve optimizer torch.compile and tensor learning-rate support.
  • Extend NaFlexViT patch-layout (for NaFlex-CLAP), and forward_intermediates (NaFlex dict input) support.
  • Harden pickle loading and improve custom-label inference.
  • Release 1.0.28

May 27, 2026

May 8, 2026

  • Release 1.0.27

April 23, 2026

  • Add Gemma4 ViT encoders w/ NaFlex pipeline support (variable aspect/size per image). Thanks Yonghye Kwon
  • Support DINOv3 weights in NaFlexVit. Thanks Yonghye Kwon
  • Some improvements to Muon fallback (AdamW/NadamW) lr behavior

March 23, 2026

  • Improve pickle checkpoint handling security. Default all loading to weights_only=True, add safe_global for ArgParse.
  • Improve attention mask handling for core ViT/EVA models & layers. Resolve bool masks, pass is_causal through for SSL tasks.
  • Fix class & register token uses with ViT and no pos embed enabled.
  • Add Patch Representation Refinement (PRR) as a pooling option in ViT. Thanks Sina (https://github.com/sinahmr).
  • Improve consistency of output projection / MLP dimensions for attention pooling layers.
  • Hiera model F.SDPA optimization to allow Flash Attention kernel use.
  • Caution added to SGDP optimizer.
  • Release 1.0.26. First maintenance release since my departure from Hugging Face.

Feb 23, 2026

  • Add token distillation training support to distillation task wrappers
  • Remove some torch.jit usage in prep for official deprecation
  • Caution added to AdamP optimizer
  • Call reset_parameters() even if meta-device init so that buffers get init w/ hacks like init_empty_weights
  • Tweak Muon optimizer to work with DTensor/FSDP2 (clamp_ instead of clamp_min_, alternate NS branch for DTensor)
  • Release 1.0.25

Jan 21, 2026

  • Compat Break: Fix oversight w/ QKV vs MLP bias in ParallelScalingBlock (& DiffParallelScalingBlock)
    • Does not impact any trained timm models but could impact downstream use.

Jan 5 & 6, 2026

  • Release 1.0.24
  • Add new benchmark result csv files for inference timing on all models w/ RTX Pro 6000, 5090, and 4090 cards w/ PyTorch 2.9.1
  • Fix moved module error in deprecated timm.models.layers import path that impacts legacy imports
  • Release 1.0.23

Dec 30, 2025

Dec 12, 2025

Dec 1, 2025

  • Add lightweight task abstraction, add logits and feature distillation support to train script via new tasks.
  • Remove old APEX AMP support

Nov 4, 2025

Oct 31, 2025 🎃

  • Update imagenet & OOD variant result csv files to include a few new models and verify correctness over several torch & timm versions
  • EfficientNet-X and EfficientNet-H B5 model weights added as part of a hparam search for AdamW vs Muon (still iterating on Muon runs)

Oct 16-20, 2025

  • Add an impl of the Muon optimizer (based on https://github.com/KellerJordan/Muon) with customizations
    • 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.

Optimizers

To see full list of optimizers w/ descriptions: timm.optim.list_optimizers(with_description=True)

Included optimizers available via timm.optim.create_optimizer_v2 factory method:

Augmentations

Regularization

Other

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:

Results

Model validation results can be found in the results tables

Getting Started (Documentation)

The official documentation can be found at https://huggingface.co/docs/hub/timm. Documentation contributions are welcome.

Getting Started with PyTorch Image Models (timm): A Practitioner’s Guide by Chris Hughes is an extensive blog post covering many aspects of timm in detail.

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

Computer Vision / Image Augmentation

Knowledge Distillation

Metric Learning

Training / Frameworks

Deployment

Licenses

Code

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

DOI

About

The largest collection of PyTorch image encoders / backbones. Including train, eval, inference, export scripts, and pretrained weights -- ResNet, ResNeXT, EfficientNet, NFNet, Vision Transformer (ViT), MobileNetV4, MobileNet-V3 & V2, RegNet, DPN, CSPNet, Swin Transformer, MaxViT, CoAtNet, ConvNeXt, and more

Topics

Resources

Code of conduct

Contributing

Stars

37.2k stars

Watchers

322 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages