timm (PyTorch Image Models)
The largest collection of pretrained PyTorch image models, layers, and training utilities.
Repository Health
Technical Analysis
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.
Used by 3 apps in this directory
clarity-upscaler
AI Design Tools · Design Tools
Free open-source AI image upscaler reaching 13K resolution using Stable Diffusion, ControlNet, and Tiled Diffusion — a self-hostable alternative to Magnific.
Gemma Multimodal Fine-Tuner
AI Development
An Apple-Silicon-native LoRA fine-tuning tool for Gemma on text, image, and audio data — with a wizard CLI, live browser-based training visualizer, and streaming from GCS/BigQuery for datasets too large for local disk.
LibrePhotos
File Storage
Self-hosted photo library with AI-powered face recognition, semantic search, and automatic event albums — no cloud required.