Metadata-Version: 2.4
Name: autotimm
Version: 0.7.34
Summary: Automated deep learning for computer vision — train image classification, object detection, and segmentation models with 1000+ backbones in minimal code
Author: Krishnatheja Vanka
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Project-URL: Homepage, https://theja-vanka.github.io/AutoTimm
Project-URL: Documentation, https://theja-vanka.github.io/AutoTimm
Project-URL: Repository, https://github.com/theja-vanka/AutoTimm
Project-URL: Issues, https://github.com/theja-vanka/AutoTimm/issues
Project-URL: Changelog, https://github.com/theja-vanka/AutoTimm/releases
Keywords: deep-learning,computer-vision,pytorch,timm,image-classification,object-detection,semantic-segmentation,instance-segmentation,transfer-learning,vision-transformer,resnet,efficientnet,yolox,pytorch-lightning,automl,huggingface,torchmetrics,model-training,model-deployment,onnx-export
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.0
Requires-Dist: torchvision>=0.15
Requires-Dist: timm>=1.0
Requires-Dist: pytorch-lightning>=2.0
Requires-Dist: torchmetrics>=1.0
Requires-Dist: numpy>=1.23
Requires-Dist: opencv-python-headless>=4.8
Requires-Dist: huggingface_hub>=0.20
Requires-Dist: watermark>=2.3
Requires-Dist: loguru>=0.7
Requires-Dist: albumentations>=1.3
Requires-Dist: matplotlib>=3.7
Requires-Dist: transformers>=4.30
Requires-Dist: jsonargparse[signatures]>=4.27
Requires-Dist: plotly>=5.0
Provides-Extra: tensorboard
Requires-Dist: tensorboard>=2.14; extra == "tensorboard"
Provides-Extra: mlflow
Requires-Dist: mlflow>=2.0; extra == "mlflow"
Provides-Extra: wandb
Requires-Dist: wandb>=0.15; extra == "wandb"
Provides-Extra: onnx
Requires-Dist: onnx>=1.14; extra == "onnx"
Requires-Dist: onnxruntime>=1.16; extra == "onnx"
Requires-Dist: onnxscript>=0.6; extra == "onnx"
Provides-Extra: coco
Requires-Dist: pycocotools>=2.0; extra == "coco"
Provides-Extra: all
Requires-Dist: tensorboard>=2.14; extra == "all"
Requires-Dist: mlflow>=2.0; extra == "all"
Requires-Dist: wandb>=0.15; extra == "all"
Requires-Dist: albumentations>=1.3; extra == "all"
Requires-Dist: opencv-python-headless>=4.8; extra == "all"
Requires-Dist: pycocotools>=2.0; extra == "all"
Requires-Dist: onnx>=1.14; extra == "all"
Requires-Dist: onnxruntime>=1.16; extra == "all"
Requires-Dist: onnxscript>=0.6; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: pycocotools>=2.0; extra == "dev"
Requires-Dist: tensorboard>=2.14; extra == "dev"
Requires-Dist: mlflow>=2.0; extra == "dev"
Requires-Dist: wandb>=0.15; extra == "dev"
Requires-Dist: albumentations>=1.3; extra == "dev"
Requires-Dist: opencv-python-headless>=4.8; extra == "dev"
Requires-Dist: plotly>=5.0; extra == "dev"
Requires-Dist: transformers>=4.30; extra == "dev"
Requires-Dist: onnx>=1.14; extra == "dev"
Requires-Dist: onnxruntime>=1.16; extra == "dev"
Requires-Dist: onnxscript>=0.6; extra == "dev"
Provides-Extra: docs
Requires-Dist: zensical; extra == "docs"
Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
Dynamic: license-file

<div align="center">

<br>

<img src="https://drive.google.com/uc?export=view&id=1IO383lY97phOg9qDVARnG9HQ2McOF7Zj" width="400" alt="AutoTimm logo" />

<br>

### Train state-of-the-art vision models with minimal code.

