Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Chargement du pipeline d'analyse de sentiment
|
| 5 |
+
sentiment = pipeline("sentiment-analysis")
|
| 6 |
+
|
| 7 |
+
# Fonction pour prédire le sentiment
|
| 8 |
+
def predict(review):
|
| 9 |
+
result = sentiment(review)[0]
|
| 10 |
+
return f"Sentiment : {result['label']}, confiance {result['score']:.2f}"
|
| 11 |
+
|
| 12 |
+
# Interface Gradio
|
| 13 |
+
gr.Interface(fn=predict, inputs="text", outputs="text").launch()
|