mexha20 commited on
Commit
16d700e
·
verified ·
1 Parent(s): 0bdc1d5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the sentiment analysis pipeline
5
+ sentiment_pipeline = pipeline("sentiment-analysis")
6
+
7
+ # Corrected function
8
+ def get_sentiment(input_text):
9
+ result = sentiment_pipeline(input_text) # Use the pipeline, not the function itself
10
+ return result[0]['label'] # Access the label correctly
11
+
12
+ # Launch the web UI
13
+ iface = gr.Interface(
14
+ fn=get_sentiment, # Pass the function to Gradio
15
+ inputs="text",
16
+ outputs="text",
17
+ title="My First AI App",
18
+ description="Enter some text and I will tell you whether it is Positive or Negative."
19
+ )
20
+
21
+ iface.launch()