Meckyhugging commited on
Commit
0d90e00
·
verified ·
1 Parent(s): e566da4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Load sentiment analysis pipeline
5
+ # classifier_pipeline = pipeline("text-classification", model="tabularisai/multilingual-sentiment-analysis")
6
+ classifier_pipeline = ("sentiment-analysis")
7
+
8
+ # Define classification function
9
+ def classify_text(text):
10
+ output = classifier_pipeline(text)
11
+ return output[0] # Extract the first result from the list
12
+
13
+ # Define Gradio interface
14
+ interface = gr.Interface(
15
+ fn=classify_text,
16
+ inputs=gr.Textbox(label="Enter sentence here"),
17
+ outputs=gr.Label(),
18
+ examples=["I am hungry", "I love this product!", "This is the worst experience ever."]
19
+ )
20
+
21
+ # Launch the interface
22
+ interface.launch()