Metadata-Version: 2.4
Name: minitrain
Version: 0.1.1
Summary: Mini-models. Mini-data. Uni-recipe.
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib
Requires-Dist: numpy
Requires-Dist: PyYAML
Requires-Dist: torch>=2.5
Requires-Dist: tqdm
Provides-Extra: fid
Requires-Dist: torchmetrics>=1.9; extra == "fid"
Requires-Dist: torch-fidelity>=0.3; extra == "fid"
Dynamic: license-file

# minitrain

Mini-models. Mini-data. Uni-recipe.

Run small-scale machine learning experiments from YAML or JSON recipes.

## Quickstart

Use Python 3.10 or newer. Install from the checkout with
`python -m pip install .`, or use `pip install minitrain` once released on PyPI.

```bash
minitrain classification/cifar10-resnet20
minitrain path/to/experiment.yaml
```

Missing data files are downloaded automatically. Use `minitrain --help` to
list the bundled presets. During training, one terminal progress bar shows
the elapsed time, estimated time left, epoch, optimizer step, training loss,
and latest evaluation loss.

For GPU training, install a [PyTorch build](https://pytorch.org/get-started/previous-versions/)
that supports your GPU. V100 needs a build with Volta kernels, such as a
compatible CUDA 12.6 wheel.

## Train from Python

```python
import minitrain

recipe = minitrain.load_recipe("experiment.yaml")
trainer = minitrain.Trainer(**recipe)
run = trainer.train(train_dataset, model, validation_dataset=validation_dataset)
scores = trainer.evaluate(test_dataset, model)
```

Pass your own PyTorch model and datasets or DataLoaders. For a quick run,
use `minitrain.Trainer(task="classification", epochs=2, batch_size=32)`.
See the [Python recipe guide](src/minitrain/train/recipes/README.md#python-api)
for inputs, output paths, and DDP.

## Inference

```python
import minitrain

model = minitrain.load_model("outputs/cifar10/last.ckpt")
```

Built-in models load by checkpoint alone, in evaluation mode on CPU. The loader
prefers EMA weights when available. Use `device="cuda"` for GPU inference,
`use_ema=False` for regular weights, or `model=YourModel(...)` for a custom
architecture or older checkpoint. Apply the recipe’s evaluation preprocessing
to classifier inputs.

- [Recipe options, outputs, and resume](src/minitrain/train/recipes/README.md)
- [Model options and diffusion sampling](src/minitrain/models/README.md)

For development, run `python -m pip install -e .` and
`python -m unittest discover -v`.
