Code Monkey home page Code Monkey logo

deserve's Introduction

Deserve

Deserve example workflow example workflow

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.
  • 🛩️ No dependencies, less than 70 lines of code.

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 handler 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 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

deserve's People

Contributors

matiasbattocchia avatar

Stargazers

Gaston Bji avatar  avatar Julia Milanese avatar Diego Emilio Parma avatar Julio Spairani avatar Ramiro Savoie avatar Matias Haure avatar  avatar  avatar  avatar Pedro Maglione avatar Cefra avatar  avatar Alesis Manzano avatar Nacho avatar Ezequiel Geringer avatar  avatar  avatar Cezar Azevedo de Faveri avatar MG avatar  avatar  avatar Gonzalo Flores avatar Federico Bricker avatar  avatar  avatar Damián Blasi avatar Daniel Quinteros avatar Julieta Carricondo Robino avatar Martín Santos avatar Tomás Manzur avatar Cristian Costa avatar Luciano Robino avatar Lisandro Espejo avatar  avatar  avatar Fer Perrotta avatar Rodrigo Sobisch avatar Leonardo Calderon avatar Mauricio Pasquier Juan avatar M. Victoria Munafó avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.