Spaces:
Build error
Build error
File size: 662 Bytes
63d0071 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import gradio as gr
from transformers import pipeline
# Initialize the sentiment analysis pipeline
classifier = pipeline("sentiment-analysis")
def analyze_sentiment(text):
result = classifier(text)
return result[0]['label'], result[0]['score']
# Create Gradio interface
demo = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(label="Enter text to analyze"),
outputs=[
gr.Label(label="Sentiment"),
gr.Number(label="Confidence Score")
],
title="Sentiment Analysis Demo",
description="Enter some text to analyze its sentiment using Hugging Face's transformers."
)
if __name__ == "__main__":
demo.launch() |