VeyVey commited on
Commit
420fa67
1 Parent(s): 2163a12

Create app.y

Browse files
Files changed (1) hide show
  1. app.y +18 -0
app.y ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the sentiment analysis pipeline
5
+ pipe = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment")
6
+
7
+ def analyze_sentiment(text):
8
+ # Analyze sentiment using the pipeline
9
+ result = pipe(text)[0]
10
+ label = result['label']
11
+ score = result['score']
12
+ return f"Sentiment: {label}, Score: {score}"
13
+
14
+ # Create the Gradio interface
15
+ text_input = gr.inputs.Textbox(label="Enter Text")
16
+ output_text = gr.outputs.Textbox(label="Sentiment Analysis Result")
17
+
18
+ gr.Interface(fn=analyze_sentiment, inputs=text_input, outputs=output_text).launch()