Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,24 @@
|
|
1 |
-
|
2 |
-
from transformers import pipeline,AutoTokenizer, AutoModelForSequenceClassification
|
3 |
-
import gradio as gr
|
4 |
-
|
5 |
-
|
6 |
-
pipe = pipeline("text-classification", model="Taraassss/sentiment_analysis_IT")
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
)
|
26 |
-
|
27 |
-
iface.launch()
|
|
|
1 |
+
|
2 |
+
from transformers import pipeline,AutoTokenizer, AutoModelForSequenceClassification
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
|
6 |
+
pipe = pipeline("text-classification", model="Taraassss/sentiment_analysis_IT")
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
def sentiment_analysis(text):
|
11 |
+
result = pipe(text)
|
12 |
+
sentiment = result[0]['label']
|
13 |
+
score = result[0]['score']
|
14 |
+
return f"Sentiment: {sentiment}, Confidence: {score:.2f}"
|
15 |
+
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=sentiment_analysis,
|
18 |
+
inputs=gr.Textbox(lines=2, placeholder="Inserisci il testo da analizzare..."),
|
19 |
+
outputs="text",
|
20 |
+
title="Analisi del Sentimento Italiano",
|
21 |
+
description="Inserisci una frase in italiano per analizzare il sentimento.",
|
22 |
+
)
|
23 |
+
|
24 |
+
iface.launch()
|
|
|
|
|
|