Skip to main content

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.

Python 3.10+ License: MIT

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:

  1. Config — reads versions and platform matrix from build-config.json
  2. Build — creates pure Python or mypyc-compiled wheels depending on config
  3. 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

matrice_models-0.0.4.tar.gz (104.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matrice_models-0.0.4-py3-none-any.whl (159.6 kB view details)

Uploaded Python 3

File details

Details for the file matrice_models-0.0.4.tar.gz.

File metadata

  • Download URL: matrice_models-0.0.4.tar.gz
  • Upload date:
  • Size: 104.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for matrice_models-0.0.4.tar.gz
Algorithm Hash digest
SHA256 614592024be76faecaf0559c8319a2db21f4e39a363243428ca4071aea21a302
MD5 7d88e3aa80a2044ee3f3be13b94d03f2
BLAKE2b-256 4756d0df38d58a9e026866d05b56ac50e832448832795dbc7354dd8c0e763110

See more details on using hashes here.

File details

Details for the file matrice_models-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: matrice_models-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 159.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for matrice_models-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6a8b5926319c09dbd515ee04ec30097bd378ef729f870002ebdcb7e579e1a41f
MD5 b4929a6deefffad2f6f526f95bc1b369
BLAKE2b-256 fbabc6592df908d978e27469daf6ec7089e20e37d19e0fa1ecffa09651f83754

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page