Skip to content

Instantly share code, notes, and snippets.

@edoakes
Last active August 25, 2021 19:04
Show Gist options
  • Save edoakes/01df0f436773e4c1a91ca63060dfc7ff to your computer and use it in GitHub Desktop.
Save edoakes/01df0f436773e4c1a91ca63060dfc7ff to your computer and use it in GitHub Desktop.
from transformers import pipeline
@serve.deployment(route_prefix="/sentiment", name="sentiment")
class SentimentDeployment:
def __init__(self):
self.classifier = pipeline("sentiment-analysis")
async def __call__(self, request):
data = await request.body()
[result] = self.classifier(str(data))
return result["label"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment