Ray1st's picture
Update app.py
981db7e verified
raw
history blame contribute delete
813 Bytes
import gradio as gr
from transformers import pipeline
sentiment_pipeline = pipeline("sentiment-analysis")
review = "I haven not enjoyed my stay !"
result = sentiment_pipeline(review)[0]
print(result)
def analyze_sentiment(review):
result = sentiment_pipeline(review)[0]
sentiment_label = result["label"]
confidence_score = round(result["score"], 2)
return sentiment_label, confidence_score
interface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(
lines=3, placeholder="Enter a review...", label="Enter the review:"
),
outputs=[
gr.Textbox(label="Sentiment:"),
gr.Textbox(label="Confidence Score:")
],
title="Sentiment Analysis",
description="Enter a review and get the sentiment and confidence score."
)
interface.launch()