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

Uploaded Python 3

File details

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

File metadata

  • Download URL: matrice_models-0.0.3.tar.gz
  • Upload date:
  • Size: 103.3 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.3.tar.gz
Algorithm Hash digest
SHA256 8d47e9bb047491505de257eb73bdc278bf1ad18a1e4930bd45d5c15edd1ca401
MD5 536ca420f867f2986632b9697bc769e3
BLAKE2b-256 5563b2f9607c79f564d9a5e6a940c8fd847c0be87a8b127c2513329c0ca0cb63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: matrice_models-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 93add0174e50dd736850d5cd74833d88a047866b6e680553c1a69e57aaea3678
MD5 e1acbef075c1bd5a0e0f5522c9fa9066
BLAKE2b-256 053605e768ca05b95fa8adc51c9327bfc881aa16e2a251d2de8c67b78d5ce1b0

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