Spaces:
Running
Running
File size: 681 Bytes
665a972 8edbe7c 665a972 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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() |