import gradio as gr from transformers import pipeline # Initialize the Hugging Face sentiment-analysis pipeline nlp = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") def sentiment_analysis(text): result = nlp(text)[0] return f"label: {result['label']}, with score: {round(result['score'], 4)}" # Define example inputs examples = [ ['Absolutely love my new lamp from BrightLight Co.! The design is elegant and modern, seamlessly blending into my home decor.'], ['The movie was a great disappointment.'], ['Sarah at SeriouslyNutz has awesome parrot toys. My African Grey loves them all!'] ] iface = gr.Interface(fn=sentiment_analysis, inputs=gr.inputs.Textbox(lines=7, label="Input Text"), # Set the lines to 7 for a larger text box outputs="text", examples=examples) # Add example inputs iface.launch()