AhsanSaghir commited on
Commit
ef37f64
·
verified ·
1 Parent(s): c3c95d0

Update app.py

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