File size: 644 Bytes
770b6b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from transformers import pipeline
import gradio as gr

# Load sentiment analysis pipeline
classifier_pipeline = pipeline("text-classification", model="tabularisai/multilingual-sentiment-analysis")

# Define classification function
def classify_text(text):
    output = classifier_pipeline(text)
    return output[0]  # Extract the first result from the list

# Define Gradio interface
interface = gr.Interface(
    fn=classify_text,
    inputs=gr.Textbox(label="Enter sentence here"),
    outputs=gr.Label(),
    examples=["I am hungry", "I love this product!", "This is the worst experience ever."]
)

# Launch the interface
interface.launch()