Metadata-Version: 2.1
Name: mlstac
Version: 0.3.1
Summary: A machine learning model-sharing specification based on STAC MLM and Safetensors.
Home-page: https://github.com/csaybar/isp-models
Author: Cesar Aybar
Author-email: cesar.aybar@uv.es
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: fsspec (>=2024.10.0)
Requires-Dist: pystac (>=1.12.2)
Requires-Dist: safetensors (>=0.5.2)
Requires-Dist: tqdm (>=4.67.1)
Project-URL: Documentation, https://csaybar.github.io/isp-models/
Project-URL: Repository, https://github.com/csaybar/isp-models
Description-Content-Type: text/markdown

# MLSTAC: Machine Learning with STAC

[![PyPI version](https://img.shields.io/pypi/v/mlstac.svg)](https://pypi.org/project/mlstac/)
[![Python Versions](https://img.shields.io/pypi/pyversions/mlstac.svg)](https://pypi.org/project/mlstac/)
[![License](https://img.shields.io/pypi/l/mlstac.svg)](https://github.com/csaybar/isp-models/blob/main/LICENSE)
[![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://csaybar.github.io/isp-models/)

MLSTAC is a Python library that simplifies working with machine learning models using STAC (SpatioTemporal Asset Catalog) metadata standards. Load models with just a few lines of code regardless of where they're stored or how they're formatted.

## Features

- **Unified API**: Work with ML models using a consistent interface
- **Multiple Storage Backends**: Support for local, HTTP(S), FTP, S3, and Google Cloud Storage
- **Smart Visualization**: Automatic detection of Jupyter/Colab notebooks for enhanced display
- **Efficient Downloads**: Stream large model files for optimal performance
- **STAC Metadata**: Rich model information using standard metadata format

## Installation

```bash
pip install mlstac
```

## Quick Start

```python
from mlstac import ModelLoader

# Load a model by ID (will fetch metadata from the registry)
model = ModelLoader("resnet50")

# Download the model to a local directory
model.download("./models")

# Load the model for inference
inference_model = model.load_compiled_model()

# Get example data for testing
example_data = model.load_example_data()

# Run inference
result = inference_model(example_data)
```

## Working with Models

MLSTAC provides a simple, consistent interface for working with ML models:

```python
# View model information
model = ModelLoader("efficientnet")
# Prints rich information about the model in a notebook or terminal

# Get model summary as a dictionary
summary = model.get_model_summary()

# Download only specific components
model.download(
    "./models", 
    trainable_model=True, 
    compiled_model=True,
    example_data=False
)

# Load for training
trainable = model.load_trainable_model()
```

## Model Storage Support

MLSTAC supports multiple ways to access models:

- **Snippet IDs**: Short IDs that resolve to models in the registry
- **URLs**: HTTP(S) or FTP URLs to model files
- **Cloud Storage**: AWS S3 and Google Cloud Storage
- **Local Paths**: File paths on your local system

## Documentation

For complete documentation, visit our [documentation site](https://csaybar.github.io/isp-models/).

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the terms of the MIT license.
