Spaces:
Build error
Build error
File size: 648 Bytes
2bc3e0b a976097 2bc3e0b a976097 2bc3e0b a976097 2bc3e0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
from transformers import pipeline
# Load pre-trained sentiment analysis model
sentiment_model = pipeline("sentiment-analysis")
# Define function to use the model
def analyze_sentiment(text):
result = sentiment_model(text)[0]
return f"Label: {result['label']} | Confidence: {result['score']:.2f}"
# Create Gradio interface
demo = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(lines=3, placeholder="Type a sentence here..."),
outputs="text",
title="Simple Sentiment Analyzer",
description="Find out if your text is Positive or Negative using a BERT model."
)
# Launch the app
demo.launch()
|