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.2.tar.gz (103.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.2-py3-none-any.whl (158.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: matrice_models-0.0.2.tar.gz
  • Upload date:
  • Size: 103.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.2.tar.gz
Algorithm Hash digest
SHA256 10d2c35dcd1fd4dea4cd0e20e98427783fee4d413f23e6229a8cba143cf5db9e
MD5 8aabf501c5d9e0892441d7d555f18bb3
BLAKE2b-256 b5b3f6872b9d3918fa925edcaf87fb41606033fb5d14d546bfde7f771bbb339b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: matrice_models-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 158.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4ac70461e1fad96b90d4b194d110ce7273bfce71117566751ec145914a68ed8c
MD5 5b95cb4d66cf024159d76719b935cf5d
BLAKE2b-256 7ab93b499d353c7b8e6a21f82fe210d2f3669bf7bbd4a62c44932de95155c3bc

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