Spaces:
Sleeping
Sleeping
Download app.py from Anwaree/sentiment-demo: direct link, hf CLI and curl.
- Browser
- Download file 402 Bytes
-
https://huggingface.co/spaces/Anwaree/sentiment-demo/resolve/main/app.py
- Command line
-
hf download hf://spaces/Anwaree/sentiment-demo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Anwaree/sentiment-demo/resolve/main/app.py
402 Bytes
| from transformers import pipeline | |
| import gradio as gr | |
| # Chargement du pipeline d'analyse de sentiment | |
| sentiment = pipeline("sentiment-analysis") | |
| # Fonction pour prédire le sentiment | |
| def predict(review): | |
| result = sentiment(review)[0] | |
| return f"Sentiment : {result['label']}, confiance {result['score']:.2f}" | |
| # Interface Gradio | |
| gr.Interface(fn=predict, inputs="text", outputs="text").launch() | |