Last active
August 25, 2021 19:04
-
-
Save edoakes/01df0f436773e4c1a91ca63060dfc7ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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