GitHub Actions
Deploy from GitHub
022803a
raw
history blame contribute delete
520 Bytes
import gradio as gr
from transformers import pipeline
sentiment_pipeline = pipeline(
"sentiment-analysis",
model="distilbert-base-uncased-finetuned-sst-2-english"
)
def analyze(text):
result = sentiment_pipeline(text)[0]
label = result["label"]
score = result["score"]
return f"{label} ({score:.2%} confidence)"
demo = gr.Interface(
fn=analyze,
inputs=gr.Textbox(placeholder="Type something..."),
outputs=gr.Textbox(label="Result"),
title="Sentiment Analyzer"
)
demo.launch()