Atelv7's picture
Create app.py
79b0868 verified
Raw History Blame Contribute Delete
561 Bytes
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()