Mini trainer
Mini trainer is an extensible PyTorch framework for training, evaluating and
exporting image classifiers. It supports flat labels and hierarchical class
structures on your own datasets; biological taxonomy is one application.
The training framework is published on PyPI as mt-trainer.
Python imports remain mini_trainer.
Features and guides
- Flat and hierarchical classification: train classifiers and predict at multiple levels of a label hierarchy. Start with the MNIST and hierarchical Blair examples.
- Choice of image backbone: use Torchvision models, optional timm, Transformers or BioCLIP backends, and customize training components through builders.
- Training and data: image folders or supported metadata Parquet inputs, mixed precision, distributed training, checkpoint loading and configurable augmentation, optimizers and schedules. See the training API, distributed setup and runtime contracts and limitations.
- Evaluation and inspection: classification metrics, confusion matrices, hierarchy visualizations and optional Weights & Biases logging. The benchmark guide explains maintained evaluation coverage.
- Deployment: native PyTorch inference and optional ONNX export with class mappings and preprocessing metadata. See the separate quantization guide for opt-in x86 INT8 support and its limits.
These guides and examples serve as the documentation entry points while a standalone documentation site is pending.
Released models
Model packages contain a particular trained model and its integration interface; they are versioned separately from the general training framework. Additional models can cover other datasets, label sets and application domains.
| Model | Scope | Use it |
|---|---|---|
| Nemo (MAMBO_v3) | Adult moths and butterflies (Lepidoptera); species, genus and family predictions | PyPI package · Hugging Face model card and weights · Interactive demo |
The Nemo deployment guide covers its Python API and CLI, PyTorch/ONNX runtimes, geographic presets, custom class lists, embeddings, optional test-time augmentation and measured quality/speed.
ONNX/CPU integration needs neither the training package nor a GPU. Native
PyTorch inference is available independently through mini_trainer.deploy.
Nemo weights are CC BY-NC-SA 4.0 (non-commercial, share-alike); framework and adapter code are MIT.
Find your workflow
| Task | Start here |
|---|---|
| Integrate the Nemo release | Deployment API and CLI |
| Prepare data or adapt an example | Examples |
| Change the trainer or run checks | Development guide, test map |
| Compare models, backends or training settings | Benchmarks |
| Run on UCloud or reproduce research | UCloud, research experiments |
| Choose the next development task | Roadmap |
Installation
Use uv for environment and package management. Choose a published package or a source checkout.
PyPI
The published distribution is mt-trainer; Python imports remain mini_trainer.
The similarly named mini-trainer / mini_trainer PyPI project is unrelated.
uv venv --python 3.12
source .venv/bin/activate
uv pip install "mt-trainer[recommended]" --torch-backend=auto
| Package choice | Includes |
|---|---|
mt-trainer |
Core training and inference |
mt-trainer[recommended] |
Core plus logging, visualization and optional utilities |
mt-trainer[all] |
Recommended extras plus notebooks, model backends and ONNX export |
Substitute the desired package in the install command. Standard pip install also
works; select its PyTorch CPU/CUDA installation separately for your environment.
Local installation
Choose one backend: cpu, cu126, cu130 or cu132. The example selects CUDA 13.0;
change TORCH_BACKEND to match your intended environment before synchronizing.
git clone https://github.com/asgersvenning/mini_trainer.git
cd mini_trainer
TORCH_BACKEND=cu130
uv sync --extra recommended --extra "$TORCH_BACKEND"
source .venv/bin/activate
Replace recommended with all for the additional backends/export tools above.
Activate the environment, use its executables directly, or use uv run --no-sync.
An implicit sync can replace the deliberately selected PyTorch backend. Select the
backend explicitly whenever installing or synchronizing dependencies.
Data loading on shared machines
Defaults use process CPU availability, affinity, visible cgroup quotas and Slurm
allocation limits. Shared resources may still need an explicit per-process budget.
Set --num_workers N for loading (0 runs in the main process), and
--cache-workers N for training-cache preparation. CUDA-cached datasets use zero
DataLoader workers. See automatic budgets
for caps and fallback behavior; cache readers and DataLoader workers are separate.
Weights & Biases Integration
mini_trainer supports logging your training runs, including metrics, confusion matrices, and the probabilistic dendrogram, directly to Weights & Biases.
To use this feature you must install mini_trainer with the recommended extras. See Installation for more information.
- Login to your wandb account:
wandb login - Train with the
--wandbflag: Simply append the--wandbflag to your training command.mt_train -i path/to/dataset --wandb
Acknowledgements
This repository draws inspiration from https://github.com/pytorch/vision/tree/main/references/classification.
Contribution
Keep required dependencies and configuration small, provide useful defaults, and keep architectures, losses, data formats and training components extensible. Third-party integrations should remain optional.
Feel free to contribute, but here are a few tips:
- Follow the installation guide to setup a proper dev environment.
- Run
bash dev/check.sh staticfor lint, formatting, and architecture checks. - Run
bash dev/check.sh testfor the test suite; see the development guide for focused checks and environment details. - Run
bash dev/check-wheel.shto validate a minimal wheel installation in a disposable CPU environment. - Please avoid adding new dependencies 🙂
Repository agents should start with AGENTS.md. Planned improvements and their acceptance criteria are tracked in the roadmap. Remaining quantization work has a focused target-qualification roadmap.
ONNX export
Export trained models with mt_export --weights weights.pt --output exported-model
after installing the export extra and the relevant model backend. The generic
exporter preserves evaluation outputs and verifies ONNX Runtime parity. See the
export guide for the Python API, preprocessing contract and coverage.
Continuous benchmarks
Follow the benchmark results and coverage and continuous run history. The suite progresses from an exact synthetic oracle to MNIST and hierarchical Blair, with separate CPU and GPU profiles, visible summaries, and retained reproduction artifacts.
For configured GPU runners, the opt-in TensorRT deployment workflow rebuilds engines on the target and reports paired quality, latency and memory.
Temporarily unsupported feature
EMA (--ema / ema=True) is currently nonfunctional: classifier caches populated
by evaluation can break later EMA updates. Leave it disabled. Enabling it emits a
runtime warning; its API and checkpoint compatibility are retained, and repair is
deferred. See known limitations.
INT8 quantization
An opt-in PTQ and QAT Python API targets native x86 INT8 inference. This is an initial backend increment; CPU float32 QAT, integer inference and ordinary AMP are distinct capabilities.
Opt-in CUDA INT8 training supports Linear weights, integer forward/backward products, checkpoint restoration and CUDA inference. See the validation audit for measured memory, speed and loading benefits, supported configurations and limitations. x86 PTQ/QAT inference is a separate backend.
Metadata
Release files for mt-trainer 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mt_trainer-0.3.1.tar.gz | 288.9 kB | Without provenance | Details for mt_trainer-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mt_trainer-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for mt_trainer-0.3.1-py3-none-any.whl |
Total release size: 616.2 kB
Release files / mt_trainer-0.3.1.tar.gz
| Download URL | mt_trainer-0.3.1.tar.gz |
|---|---|
| Size | 288.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4f0bb25ee23c6c3ea7821adaf83ba8733f471196ee010c6e65d279ec41277b2
|
|
BLAKE2b-256 checksum How to use checksums |
203836b57e44eae00ef9350629eb517ae602aa47fabdbdf88bd1069472a1d13c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / mt_trainer-0.3.1-py3-none-any.whl
| Download URL | mt_trainer-0.3.1-py3-none-any.whl |
|---|---|
| Size | 327.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a9be8938bb3fce1a4e8e16bf6463e7641a07cbb6d95b47f732bb2581bddbef8
|
|
BLAKE2b-256 checksum How to use checksums |
4d49f2e7b6ef947bdd422191c9c06260187161dae126b63e8d878e09c370a5f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for mt-trainer 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.