import gradio as gr from transformers import pipeline # Load pre-trained model from Hugging Face classifier = pipeline('sentiment-analysis') def classify_text(text): result = classifier(text)[0] label = result['label'] score = result['score'] return f"{label} (confidence: {score:.2f})" # Create the Gradio interface iface = gr.Interface(fn=classify_text, inputs=["text"], outputs=["prediction"]) # Launch the Gradio app iface.launch()