timm (PyTorch Image Models)

The largest collection of pretrained PyTorch image models, layers, and training utilities.

Library
PyPI
v1.0.28
37,074stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
92/100Excellent
Development Activity96
Maintenance96
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
84/100Excellent
Architecture88
Code Quality85
Innovation85
Learning Curve78

timm (short for PyTorch Image Models) is a library that collects hundreds of state-of-the-art image classification and vision backbone architectures — ResNet, EfficientNet, Vision Transformer, ConvNeXt, MaxViT, MobileNetV4, and many more — behind a single, consistent Python API. Every model ships with pretrained weights sourced from original papers, reproductions, or timm’s own training recipes, plus reusable layers, optimizers, and LR schedulers extracted from the best-performing training runs.

Maintained by Ross Wightman and now under Hugging Face, timm has become a de facto standard vision backbone library for computer vision research and production pipelines, offering training, evaluation, inference, and ONNX export scripts alongside the model zoo itself, so a model can be created, fine-tuned, and deployed without leaving the same ecosystem.

What You Get

  • A single factory function, create_model(), that instantiates any of 1000+ model variants with matching pretrained weights
  • Reusable, tested building blocks: attention layers, normalization, activation functions, and pooling implementations extracted from published architectures
  • Training, validation, inference, and ONNX export scripts (train.py, validate.py, inference.py, onnx_export.py) usable directly or as templates
  • A library of optimizers and LR schedulers (cosine, step, plateau, and custom schedules) tuned for vision training
  • Automatic pretrained-weight downloading and caching via Hugging Face Hub integration
  • Feature-extraction API for using any model as a backbone that returns intermediate feature maps

Common Use Cases

  • Fine-tuning a pretrained vision backbone (ResNet, ConvNeXt, ViT, etc.) on a custom image classification dataset
  • Using timm models as feature extractors/backbones inside larger detection, segmentation, or multi-modal pipelines
  • Benchmarking or reproducing published vision architectures with a consistent training recipe
  • Exporting a trained model to ONNX for production inference outside of PyTorch

Under The Hood

Architecture: timm is organized as a model zoo (timm/models/) of architecture implementations sharing common building blocks in timm/layers/ (attention, normalization, activations, pooling), with timm/data/ handling dataset/transform pipelines, timm/optim/ and timm/scheduler/ providing training infrastructure, and a central create_model() factory in timm/models/_factory.py-style registry that maps string names to architecture classes and pretrained weight URLs. Tech Stack: Pure PyTorch (torch, torchvision) with huggingface_hub for weight distribution, safetensors for weight serialization, and pyyaml for config; packaged with PDM backend, requiring Python 3.8+. Code Quality: The tests/ directory covers model instantiation/forward-pass correctness (test_models.py), layers, optimizers, and schedulers across the model zoo, run via pytest with xdist/forked parallelism for the very large model matrix; the codebase is typed (py.typed marker) and follows a consistent per-architecture file/class naming convention. API Design: The dominant entry point, timm.create_model(name, pretrained=True, num_classes=N), is deliberately uniform across all 1000+ architectures, minimizing the boilerplate needed to swap backbones, with well-documented Hugging Face docs and per-architecture README notes covering training recipes and known results.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search