CadenShokat commited on
Commit
73a696f
·
verified ·
1 Parent(s): 80d7025

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ app = FastAPI()
5
+ classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment-latest")
6
+
7
+ @app.get("/sentiment")
8
+ def analyze(text: str):
9
+ result = classifier(text)[0]
10
+ return {"label": result["label"], "score": result["score"]}