Spaces:
Sleeping
Sleeping
File size: 847 Bytes
7002783 5e98755 7002783 5e98755 7002783 |
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
def sentiment_analysis(text):
# Placeholder for sentiment analysis logic
sentiment_analysis = pipeline("sentiment-analysis")
result = sentiment_analysis(text)
sentiment = result[0]['label']
score = result[0]['score']
if sentiment == "POSITIVE":
return f"Positive sentiment with score: {score:.2f}"
else:
return f"Negative sentiment with score: {score:.2f}"
with gr.Blocks() as demo:
gr.Markdown("## Sentiment Analysis App")
with gr.Column():
text_input = gr.Textbox(label="Enter text for sentiment analysis")
sentiment_output = gr.Textbox(label="Sentiment Result")
submit_btn = gr.Button("Analyze Sentiment")
submit_btn.click(sentiment_analysis, inputs=text_input, outputs=sentiment_output)
demo.launch() |