Spaces:
Sleeping
Sleeping
File size: 561 Bytes
79b0868 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import gradio as gr
from transformers import pipeline
# Load Hugging Face pretrained sentiment analysis model
classifier = pipeline("sentiment-analysis")
def classify_text(text):
result = classifier(text)[0]
return f"Label: {result['label']}, Confidence: {result['score']:.2f}"
# Gradio interface
gr.Interface(
fn=classify_text,
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
outputs="text",
title="Sentiment Classifier",
description="Type a sentence and get sentiment prediction (Positive or Negative)"
).launch()
|