GradioPractice / app.py
Emmanuel08's picture
Update app.py
745868c verified
raw
history blame contribute delete
790 Bytes
from transformers import pipeline
import gradio as gr
#classifier = pipeline("text-classification", model="tabularisai/multilingual-sentiment-analysis")
#Load sentiment analysis pipeline
# classifier_pipeline = pipeline("text-classification", model="tabularisai/multilingual-sentiment-analysis")
# Define classification function
classifier_pipeline = ("sentiment-analysis")
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()