Spaces:
Sleeping
Sleeping
Create app.py
Browse files
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()
|