from transformers import pipeline import gradio as gr # Load the model from Hugging Face classifier = pipeline("sentiment-analysis") # Define the function to make predictions def predict(text): result = classifier(text)[0] return f"{result['label']} ({result['score']:.2f})" # Create the Gradio interface gr.Interface( fn=predict, inputs=gr.Textbox(label="Enter Text"), outputs=gr.Label(label="Sentiment"), title="Sentiment Analysis with DistilBERT", description="Classify text as positive or negative.", ).launch()