deepasreevarma commited on
Commit
8a28994
·
verified ·
1 Parent(s): 7997ea3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load our model (this will happen when the app starts)
5
+ sentiment_pipeline = pipeline("sentiment-analysis")
6
+
7
+ # Create a function that Gradio can use
8
+ def get_sentiment(input_text):
9
+ result = sentiment_pipeline(input_text)
10
+ return result[0]['label'] # Just return the label (POSITIVE or NEGATIVE)
11
+
12
+ # Launch the web UI
13
+ iface = gr.Interface(
14
+ fn=get_sentiment,
15
+ inputs="text",
16
+ outputs="text",
17
+ title="My First AI App",
18
+ description="Enter some text and I'll tell you if it's positive or negative."
19
+ )
20
+ iface.launch()