PyTorch Image Models · 1000+ pretrained backbones · create_model factory · verified against timm 1.x (2026)

timm cheat sheet

timm (PyTorch Image Models, now under Hugging Face) is the largest collection of image encoders/backbones — ResNet, EfficientNet, ConvNeXt, ViT, Swin, MaxViT, MobileNetV4 and hundreds more — with pretrained weights, a single create_model factory, matching preprocessing, and feature-extraction hooks. It's the default way to get a SOTA backbone for classification, transfer learning, or as a feature extractor in a detection/segmentation model. This sheet targets timm 1.x.

create & run preprocessing features / backbones fine-tuning hub & training utils gotcha most common

Verified 2026-08-24 against the official docs at huggingface.co/docs/timm / timm.fast.ai and the huggingface/pytorch-image-models repo (timm 1.x). Pretrained weights & configs are hosted on the Hugging Face Hub.

Outline

create_model is the whole API surface. The trick most people miss: use the model's own data config for preprocessing so inputs match the weights.

Get a model

  1. 1 · Install & create_model
  2. 2 · Find models & weights

Run it

  1. 3 · Matching preprocessing
  2. 4 · Inference

As a backbone

  1. 5 · Pooled embeddings
  2. 6 · Feature maps (features_only)

Adapt

  1. 7 · Fine-tune / transfer

Train & share

  1. 8 · Optimizers, schedulers, EMA
  2. 9 · Hugging Face Hub
  3. 10 · Gotchas
  4. Worth memorizing

Get a Model

One factory function, 1000+ architectures.

1Install & create_model1.x
2Find models & weightsdiscover

Run It

Match the model's expected input, then infer.

3Matching preprocessinguse the model's config
4Inferenceforward pass

As a Backbone

timm's superpower: drop-in feature extractors.

5Pooled embeddingsone vector per image
6Feature maps (features_only)FPN / detection
7Fine-tune / transferadapt to your data

Train & Share

timm's training utilities and Hub integration.

8Optimizers, schedulers, EMArecipe helpers
9Hugging Face Hubload & share
!Common gotchasread before shipping

Worth memorizing

create_model is the whole APItimm.create_model(name, pretrained=True, num_classes=N)
num_classes=0 = feature extractorreturns the pooled embedding; num_features is its size
preprocess with the model's configresolve_data_config + create_transform — never hardcode mean/std
model.tag pins exact weightse.g. resnet50.a1_in1k; list_pretrained to see options
features_only for detection/segmulti-scale feature maps; feature_info gives channels & strides
forward_features / forward_headsplit the pass to grab pre-pool maps or pre-logit embeddings
hf_hub: prefixload any timm checkpoint from the Hub by id
it's a plain nn.Modulebring your own loop (or Lightning / HF Trainer)