test_space / app.py
abetavarez's picture
fixed
b0ca38a verified
raw
history blame contribute delete
671 Bytes
from transformers import pipeline
import gradio as gr
classifier = pipeline("sentiment-analysis")
def score_text(text: str):
result = classifier(text)[0]
label = result["label"]
score = result["score"]
return f"Sentiment: {label} score: {score}"
app = gr.Interface(
fn=score_text,
inputs=["textbox"],
outputs=["textbox"],
title="Sentiment Analysis App πŸ€—πŸ˜‘πŸ˜ ",
description="### Enter any text to instantly analyze its sentiment using a state-of-the-art machine learning model. The app will determine whether the sentiment is positive, negative, or neutral, and display the confidence score for the prediction."
)
app.launch()