Deserve is a nanoframework for serving ML models
Project description
Deserve
Deserve is a nanoframework for serving ML models. Flasker than Flask, faster than FastAPI, Deserve is asynchronous, lightweight and simple.
Features
- 🤙 Remote procedure call (RPC) architecture. There are no endpoints, methods, paths, nor resources to make decisions about — just the
host
:port
. - 📦 Send JSON, receive JSON, client-side. Accept a Python object, return an object, server-side. Conversions happen under the hood.
Installing
$ pip install deserve
Also install an ASGI server such as Uvicorn or Hypercorn.
$ pip install hypercorn
Quickstart
This example uses the 🤗 Transformers library.
# Save this as example.py
import deserve
from transformers import pipeline
# Load your model
classifier = pipeline('sentiment-analysis')
@deserve
async def predict(payload: object) -> object:
return classifier(payload)
Run the server using the names of your file (example.py
) and function (predict
).
$ hypercorn example:predict
[INFO] Running on http://127.0.0.1:8000
Get some predictions.
$ curl localhost:8000 --data '["This is the simplest framework.", "You deserve it!"]'
[{"label": "POSITIVE", "score": 0.799}, {"label": "POSITIVE", "score": 0.998}]
Serialization and deserialization
Deserve takes care of converting the request and response payloads based on the content-type and accept headers of the request.
List of supported content-types and the deserialized payload that is passed to the inference handler.
content-type | Payload |
---|---|
application/json | dict /list |
text/* | raw |
image/* | binary |
audio/* | binary |
List of supported accept headers and the serialized payload that is returned.
accept | Payload |
---|---|
application/json | JSON |
text/* | raw |
image/* | binary |
audio/* | binary |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file deserve-0.2.tar.gz
.
File metadata
- Download URL: deserve-0.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2c135d44b3d3ff6e676b6157aff8f3f94ae5a3f423b9bd7a207984789be372e |
|
MD5 | 2d82af80257216ef9daa523b80fad57b |
|
BLAKE2b-256 | 9e9bf39072bb1daad7bca13606cd902ae239c87f69b2f3f9faceeca9b89189a5 |
File details
Details for the file deserve-0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: deserve-0.2-py2.py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3d73756d85bd605f444fcdd1c43af7054d417f7dbe6ab3e937a8246f2785159 |
|
MD5 | e5f500a58804e4fba1a27c7b2b396a52 |
|
BLAKE2b-256 | 28c97aa2705bc51df94d440ba63f56cddc0e32ae10d2c605aee5b7c72a4a5704 |