Joe7oo7 commited on
Commit
884c2a2
·
verified ·
1 Parent(s): 65ddf6b

Update app.py

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