Spaces:
Runtime error
Runtime error
File size: 813 Bytes
0cce53f 981db7e 0cce53f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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()
|