Atharva101 commited on
Commit
41f2fb7
·
verified ·
1 Parent(s): cc1ccee

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +26 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Load pretrained sentiment analysis model
5
+ classifier = pipeline("sentiment-analysis")
6
+
7
+ # Prediction function
8
+ def analyze_sentiment(text):
9
+ result = classifier(text)
10
+
11
+ label = result[0]['label']
12
+ score = result[0]['score']
13
+
14
+ return f"Sentiment: {label}\nConfidence: {score:.2f}"
15
+
16
+ # Create Gradio interface
17
+ interface = gr.Interface(
18
+ fn=analyze_sentiment,
19
+ inputs=gr.Textbox(lines=3, placeholder="Enter text here..."),
20
+ outputs="text",
21
+ title="Sentiment Analysis App",
22
+ description="AI model deployed using Hugging Face Spaces"
23
+ )
24
+
25
+ # Launch app
26
+ interface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio