import gradio as gr from transformers import pipeline # Load a tweet classification model from Hugging Face classifier = pipeline("text-classification", model="finiteautomata/bertweet-base-sentiment-analysis") def classify_tweet(tweet): result = classifier(tweet)[0] label = result['label'] score = result['score'] return f"Label: {label} (Confidence: {score:.2f})" # Create the Gradio interface iface = gr.Interface( fn=classify_tweet, inputs=gr.Textbox(lines=3, placeholder="Enter a tweet here..."), outputs="text", title="Tweet Classifier", description="Enter a tweet and click the button to classify it!" ) # Launch the app iface.launch()