import gradio as gr from transformers import pipeline pipe = pipeline("text-classification", model="mgb-dx-meetup/xlm-roberta-finetuned-sentiment") def predict(text): preds = pipe(text)[0] return preds["label"], round(preds["score"], 5) gradio_ui = gr.Interface( fn=predict, title="Predicting review scores from customer reviews", description="Enter some review text about a product and check what the model predicts for it's star rating.", inputs=[ gr.inputs.Textbox(lines=5, label="Paste some text here"), ], outputs=[ gr.outputs.Textbox(label="Label"), gr.outputs.Textbox(label="Score"), ], examples=[ ["The product is perfect for my classroom. It provides a wonderful flex seating option. The company also was supportive when I had a small issue. Great customer service!"], ["Für kleinen Umzug ganz ok"], ["Pratique mais pas très absorbant. Dommage."] ], ) gradio_ui.launch()