Spaces:
Sleeping
Sleeping
File size: 629 Bytes
f0967d5 a9f30fb f0967d5 a9f30fb f0967d5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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()
|