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