sifujohn commited on
Commit
770b6b6
·
verified ·
1 Parent(s): 9d72d85

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
7
+ # Define classification function
8
+ def classify_text(text):
9
+ output = classifier_pipeline(text)
10
+ return output[0] # Extract the first result from the list
11
+
12
+ # Define Gradio interface
13
+ interface = gr.Interface(
14
+ fn=classify_text,
15
+ inputs=gr.Textbox(label="Enter sentence here"),
16
+ outputs=gr.Label(),
17
+ examples=["I am hungry", "I love this product!", "This is the worst experience ever."]
18
+ )
19
+
20
+ # Launch the interface
21
+ interface.launch()