Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
def analyser_sentiment_camembert(tweet):
|
| 5 |
+
# charger le modèle
|
| 6 |
+
sentiment_pipeline = pipeline("sentiment-analysis", model="cmarkea/distilcamembert-base-sentiment")
|
| 7 |
+
|
| 8 |
+
# appliquer le modèle
|
| 9 |
+
result = sentiment_pipeline(tweet)[0]['label']
|
| 10 |
+
return result
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
interface2 = gr.Interface(
|
| 14 |
+
fn = analyser_sentiment_camembert,
|
| 15 |
+
inputs=gr.Textbox(lines=3, placeholder="Entrez un tweet en français ici..."),
|
| 16 |
+
outputs=gr.Textbox(label='Output'),
|
| 17 |
+
title="Analyse de Sentiment de Tweets",
|
| 18 |
+
description="Entrez un tweet en français pour obtenir son sentiment."
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# lancer l'interface
|
| 24 |
+
interface2.launch()
|