Shared model training, evaluation, deployment, and prediction utilities for Matrice.ai BYOM pipelines
Project description
matrice_models
Shared model training, evaluation, deployment, and prediction utilities for Matrice.ai BYOM (Bring Your Own Model) pipelines.
Installation
Install from PyPI:
pip install matrice_models
Install from Test PyPI (for pre-release versions):
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ matrice_models
Install from source:
git clone https://github.com/matrice-ai/py_models.git
cd py_models
pip install -e .
Quick Start
from matrice_models.config import ModelInfo, TrainConfig
from matrice_models.training import LoopTrainer, DelegatedTrainer
Package Structure
| Module | Description |
|---|---|
matrice_models.config |
Pydantic-based configuration schemas (ModelInfo, TrainConfig, EvalConfig, ExportConfig, DeployConfig) |
matrice_models.training |
Trainer hierarchy (LoopTrainer, DelegatedTrainer), callbacks, checkpoints, early stopping, optimizers, schedulers, device utilities |
matrice_models.eval |
Evaluation orchestration, inference runners, metric formatting, model loader registry |
matrice_models.deploy |
Deployment server, framework routing, runtime resolution |
matrice_models.predict |
Prediction pipeline — model loading strategies, pre/post-processing, TensorRT adapters |
matrice_models.metrics |
Classification and detection metrics (precision, recall, F1, mAP, IoU) |
Training
The training module provides two trainer base classes:
LoopTrainer— for custom epoch-based training loops where you control iteration logic.DelegatedTrainer— for framework-owned loops (e.g., HuggingFace Trainer, Ultralytics).
Task-specific models override these hooks: _get_dataloader, _init_model, _compute_loss, _format_metrics, _get_augmentation.
Development
Prerequisites
- Python 3.10, 3.11, or 3.12
- Ruff for linting and formatting
Setup
git clone https://github.com/matrice-ai/py_models.git
cd py_models
pip install -e ".[dev]"
Linting & Formatting
ruff check src/
ruff format src/
Configuration lives in ruff.toml (line length 120, Google-style docstrings, Python 3.10+ target).
Running Tests
pytest tests/
Build Modes
The package supports two build modes controlled via the ENABLE_MYPYC environment variable or build-config.json:
| Mode | Command | Output |
|---|---|---|
| Pure Python (default) | python -m build |
Universal py3-none-any wheel |
| Mypyc Compiled | ENABLE_MYPYC=true python -m build |
Platform-specific compiled wheels |
Mypyc compilation produces native extensions for faster execution but requires building per-platform wheels.
CI / CD
The GitHub Actions workflow (.github/workflows/publish-to-pypi.yml) automates building and publishing:
- Config — reads versions and platform matrix from
build-config.json - Build — creates pure Python or mypyc-compiled wheels depending on config
- Publish — uploads to Test PyPI (dev), Test PyPI, and PyPI
Versioning is managed in build-config.json:
License
Apache License 2.0 — see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matrice_models-0.0.1.tar.gz.
File metadata
- Download URL: matrice_models-0.0.1.tar.gz
- Upload date:
- Size: 86.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb2f0041c6b7b2dca5024e050a9526e6c69dcf382ca510819dd018b39b780d20
|
|
| MD5 |
44ce80a6a8b914dfc7b8c213cd74f65a
|
|
| BLAKE2b-256 |
15ecf600c99e9ef584fb4eb2348e126d7cbccd96afcaf0ddd0b2d0a47e6a7a55
|
File details
Details for the file matrice_models-0.0.1-py3-none-any.whl.
File metadata
- Download URL: matrice_models-0.0.1-py3-none-any.whl
- Upload date:
- Size: 129.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0984e9b44fecae99b3c86f11f2a3816e1e716f43133cebe45a794e646b7a631b
|
|
| MD5 |
9dff2b296c5707c80e885acf6c691fcb
|
|
| BLAKE2b-256 |
e6b090df52830aec0b927c9a0dc1c92de3c92e07255e941d9319eb60995dfaed
|