amelkhoadry commited on
Commit
4f5baeb
·
verified ·
1 Parent(s): fc8f578

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Load the model
5
+ sentiment_model = pipeline("sentiment-analysis")
6
+
7
+ # Define the app's logic
8
+ def analyze_sentiment(text):
9
+ result = sentiment_model(text)[0] # Get the first result
10
+ label = result['label'] # Extract label (e.g., "POSITIVE" or "NEGATIVE")
11
+ return label
12
+
13
+ # Gradio interface
14
+ interface = gr.Interface(
15
+ fn=analyze_sentiment,
16
+ inputs="text",
17
+ outputs="text",
18
+ )
19
+
20
+ interface.launch()