Spaces:
Sleeping
Sleeping
Delete app.py
Browse filesfrom transformers import pipeline
import gradio as gr
# Load the sentiment analysis pipeline
classifier = pipeline("sentiment-analysis")
# Define the prediction function
def analyze_sentiment(text):
result = classifier(text)[0]
label = result['label']
score = round(result['score'], 3)
return f"Sentiment: {label} (Confidence: {score})"
# Create the Gradio interface
interface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(lines=4, placeholder="Enter some text here..."),
outputs="text",
title="Sentiment Analysis with Hugging Face 🤗",
description="Enter text to find out if the sentiment is positive, negative, or neutral."
)
# Run the app
if __name__ == "__main__":
interface.launch()