RS00 commited on
Commit
6c701d5
·
verified ·
1 Parent(s): 77ed5e5

Upload sentimentAnalysisITA.py

Browse files
Files changed (1) hide show
  1. sentimentAnalysisITA.py +27 -0
sentimentAnalysisITA.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ tokenizer = AutoTokenizer.from_pretrained("Taraassss/sentiment_analysis_IT")
8
+ model = AutoModelForSequenceClassification.from_pretrained("Taraassss/sentiment_analysis_IT")
9
+
10
+
11
+ pipe = pipeline("text-classification", model="Taraassss/sentiment_analysis_IT")
12
+
13
+ def sentiment_analysis(text):
14
+ result = pipe(text)
15
+ sentiment = result[0]['label']
16
+ score = result[0]['score']
17
+ return f"Sentiment: {sentiment}, Confidence: {score:.2f}"
18
+
19
+ iface = gr.Interface(
20
+ fn=sentiment_analysis,
21
+ inputs=gr.Textbox(lines=2, placeholder="Inserisci il testo da analizzare..."),
22
+ outputs="text",
23
+ title="Analisi del Sentimento Italiano",
24
+ description="Inserisci una frase in italiano per analizzare il sentimento.",
25
+ )
26
+
27
+ iface.launch()