import gradio as gr from transformers import pipeline # Load the sentiment-analysis pipeline with a more reliable model model = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") # Function for sentiment analysis def analyze_sentiment(feedback_text): result = model(feedback_text) sentiment = result[0]['label'] # The model outputs something like 'POSITIVE' or 'NEGATIVE' confidence = result[0]['score'] # The confidence score for the sentiment return sentiment, confidence # Gradio interface iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs=["text", "number"], live=True) # Set live=True to provide instant results as you type # Launch the interface iface.launch()