import gradio as gr from transformers import pipeline distilled_student_sentiment_classifier = pipeline( model="lxyuan/distilbert-base-multilingual-cased-sentiments-student", return_all_scores=True ) def sentiment_analysis(user_query: str): result = distilled_student_sentiment_classifier(user_query)[0] structured_result = dict() for r in result: structured_result[r["label"]] = r["score"] return structured_result demo = gr.Interface( fn = sentiment_analysis, inputs = [gr.Textbox()], outputs = [gr.Label()] ) demo.launch()