Introduction
MLup is a library for easy and fast running of ML models in production.
All you need is to deliver the model file to the server (a config is optional) — pymlup turns it into a FastAPI web application with one CLI command. No web app code to write or maintain.
- Pure Python, no required framework-specific glue code;
- Uses FastAPI for the web layer;
- Works with any Python object that exposes a
predict-like method, plus native (de)serialization support for scikit-learn, lightgbm, tensorflow, torch and onnx models.
Requirements
Python 3.10+ (3.11, 3.12, 3.13, 3.14 supported; the tensorflow extra requires Python <3.14 until TensorFlow publishes 3.14 wheels).
pymlup 0.4.0 runs on FastAPI and Pydantic v2. Python 3.8/3.9 and Pydantic v1 are still supported on the pymlup 0.3.x line.
Installation
pip install pymlup
With an ML backend extra:
pip install "pymlup[scikit-learn]" # For scikit-learn
pip install "pymlup[lightgbm]" # For microsoft lightgbm
pip install "pymlup[tensorflow]" # For tensorflow
pip install "pymlup[torch]" # For torch
pip install "pymlup[onnx]" # For onnx models: torch, tensorflow, sklearn, etc...
Quick start
From a clean environment to a working prediction API in about five minutes, using scikit-learn as the example.
1. Create a virtual environment and install pymlup with the scikit-learn extra:
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install "pymlup[scikit-learn]"
2. Train and save a tiny model. Save this as train_model.py and run it:
# train_model.py
import pickle
from sklearn.tree import DecisionTreeClassifier
X = [[0, 0], [1, 1], [2, 2], [3, 3]]
y = [0, 0, 1, 1]
model = DecisionTreeClassifier().fit(X, y)
with open("model.pkl", "wb") as f:
pickle.dump(model, f)
python train_model.py
3. Start the API:
mlup run -m ./model.pkl
4. Check it's alive (in another terminal):
curl http://localhost:8009/health
{"status":200}
5. Call the model:
curl -X POST http://localhost:8009/predict \
-H "Content-Type: application/json" \
-d '{"X": [[1, 1], [3, 3]]}'
{"predict_result":[0,1]}
6. Explore the interactive API docs. Open http://localhost:8009/docs in your browser for the Swagger UI, auto-generated from your model's predict signature — you can try /predict right there.
Stop the server with Ctrl+C.
Already have a serialized model (onnx, joblib, lightgbm, torch, tensorflow, ...) instead of training a new one? Point mlup run -m at it directly (install the matching extra from Installation) — see the full documentation for every supported format and config option.
Any Python object, no ML framework required
pymlup doesn't require a serialized model file at all — any Python object with a predict-like method works:
import mlup
class MyAnyModelForExample:
def predict(self, X):
return X
up = mlup.UP(ml_model=MyAnyModelForExample())
up.ml.load()
up.run_web_app(daemon=True)
Open http://localhost:8009/docs to try it, or call it from the same script — this needs pip install requests separately, it's not a pymlup dependency:
import requests
response = requests.post('http://localhost:8009/predict', json={'X': [[1, 2, 3], [4, 5, 6]]})
print(response.json())
up.stop_web_app()
Supported ML frameworks
Work tested with machine learning model frameworks (links to tests):
- scikit-learn>=1.2.0,<2.0.0
- tensorflow>=2.0.0,<3.0.0, Python<3.14
- lightgbm>=4.0.0,<5.0.0
- torch>=2.0.0,<3.0.0
- onnx>=1.0.0,<2.0.0
- onnxruntime>=1.14.0,<1.26.0
Support and tested with machine learning libraries:
Documentation
The full documentation — Python API, CLI reference, config file format, storages, binarizers, data transformers, web app architectures/API, application life cycle — lives at mlup.org (source: docs/).
Useful links
Metrics
MLup PyPi download statistics: https://pepy.tech/project/pymlup
Metadata
Release files for pymlup 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymlup-0.4.0.tar.gz | 45.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymlup-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 106.7 kB
Release files / pymlup-0.4.0.tar.gz
| Download URL | pymlup-0.4.0.tar.gz |
|---|---|
| Size | 45.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7aea0de395b90aeac2242d9b7bf1090b8b1afb4406e0663142dc7d49c961c734
|
|
BLAKE2b-256 checksum How to use checksums |
3f452cc74d34a1c0b42d9709bb8bca817eff400cbe57263b77640afefdbf9514
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Release files / pymlup-0.4.0-py3-none-any.whl
| Download URL | pymlup-0.4.0-py3-none-any.whl |
|---|---|
| Size | 61.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4795be3d92cf8f0002324a1a1f5fca792a25b6718c5145083ca921d92f4e2eb
|
|
BLAKE2b-256 checksum How to use checksums |
c5fee33fd2c5c841c794338d87b7b6ff4f4fb7b7c422436997b7054e631043cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|