Production-ready computer vision framework powered by
[timm](https://github.com/huggingface/pytorch-image-models) and [PyTorch Lightning](https://github.com/Lightning-AI/pytorch-lightning).

<br>

[![PyPI](https://img.shields.io/pypi/v/autotimm?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/autotimm/)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![GitHub Stars](https://img.shields.io/github/stars/theja-vanka/AutoTimm?style=flat-square&color=gold)](../../stargazers)
[![GitHub Issues](https://img.shields.io/github/issues/theja-vanka/AutoTimm?style=flat-square)](../../issues)
[![GitHub PRs](https://img.shields.io/github/issues-pr/theja-vanka/AutoTimm?style=flat-square)](../../pulls)
[![Last Commit](https://img.shields.io/github/last-commit/theja-vanka/AutoTimm?style=flat-square)](../../commits)

<br>

![Python](https://img.shields.io/badge/Python-3.10_|_3.11_|_3.12_|_3.13-3776AB?style=for-the-badge&logo=python&logoColor=white)
![PyTorch](https://img.shields.io/badge/PyTorch-2.0+-EE4C2C?style=for-the-badge&logo=pytorch&logoColor=white)
![Lightning](https://img.shields.io/badge/Lightning-2.0+-792EE5?style=for-the-badge&logo=pytorchlightning&logoColor=white)

<br>

[![timm](https://img.shields.io/badge/timm-1000+_backbones-24C8D8?style=flat-square)](https://github.com/huggingface/pytorch-image-models)
[![HuggingFace](https://img.shields.io/badge/HuggingFace-Hub_Integration-FFD21E?style=flat-square&logo=huggingface&logoColor=black)](https://huggingface.co)
[![torchmetrics](https://img.shields.io/badge/torchmetrics-Metrics-792EE5?style=flat-square)](https://github.com/Lightning-AI/torchmetrics)

<br>

[Overview](#overview) · [Features](#features) · [Quick Start](#quick-start) · [Tasks](#task-examples) · [Architecture](#architecture) · [Docs](#documentation--examples) · [Contributing](#contributing) · [License](#license)

<br>

</div>

<!-- ------------------------------------------------------------------ -->

## Overview

**AutoTimm** is a **production-ready** computer vision framework that combines [timm](https://github.com/huggingface/pytorch-image-models) (1000+ pretrained models) with [PyTorch Lightning](https://github.com/Lightning-AI/pytorch-lightning). Train image classifiers, object detectors, and segmentation models with any timm backbone using a simple, intuitive API.

Whether you're training an image classifier, an object detector, or a segmentation model, AutoTimm handles:

- **Automated model training** with auto-tuning of learning rate and batch size
- **4 vision tasks** — classification (single & multi-label), object detection, semantic & instance segmentation
- **1000+ backbones** — ResNet, EfficientNet, ViT, ConvNeXt, Swin, and more via timm + HuggingFace Hub
- **Model interpretation** — GradCAM, Integrated Gradients, Attention Rollout, and more
- **Production export** — TorchScript and ONNX for deployment anywhere

> **From prototype to production in minutes, not hours.**

---

## How It Compares

| | Manual PyTorch | AutoTimm |
| :--- | :---: | :---: |
| **Boilerplate** | Hundreds of lines per task | 5–10 lines for any task |
| **Backbone variety** | Wire up manually | 1000+ backbones, swap with one arg |
| **Auto-tuning** | Implement yourself | LR + batch size finding built-in |
| **Experiment tracking** | External tooling needed | Multi-logger (TensorBoard, MLflow, W&B, CSV) |
| **Reproducibility** | Manual seed management | Opt-in deterministic mode (`seed=42`) |
| **Model export** | Custom export scripts | One-line TorchScript & ONNX |
| **Interpretation** | Separate libraries | 6 methods + metrics built-in |

---

## Features

<table>
<tr>
<td width="50%" valign="top">

### Vision Tasks

- **Image Classification** — single-label and multi-label with any timm backbone
- **Object Detection** — FCOS and YOLOX architectures (official + custom)
- **Semantic Segmentation** — DeepLabV3+ and FCN with combined losses
- **Instance Segmentation** — FCOS + Mask R-CNN style mask head

</td>
<td width="50%" valign="top">

### Smart Training

- **Auto-tuning** — automatic LR and batch size discovery
- **torch.compile** — PyTorch 2.0+ optimization enabled by default
- **Reproducibility** — deterministic seeding across Python, NumPy, PyTorch
- **Mixed precision** — 16-bit and bf16 training out of the box
- **Multi-GPU** — distributed training with zero config

</td>
</tr>
<tr>
<td width="50%" valign="top">

### Interpretation & Export

- **6 explanation methods** — GradCAM, GradCAM++, Integrated Gradients, SmoothGrad, Attention Rollout, Attention Flow
- **6 quality metrics** — faithfulness, sensitivity, localization, sanity checks
- **Interactive visualizations** — Plotly-powered HTML reports
- **Model export** — TorchScript (.pt) and ONNX (.onnx) for production

</td>
<td width="50%" valign="top">

### Data & Integration

- **Flexible data loading** — folder structure, COCO JSON, CSV, HuggingFace datasets
- **Smart transforms** — AI-powered backend selection, unified TransformConfig
- **HuggingFace Hub** — load models with `hf-hub:` prefix
- **Multi-logger** — TensorBoard, MLflow, W&B, CSV simultaneously
- **CLI** — YAML-driven training from the command line

</td>
</tr>
</table>

<table>
<tr>
<td width="100%" align="center">

### Who Is It For?

**Researchers** needing reproducible experiments · **Engineers** building production ML systems ·
**Students** learning computer vision · **Startups** rapidly prototyping vision applications

</td>
</tr>
</table>

---

## Quick Start

### Installation

```bash
pip install autotimm
```

**Everything included:** PyTorch, timm, PyTorch Lightning, torchmetrics, albumentations, and more.

<details>
<summary><b>Optional extras</b></summary>

```bash
pip install autotimm[tensorboard]  # TensorBoard
pip install autotimm[wandb]        # Weights & Biases
pip install autotimm[mlflow]       # MLflow
pip install autotimm[onnx]         # ONNX export (onnx + onnxruntime + onnxscript)
pip install autotimm[all]          # Everything
```

</details>

### Your First Model

```python
import autotimm as at  # recommended alias
from autotimm import AutoTrainer, ImageClassifier, ImageDataModule, MetricConfig

# Data
data = ImageDataModule(
    data_dir="./data",
    dataset_name="CIFAR10",
    image_size=224,
    batch_size=64,
)

# Metrics
metrics = [
    MetricConfig(
        name="accuracy",
        backend="torchmetrics",
        metric_class="Accuracy",
        params={"task": "multiclass"},
        stages=["train", "val", "test"],
        prog_bar=True,
    )
]

# Model — try efficientnet_b0, vit_base_patch16_224, hf-hub:timm/resnet50.a1_in1k, etc.
model = ImageClassifier(backbone="resnet18", num_classes=10, metrics=metrics, lr=1e-3)

# Train with auto-tuning (finds optimal LR and batch size automatically)
trainer = AutoTrainer(max_epochs=10)
trainer.fit(model, datamodule=data)
```

> **Auto-tuning is enabled by default.** Disable with `tuner_config=False` for manual control.

### Command-Line Interface

Train from YAML configs — no Python scripts needed:

```bash
autotimm fit --config config.yaml
autotimm test --config config.yaml --ckpt_path best.ckpt
```

```yaml
model:
  class_path: autotimm.ImageClassifier
  init_args:
    backbone: resnet18
    num_classes: 10

data:
  class_path: autotimm.ImageDataModule
  init_args:
    dataset_name: CIFAR10
    data_dir: ./data
    batch_size: 32
    image_size: 224

trainer:
  max_epochs: 10
  accelerator: auto
```

---

## Task Examples

### Image Classification

```python
from autotimm import ImageClassifier

model = ImageClassifier(
    backbone="efficientnet_b0",  # or "hf-hub:timm/resnet50.a1_in1k"
    num_classes=10,
    metrics=metrics,
)

trainer = AutoTrainer(max_epochs=10)
trainer.fit(model, datamodule=data)
```

### Object Detection with YOLOX

```python
from autotimm import YOLOXDetector, DetectionDataModule

model = YOLOXDetector(
    model_name="yolox-s",  # nano, tiny, s, m, l, x
    num_classes=80,
    lr=0.01,
    optimizer="sgd",
    scheduler="yolox",
    total_epochs=300,
)

trainer = AutoTrainer(max_epochs=300, precision="16-mixed")
trainer.fit(model, datamodule=DetectionDataModule(data_dir="./coco", image_size=640))
```

### Semantic Segmentation

```python
from autotimm import SemanticSegmentor, SegmentationDataModule

model = SemanticSegmentor(
    backbone="resnet50",
    num_classes=19,
    head_type="deeplabv3plus",
    loss_type="combined",  # CE + Dice for better boundaries
)

data = SegmentationDataModule(data_dir="./cityscapes", format="cityscapes", image_size=512)

trainer = AutoTrainer(max_epochs=100)
trainer.fit(model, datamodule=data)
```

### Instance Segmentation

```python
from autotimm import InstanceSegmentor, InstanceSegmentationDataModule

model = InstanceSegmentor(backbone="resnet50", num_classes=80, mask_loss_weight=1.0)

trainer = AutoTrainer(max_epochs=100)
trainer.fit(model, datamodule=InstanceSegmentationDataModule(data_dir="./coco"))
```

### Multi-Label Classification

```python
from autotimm import ImageClassifier, MultiLabelImageDataModule, MetricConfig

data = MultiLabelImageDataModule(
    train_csv="train.csv", image_dir="./images", val_csv="val.csv",
    image_size=224, batch_size=32,
)
data.setup("fit")

model = ImageClassifier(
    backbone="resnet50",
    num_classes=data.num_labels,
    multi_label=True,
    threshold=0.5,
    metrics=[MetricConfig(
        name="accuracy", backend="torchmetrics", metric_class="MultilabelAccuracy",
        params={"num_labels": data.num_labels}, stages=["train", "val"], prog_bar=True,
    )],
)

trainer = AutoTrainer(max_epochs=10)
trainer.fit(model, datamodule=data)
```

---

## Model Interpretation

```python
from autotimm.interpretation import (
    GradCAM, GradCAMPlusPlus, IntegratedGradients,
    SmoothGrad, AttentionRollout, AttentionFlow,
    ExplanationMetrics, InteractiveVisualizer,
)

# Explain a prediction
explainer = GradCAM(model)
heatmap = explainer.explain(image, target_class=5)
explainer.visualize(image, heatmap, save_path="gradcam.png")

# Quantitative evaluation
metrics = ExplanationMetrics(model, explainer)
deletion = metrics.deletion(image, target_class=5, steps=50)
insertion = metrics.insertion(image, target_class=5, steps=50)

# Interactive comparison
viz = InteractiveVisualizer(model)
viz.compare_methods(image, {
    'GradCAM': GradCAM(model),
    'IntegratedGradients': IntegratedGradients(model),
}, save_path="comparison.html")
```

---

## Model Export

```python
from autotimm import ImageClassifier, export_to_torchscript, export_to_onnx
import torch

model = ImageClassifier.load_from_checkpoint("model.ckpt")
example_input = torch.randn(1, 3, 224, 224)

# TorchScript
export_to_torchscript(model, "model.pt", example_input=example_input)

# ONNX
export_to_onnx(model, "model.onnx", example_input=example_input)
```

| Format | Use Case | Runtimes |
| :--- | :--- | :--- |
| **TorchScript** | PyTorch ecosystem, C++, mobile | LibTorch, PyTorch Mobile |
| **ONNX** | Cross-platform, hardware-optimized | ONNX Runtime, TensorRT, OpenVINO, CoreML |

---

## Loading from Checkpoints

All task classes inherit PyTorch Lightning's `load_from_checkpoint`. Most parameters are auto-restored from saved hyperparameters — only **ignored** parameters (non-serializable objects) need to be re-supplied.

```python
import autotimm as at

# Basic — works for all tasks (ignored params default to None)
model = at.ImageClassifier.load_from_checkpoint("checkpoint.ckpt")

# For inference on CPU
model = at.ImageClassifier.load_from_checkpoint("checkpoint.ckpt", map_location="cpu")
model.eval()

# Override any saved hyperparameter
model = at.ImageClassifier.load_from_checkpoint("checkpoint.ckpt", num_classes=20)

# Disable torch.compile for faster loading (recommended for inference/export)
model = at.ImageClassifier.load_from_checkpoint("checkpoint.ckpt", compile_model=False)
```

<details>
<summary><b>Ignored parameters by task</b> (not saved in checkpoint, re-supply if needed)</summary>
<br>

| Task | Ignored Parameters |
| :--- | :--- |
| **ImageClassifier** | `metrics`, `logging_config`, `transform_config`, `loss_fn` |
| **ObjectDetector** | `metrics`, `logging_config`, `transform_config`, `cls_loss_fn`, `reg_loss_fn` |
| **SemanticSegmentor** | `metrics`, `logging_config`, `transform_config`, `class_weights`, `loss_fn` |
| **InstanceSegmentor** | `metrics`, `logging_config`, `transform_config`, `cls_loss_fn`, `reg_loss_fn`, `mask_loss_fn` |
| **YOLOXDetector** | `metrics`, `logging_config`, `transform_config` |

All ignored parameters default to `None`, so `load_from_checkpoint` works without passing them. Re-supply only if you need custom losses or metrics for continued training.

```python
# Resume training with custom metrics and loss
model = at.ObjectDetector.load_from_checkpoint(
    "checkpoint.ckpt",
    metrics=[at.MetricConfig(name="map", backend="torchmetrics", metric_class="MeanAveragePrecision")],
    cls_loss_fn="focal",
    reg_loss_fn="giou",
)
```

</details>

> **Note:** `backbone`, `num_classes`, and all other constructor arguments are saved as hyperparameters and restored automatically — no need to re-specify them.

---

## Architecture

```mermaid
graph TD
    subgraph API["Public API · autotimm"]
        Init["__init__.py"] --> Tasks
        Init --> Data
        Init --> Interpret
        Init --> Export
    end

    subgraph Core["Core · autotimm.core"]
        Backbone["backbone.py · 1000+ timm models"]
        Metrics["metrics.py · torchmetrics"]
        Loggers["loggers.py · TB / MLflow / W&B / CSV"]
        Utils["utils.py · seeding, optimizers"]
        Logging["logging.py · loguru"]
    end

    subgraph Tasks["Tasks · autotimm.tasks"]
        Cls["ImageClassifier"]
        Det["ObjectDetector"]
        Seg["SemanticSegmentor"]
        Inst["InstanceSegmentor"]
        YOLOX["YOLOXDetector"]
    end

    subgraph Data["Data · autotimm.data"]
        DM["DataModules"] --> DS["Datasets"]
        DM --> TX["Transforms"]
    end

    subgraph Interpret["Interpretation · autotimm.interpretation"]
        Methods["6 Methods"] --> Viz["Visualization"]
        Methods --> QM["Quality Metrics"]
    end

    subgraph Export["Export · autotimm.export"]
        JIT["TorchScript"]
        ONNX["ONNX"]
    end

    Tasks --> Core
    Data --> Core
```

<details>
<summary><b>Package Structure</b></summary>
<br>

| Module | Purpose |
| :--- | :--- |
| `autotimm` | Public API — all exports via `__init__.py` |
| `autotimm.core` | Backbone factory, metrics, loggers, logging, utilities |
| `autotimm.tasks` | Task models (LightningModule subclasses) |
| `autotimm.data` | DataModules, datasets, and transform pipelines |
| `autotimm.heads` | Task-specific prediction heads (Classification, Detection, FPN, DeepLabV3+, Mask, YOLOX) |
| `autotimm.losses` | Loss functions and registry (Focal, GIoU, Dice, Tversky, etc.) |
| `autotimm.models` | YOLOX-specific components (CSPDarknet, PAFPN) |
| `autotimm.interpretation` | Explanation methods, metrics, visualization, callbacks |
| `autotimm.export` | TorchScript and ONNX export utilities + CLIs |
| `autotimm.training` | AutoTrainer wrapper with auto-tuning |
| `autotimm.cli` | Command-line interface (fit/test/validate + interpretation CLI) |
| `autotimm.callbacks` | JSON progress callback for frontend integration |

</details>

---

## Documentation & Examples

| Section | Description |
| :--- | :--- |
| [Quick Start](https://theja-vanka.github.io/AutoTimm/getting-started/quickstart/) | Get up and running in 5 minutes |
| [User Guide](https://theja-vanka.github.io/AutoTimm/user-guide/data-loading/) | In-depth guides for all features |
| [Interpretation Guide](https://theja-vanka.github.io/AutoTimm/user-guide/interpretation/) | Model explainability and visualization |
| [YOLOX Guide](https://theja-vanka.github.io/AutoTimm/user-guide/models/yolox-detector/) | Complete YOLOX implementation guide |
| [CLI Guide](https://theja-vanka.github.io/AutoTimm/user-guide/training/cli/) | Train from YAML configs on the command line |
| [API Reference](https://theja-vanka.github.io/AutoTimm/api/) | Complete API documentation |
| [Examples](https://theja-vanka.github.io/AutoTimm/examples/) | 50+ runnable code examples |

<details>
<summary><b>Ready-to-Run Examples</b></summary>
<br>

**Getting Started** — [classify_cifar10.py](examples/getting_started/classify_cifar10.py) · [classify_custom_folder.py](examples/getting_started/classify_custom_folder.py) · [vit_finetuning.py](examples/getting_started/vit_finetuning.py)

**Computer Vision** — [yolox_official.py](examples/computer_vision/yolox_official.py) · [object_detection_yolox.py](examples/computer_vision/object_detection_yolox.py) · [semantic_segmentation.py](examples/computer_vision/semantic_segmentation.py) · [instance_segmentation.py](examples/computer_vision/instance_segmentation.py)

**HuggingFace Hub** — [huggingface_hub_models.py](examples/huggingface/huggingface_hub_models.py) · [hf_interpretation.py](examples/huggingface/hf_interpretation.py) · [hf_transfer_learning.py](examples/huggingface/hf_transfer_learning.py) · [hf_ensemble.py](examples/huggingface/hf_ensemble.py) · [hf_deployment.py](examples/huggingface/hf_deployment.py)

**Data & Training** — [csv_classification.py](examples/data_training/csv_classification.py) · [csv_detection.py](examples/data_training/csv_detection.py) · [multilabel_classification.py](examples/data_training/multilabel_classification.py) · [multi_gpu_training.py](examples/data_training/multi_gpu_training.py)

**Interpretation** — [interpretation_demo.py](examples/interpretation/interpretation_demo.py) · [interpretation_metrics_demo.py](examples/interpretation/interpretation_metrics_demo.py) · [interactive_visualization_demo.py](examples/interpretation/interactive_visualization_demo.py)

**CLI Configs** — [classification.yaml](examples/cli/classification.yaml) · [detection.yaml](examples/cli/detection.yaml) · [segmentation.yaml](examples/cli/segmentation.yaml)

[Browse all examples](https://theja-vanka.github.io/AutoTimm/examples/)

</details>

---

## Testing

```bash
# Run all tests
pytest tests/ -v

# Specific modules
pytest tests/test_classification.py
pytest tests/test_yolox.py
pytest tests/test_interpretation.py

# With coverage
pytest tests/ --cov=autotimm --cov-report=html
```

---

## Contributing

Contributions, issues, and feature requests are welcome! See the [issues page](../../issues) to get started.

1. **Fork** the repository
2. **Create** a feature branch — `git checkout -b feat/your-feature`
3. **Commit** your changes — `git commit -m 'feat: add your feature'`
4. **Push** to the branch — `git push origin feat/your-feature`
5. **Open** a Pull Request

```bash
git clone https://github.com/theja-vanka/AutoTimm.git && cd AutoTimm
pip install -e ".[dev,all]"
pytest tests/ -v
```

---

## Citation

```bibtex
@software{autotimm,
  author = {Krishnatheja Vanka},
  title = {AutoTimm: Automatic PyTorch Image Models},
  url = {https://github.com/theja-vanka/AutoTimm},
  year = {2026},
}
```

---

## License

Distributed under the **Apache License 2.0**. See [`LICENSE`](LICENSE) for details.

---

<div align="center">
<br>

**Built with care by [Krishnatheja Vanka](https://github.com/theja-vanka)**

If AutoTimm saves you time, consider giving it a &#11088;

<br>

<a href="https://www.buymeacoffee.com/theja.vanka" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

<br>
</div>
