Spaces:
Runtime error
Runtime error
Download app.py from CadenShokat/sentiment-classification: direct link, hf CLI and curl.
- Browser
- Download file 326 Bytes
-
https://huggingface.co/spaces/CadenShokat/sentiment-classification/resolve/main/app.py
- Command line
-
hf download hf://spaces/CadenShokat/sentiment-classification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/CadenShokat/sentiment-classification/resolve/main/app.py
326 Bytes
| from fastapi import FastAPI | |
| from transformers import pipeline | |
| app = FastAPI() | |
| classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment-latest") | |
| def analyze(text: str): | |
| result = classifier(text)[0] | |
| return {"label": result["label"], "score": result["score"]} | |