Skip to main content

A machine learning model-sharing specification based on STAC MLM and Safetensors.

Project description

MLSTAC logo

MLSTAC

Machine learning model sharing, built on the STAC MLM extension and Safetensors.

PyPI version Python versions Tests License Documentation


Overview

MLSTAC gives you a single, consistent way to publish and consume machine learning models. Each model is described by a STAC Item using the MLM extension, and its weights travel as Safetensors. From that metadata you can load a model from many backends (HTTP, local disk, S3, Google Cloud Storage), download it, inspect it, and turn it into a usable PyTorch model.

Status: experimental. The API may change between minor versions.

Installation

pip install mlstac

Quickstart

import mlstac

# Load only the metadata first (no weights are downloaded yet)
model = mlstac.load("https://example.com/my-model/mlm.json")

# Inspect what you have
print(model.get_model_summary())
model.print_schema()

# Download every file into a local folder; you get back a loader
# pointing at the local copy
local = model.download("./my-model")

# Build a usable model from the local files
net = local.compiled_model()

Loading from different sources

mlstac.load is the main entry point. It accepts a URL, a local path, or a list of .pt2 files for an ad-hoc ensemble.

# Remote metadata
mlstac.load("https://example.com/model/mlm.json")

# A local directory that contains an mlm.json
mlstac.load("./my-model")

# An ensemble built directly from .pt2 files
ensemble = mlstac.load(["model_a.pt2", "model_b.pt2"])
ensemble.is_ensemble  # True

Downloading

You can download from the loader instance, or call the module-level function directly.

# From an existing loader (reuses the source it was created from)
local = model.download("./my-model")

# Or as a one-shot call
local = mlstac.download("https://example.com/model/mlm.json", "./my-model")

Supported backends

Scheme Example
http / https / ftp https://example.com/model/mlm.json
local ./my-model or /abs/path/mlm.json
s3 s3://bucket/key/mlm.json (needs boto3)
gs gs://bucket/key/mlm.json (needs google-cloud-storage)

Documentation

Full docs live at tacofoundation.github.io/mlstac.

Development

# install with dev dependencies
poetry install --with dev

# run the test suite
poetry run pytest tests/ -v

License

See LICENSE.

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

mlstac-0.4.9.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

mlstac-0.4.9-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file mlstac-0.4.9.tar.gz.

File metadata

  • Download URL: mlstac-0.4.9.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Windows/11

File hashes

Hashes for mlstac-0.4.9.tar.gz
Algorithm Hash digest
SHA256 4f1fc327e703c63429d03846ed4cdd365708aec89aecfa0c24085e745b40e593
MD5 7580928d9a4c793a2d54f3e7e5c8c8d0
BLAKE2b-256 e97a6a27ea57039ed38187579b0c0ad676a4d8aae823eafb5e1381d5af9f152d

See more details on using hashes here.

File details

Details for the file mlstac-0.4.9-py3-none-any.whl.

File metadata

  • Download URL: mlstac-0.4.9-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Windows/11

File hashes

Hashes for mlstac-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5758d4e1de03734aba540d5200ede73facf4286b838198b06dfe5495a4e4463d
MD5 0b74b20b79fa5af707e0fd088cf273bc
BLAKE2b-256 78d82246bb7178f78d9d4e23d1b6134fa999a16c314bd0b9ffc1a2331d8f84d6

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