Spaces:
Runtime error
Runtime error
File size: 326 Bytes
73a696f | 1 2 3 4 5 6 7 8 9 10 11 | from fastapi import FastAPI
from transformers import pipeline
app = FastAPI()
classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment-latest")
@app.get("/sentiment")
def analyze(text: str):
result = classifier(text)[0]
return {"label": result["label"], "score": result["score"]}
|