huggingface/pytorch-image-models
62.3
Adequate · 11 October 2026
126.7k
lines of production code
Python
primary language
4
measurements over time
What this system is
This system is a comprehensive computer vision library that provides a unified framework for training, evaluating, and deploying deep learning models. It offers extensive capabilities for data loading with advanced augmentations, model creation across a wide range of architectures, and standardized training workflows including loss functions, optimizers, and schedulers. The library also supports model conversion, performance benchmarking, and secure weight management via the Hugging Face Hub.
How it got here
2019 — API standardization and modular expansion
11 changes.
This period focused on restructuring the timm library into modular packages for data, loss, optimizers, and schedulers, while standardizing the model API with consistent interfaces and type hints. The work significantly expanded the model library with new architectures and pretrained weights, and introduced comprehensive weight conversion scripts and modern build configurations.
2020–2025 — Architecture reorganization and security hardening
8 changes.
This period focused on restructuring the library's internal architecture by decoupling layer definitions into a dedicated timm.layers package and introducing task-based training abstractions. Significant efforts were also made to enhance security through hardened dataset readers and to improve usability with comprehensive benchmarking, expanded test coverage, and structured Hugging Face documentation.
Features
Add comprehensive model validation and inference benchmark results
The \results\ directory now includes a \README.md\ documenting validation and benchmark datasets, including ImageNet-1k, ImageNetV2, ImageNet-Sketch, ImageNet-Adversarial, and ImageNet-Rendition. New CSV files provide inference benchmark data for models on RTX 3090 and RTX 4090 GPUs using PyTorch 1.13, 2.1, and 2.4, covering NCHW and NHWC formats with AMP precision. These files allow users to compare model performance across different hardware and PyTorch versions.
results · high confidence
Added weight conversion scripts for MXNet, Gemma4, PP-LCNetV2, and Nest models
Users can now convert pretrained weights from external frameworks into timm format using four new scripts in the convert directory. The new convert\_from\_mxnet.py script converts ResNet and other variants from MXNet Gluon to PyTorch. convert\_gemma4\_vit.py extracts and remaps the vision encoder weights from Hugging Face Gemma4 multimodal models into timm-compatible safetensors. convert\_lcnetv2\_paddle.py handles PP-LCNetV2 checkpoints from PaddleClas, including specific handling for dropout folding and key remapping. Finally, convert\_nest\_flax.py converts Nested Transformer weights from Flax/Google Research checkpoints into PyTorch state dicts.
convert · high confidence
Initial repository structure and documentation
The repository is initialized with core documentation files including a README, CONTRIBUTING guidelines, Code of Conduct, and Apache 2.0 license. Configuration files such as .gitignore and .gitattributes are added to manage build artifacts and file metadata. Utility scripts for checkpoint averaging, model benchmarking, and bulk execution are included to support model evaluation and training workflows.
(repo-wide) · high confidence
Introduce task-based training abstractions for classification and distillation
The \timm/task\ module introduces a new object-oriented training architecture that encapsulates the forward pass, loss computation, and metric evaluation into reusable task classes. Users can now train with \ClassificationTask\ and \MultiLabelClassificationTask\, which support configurable loss functions and distributed training via \prepare\_distributed\. The module also adds \DistillationTeacher\ and specific distillation tasks (\LogitDistillationTask\, \FeatureDistillationTask\, \TokenDistillationTask\) to facilitate knowledge distillation workflows, including support for soft/hard distillation and token-based heads. Checkpointing and resumption are handled via new helper functions (\resume\_task\_checkpoint\, \load\_task\_ema\_checkpoint\) that support both the new task state format and legacy model-only checkpoints, while \ClassificationEvaluator\ and \MultiLabelClassificationEvaluator\ provide standardized metric accumulation for validation.
timm/task · high confidence
Major data pipeline reorganization and new augmentation support
The data loading infrastructure has been restructured into a modular package under \timm/data\, introducing a factory-based approach for creating datasets (\create\_dataset\) and loaders (\create\_loader\). This change adds comprehensive support for automated image augmentations, including AutoAugment, RandAugment, AugMix, and 3-Augment, along with Mixup and CutMix. It also introduces new dataset readers for Hugging Face Datasets and TensorFlow Datasets (TFDS), a \RepeatAugSampler\ for distributed training, and a CUDA/NPU-aware \PrefetchLoader\ for optimized batch transfer. Additionally, it provides helper classes for dataset metadata (\DatasetInfo\) and specific support for ImageNet subsets.
timm/data · high confidence
Massive model library expansion and interface standardization
This update significantly expands the timm.models library by adding dozens of new vision architectures (including TResNet, Twins, NaFlexViT, Hiera, ConvNeXt, and various MobileNet and EfficientNet variants) and their corresponding pretrained weights. It also standardizes the model API across all architectures, introducing consistent interfaces for feature extraction (forward\_features, forward\_intermediates), dynamic input resizing (set\_input\_size), and parameter grouping for layer-wise learning rate decay, while migrating pretrained weight sources to the Hugging Face Hub.
timm/models (part 1 of 2) · high confidence · unverified
New centralized optimizer module with factory and layer-decay support
A new \timm/optim\ package has been introduced to centralize optimizer implementations and provide a unified factory interface. This module exposes a wide range of optimizers—including AdaBelief, Adafactor, Lion, Muon, and Adan—alongside standard PyTorch optimizers, all accessible via a consistent namespace. The \create\_optimizer\_v2\ factory enables advanced parameter grouping strategies, specifically layer-wise learning rate decay and weight decay, which are essential for training vision transformers and other architectures with heterogeneous parameter scales. Additionally, the package includes helper utilities for state-dtype preservation during checkpoint loading and optimized multi-tensor (foreach) execution paths for improved performance on CUDA devices.
timm/optim · high confidence
New modular learning rate scheduler system with noise and cycle support
The \timm/scheduler\ module has been restructured into a new, modular system featuring a common \Scheduler\ base class that centralizes learning rate noise, warmup, and state management. This change introduces several new scheduler implementations—including Cosine, MultiStep, Plateau, Polynomial, Step, Tanh, and Warmup-Stable-Decay (WSD)—all of which support configurable learning rate noise, warmup phases, and cycle/restart logic (e.g., cosine annealing with restarts). The \scheduler\_factory\ now provides \create\_scheduler\ and \create\_scheduler\_v2\ methods to instantiate these schedulers, allowing users to select from a wider variety of schedules and configure advanced options like k-decay, cycle multipliers, and noise parameters directly via command-line arguments or configuration objects.
timm/scheduler · high confidence
New modular loss library with factory and multi-label support
The \timm/loss\ package has been introduced to centralize classification loss functions, providing a factory (\create\_classification\_loss\) that instantiates losses by string key (e.g., 'ce', 'bce', 'asl', 'poly', 'jsd', 'twoway', 'zlpr', 'db'). This update adds support for multi-label classification with specific losses like Asymmetric Loss (multi-label and single-label variants), PolyLoss, Two-Way Loss, ZLPR, and Distribution-Balanced Loss. It also enhances Binary Cross-Entropy with options for target thresholding (to handle soft targets from mixup/cutmix), class weighting, and positive class weighting. Additionally, it includes utilities for computing and resolving class weights from label frequencies and supports label smoothing and soft targets across compatible loss types.
timm/loss · high confidence
Reworked training utilities with new EMA, attention extraction, and ONNX export capabilities
The training utility module has been reorganized into separate files, introducing several new capabilities and behavioral changes. Users can now extract attention maps or activations from models using the new AttentionExtract helper, which supports both FX graph tracing and hook-based methods with wildcard or regex matching. Model Exponential Moving Average (EMA) has been upgraded with ModelEmaV2 (simpler, TorchScript-compatible iteration) and ModelEmaV3 (optimized with foreach/in-place operations and bfloat16 stochastic rounding), while the original ModelEma is retained for backward compatibility. Checkpoint saving behavior has changed to support a configurable max history and improved recovery logic, and gradient clipping now supports Adaptive Gradient Clipping (AGC) via the dispatch\_clip\_grad interface. Additionally, ONNX export has been enhanced with support for Dynamo-based exporting, dynamic shapes, and better compatibility across PyTorch versions, while distributed device initialization now explicitly supports Ascend NPU alongside CUDA.
timm/utils · high confidence
Structured Hugging Face documentation site with generated model family pages
The repository now includes a complete Hugging Face documentation site under \hfdocs\. This introduces a new documentation structure organized by model families (e.g., CNNs, Vision Transformers) rather than individual models, with a generator script (\generate\_model\_docs.py\) that builds these pages from code and benchmark data. The site includes tutorials for feature extraction, hyperparameters, and Hugging Face Hub integration, along with a changelog and installation guide. Old per-model documentation pages have been replaced by these family pages, with redirects configured in \\_redirects.yml\ to ensure old links still work.
hfdocs · high confidence
Removals
Removal of legacy model implementations and pooling utilities
The models package has removed several legacy and specialized components: the \fbresnet200\ model file, the \dpn\ (DualPathNetworks) implementation, and the \adaptive\_avgmax\pool\ utility module. Additionally, the \models/\\init\\_.py\ entry point and the \model\_factory.py\ module, which previously handled model instantiation and transform configuration, have been deleted. This cleanup removes older model variants and centralizes model creation logic elsewhere.
models · high confidence
Security
Introduce dedicated dataset reader module with pickle security hardening
The \timm/data/readers\ package has been introduced to centralize dataset loading logic, providing a factory (\create\_reader\) that instantiates specific readers for local image folders, tar archives, Hugging Face datasets, Hugging Face iterable datasets, TensorFlow Datasets, and WebDataset. A key behavioral change is the hardening of pickle deserialization in \class\_map.py\ and \reader\_image\_in\_tar.py\: class map files (\.pkl\) and tar info caches are now loaded using restricted unpicklers that block arbitrary code execution (addressing CVE [GHSA redacted]). Additionally, the new readers support class label remapping via \class\_map\ arguments, allow specifying additional features to return (for HF datasets), and enable \trust\_remote\_code\ for Hugging Face datasets, while ensuring UTF-8 encoding for text-based class maps.
timm/data/readers · high confidence
Architecture
Restructure layer modules into timm.layers package
The library has reorganized its internal structure by moving all layer implementations from timm.models.layers to a new top-level timm.layers package. This change introduces a centralized \_\init\\_.py that exposes all layer classes and functions, and adds a new \_fx.py module to manage TorchFX tracing configuration (leaf modules and autowrap functions). Users should update any direct imports from the old location to use the new timm.layers namespace.
timm/layers · high confidence
Behavioural changes
Deprecation of timm.models.layers in favor of timm.layers
The \timm.models.layers\ module is now deprecated and serves only as a compatibility shim that re-exports all public symbols from the new \timm.layers\ package. Users importing from \timm.models.layers\ will now see a \FutureWarning\ urging them to update their imports to use \timm.layers\ directly. This change reflects the broader reorganization of the library's internal structure, moving layer definitions out of the models namespace to reduce coupling and improve modularity.
timm/models/layers · high confidence
Extensive model refactoring, new architectures, and security fixes
This update introduces a wide range of new vision architectures (including TResNet, Twins, NaFlexViT, Hiera, MambaOut, and various MobileNetV4/EdgeNeXt variants) and adds corresponding pretrained weights to the Hugging Face Hub. It also implements significant behavioral changes to the model API, such as standardizing the forward\_features/forward\_head interface, adding forward\_intermediates() support to most models, and enabling gradient checkpointing. Additionally, it addresses a security vulnerability related to pickle deserialization ([CVE redacted]) and fixes numerous bugs in weight loading, TorchScript compatibility, and feature extraction.
timm/models (part 2 of 2) · high confidence · unverified
timm 1.0.31.dev0 release with module restructure and type hints
This release updates the package version to 1.0.31.dev0 and introduces structural changes to the public API. The \timm/\_\init\\_.py\ file now explicitly exposes core model creation and listing functions (such as \create\_model\, \list\_models\, and \get\_pretrained\_cfg\) alongside scriptability utilities from \timm.layers\. Additionally, a \py.typed\ marker file is added to the package root, enabling PEP 561 compliance for static type checking in downstream projects.
timm · high confidence
Test coverage
New test suite for checkpoint loading, saving, and data pipelines
Added a new test suite in the tests directory covering checkpoint loading and saving logic, data loading and preprocessing (including NaFlex loaders and auto-augment factories), model registry and factory functions, Hub weight loading, input convolution adaptation, and core layer implementations (pooling, dropout, and attention). These tests verify correct behavior for features such as safe weights\_only loading, checkpoint history management, multi-spectral input handling, and various layer configurations.
tests · high confidence
Dependencies
Migrate to pyproject.toml and update core dependencies
The project has replaced the legacy setup.py with a modern pyproject.toml configuration managed by PDM, establishing PyTorch 1.7+ as the minimum version requirement. This update also introduces new runtime dependencies, specifically huggingface\_hub (\>=0.17.0) and safetensors (\>=0.2), while retaining pyyaml and numpy, and separates development tools like pytest into a dedicated requirements-dev.txt file.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 62.
Lenses
- Code Health 60
- Architecture 84
- Maturity 51
- Readiness 82
- Security 94
Changes since last survey
- 300 commits — 210 feature/other, 90 fixes
By area
- timm/models — 83 commits
- (root) — 41 commits
- (repo) — 26 commits
- timm/optim — 24 commits
- .github/workflows — 17 commits
- tests/test_models.py — 14 commits
- timm/data — 13 commits
- tests/test_optim.py — 12 commits
- timm/layers — 12 commits
- hfdocs/source — 9 commits
- tests/test_data.py — 9 commits
- timm/version.py — 8 commits
- tests/test_layers.py — 5 commits
- timm/task — 5 commits
- timm/scheduler — 3 commits
- convert/convert_lcnetv2_paddle.py — 2 commits
- tests/test_layers_pool.py — 2 commits
- tests/test_layers_pos_embed.py — 2 commits
- tests/test_utils.py — 2 commits
- timm/loss — 2 commits
Notable commits
- fix: A few more optimizers followup fixes
- fix: Add comments for DinoV3 re global pool (class token). Fix #2681
- fix: Address a few pickle security concerns. Fix CVE https://github.com/huggingface/pytorch-image-models/security/advisories/[GHSA redacted]
- fix: Address onnx export API compat issues across torch versions. Fix Gemma4 & pos_embed export concerns. Broader scope than #2815
- fix: Attempt to fix false positive trufflehog
- fix: Change pos_embed_interp_mode default to 'bilinear' for naflex siglip configs only. Fix #2542
- fix: Drop FX tests for PyTorch 1.13 due to issues that are fixed in newer PT
- fix: Drop class map encoding test, monkeypatching open() in the module namespace is too hacky for a two line fix
- fix: Fix #2644 with full import path
- fix: Fix #2653, no models with weights impacted so just a clean fix, remove buffer as benchmarks w/ pt 2.9 show no difference
- fix: Fix #2661 ... don't skip reset_parameters/init when meta device detected as it breaks use of accelerate and similar dispatch override context managers
- fix: Fix #2781, CUDA stream allocation
- fix: Fix #2821 grad accum remainder bug without args. use
- fix: Fix AdaMuon LR scale for conv weights
- fix: Fix AdafactorBigVision dropping the factored row normalization for tall matrices
- fix: Fix AttributeError in auto-augment factories when hparams is None
- fix: Fix AugMix mixing buffer shape for non-square and single-band images
- fix: Fix CI failures for reset_classifier() changes
- fix: Fix CLS and Reg tokens usage when pos_embed is disabled
- fix: Fix CutMix minmax border sampling (#2739)
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
huggingface/pytorch-image-models was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 11 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit e84b179c5cddeb039736556b046614030061a9ee — the exact code this score is about.
- Scored under rubric-2026.10.5 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-fe8540b5da9b.