Felguk commited on
Commit
9c2c656
·
verified ·
1 Parent(s): f8b3318

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the sentiment analysis model
5
+ sentiment_pipeline = pipeline("sentiment-analysis")
6
+
7
+ def analyze_sentiment(text):
8
+ result = sentiment_pipeline(text)[0]
9
+ return f"Label: {result['label']}, Confidence: {result['score']:.4f}"
10
+
11
+ # Define the Gradio interface
12
+ iface = gr.Interface(
13
+ fn=analyze_sentiment,
14
+ inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
15
+ outputs="text",
16
+ title="Sentiment Analysis",
17
+ description="Enter a sentence to analyze its sentiment."
18
+ )
19
+
20
+ # Launch the interface
21
+ iface.launch()