pytorch-image-models (huggingface/pytorch-image-models)

Searching Database…

What is this?PyTorch Image Models (timm) — the largest collection of PyTorch image encoders and backbones, shipped with pretrained weights plus train, eval, inference and export scripts.
Is this a library I import into my own code, or a tool I run?A Python library you import into your own PyTorch code — the repo also ships ready-made scripts for training, validation, inference and export that you can run from the command line.
How do I add it to my project?Install it with 'pip install timm', then build a model in code like timm.create_model('resnet50', pretrained=True) — pretrained weights are pulled from the Hugging Face Hub on first use.
Which Python and PyTorch versions does it need?Nothing exotic: unit tests cover Python 3.10 up to 3.13 and PyTorch 1.13 up to 2.9.1, so even fairly old environments are supported.
Is it safe to load checkpoints I find online?Loading third-party checkpoints used to be a pickle risk, but recent releases hardened it: loading now defaults to weights_only=True, so a malicious pickle can't execute arbitrary code.
The code is Apache-2.0 — does that cover the pretrained weights too?The code is Apache-2.0, but individual pretrained weights can carry their own terms — the README keeps a separate Licenses section listing them, so check it before commercial use.
Do I need a big GPU, or will a CPU do?It runs anywhere PyTorch runs, CPU included — the collection even added CPUBone, an efficient vision backbone for devices with low parallelization capabilities.
What is NaFlexViT and why would I pick it?It's timm's flexible Vision Transformer: one model that handles variable aspect ratios and resolutions per image, and even variable patch sizes. Classic ViTs load into it with use_naflex=True, and a matching --naflex-loader data pipeline covers training, fine-tuning and evaluation on non-square images.
Beyond ImageNet classifiers, are there self-supervised or CLIP-style encoders?Yes — recent releases added DINOv3 ViT and ConvNeXt weights, SigLIP-2 NaFlex ViT encoders, and MobileCLIP-2 and MetaCLIP-2 vision encoders, so timm doubles as a source of general-purpose backbones.
Where can I check a model's accuracy and speed before picking one?The repo publishes result CSVs with ImageNet top-1/top-5 accuracy for every model, plus inference timing benchmarks run on RTX 4090, 5090 and RTX Pro 6000 cards with PyTorch 2.9.1 — handy for trading accuracy against latency.
Is timm still actively developed?Very much — releases land almost monthly (v1.0.29 in August 2026 added LowFormer weights), and the original maintainer keeps shipping after leaving Hugging Face.
Size
32.6 MB
Stars
37.3K
Age
7y
Commits · 90 Days