DEV Community

Cover image for A straightforward Flask replacement for ML model deployment
Matías Battocchia
Matías Battocchia

Posted on

A straightforward Flask replacement for ML model deployment

Why would someone need to replace Flask or FastAPI for the task of deploying a model? They get the job done. Well, yes — that was what I used to think.

Some time ago I gave the task of serving a model to a team of junior developers. It was a data science team, good at developing models, without prior web development knowledge.

I told the team: use something simple like Flask. They finally did it, but struggled with some web concepts such as requests, responses and headers during that day.

So, we are used to web frameworks for model serving, while we could be using a leaner and more specific tool for the task. That is what Deserve is about.

I bid goodbye with an example:

import deserve
from transformers import pipeline

# Load your model
classifier = pipeline('sentiment-analysis')

@deserve
async def predict(payload: object) -> object:
    return classifier(payload)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)