Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# Load the sentiment-analysis pipeline with a specified model | |
classifier = pipeline('sentiment-analysis', model='distilbert-base-uncased-finetuned-sst-2-english') | |
def sentiment_analysis(text): | |
result = classifier(text)[0] | |
return f"Label: {result['label']}, Score: {round(result['score'], 4)}" | |
iface = gr.Interface( | |
fn=sentiment_analysis, | |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."), | |
outputs=gr.Textbox(), | |
title="Simple Sentiment Analysis", | |
description="Enter a sentence and see if it's Positive or Negative!" | |
) | |
iface.launch() | |