Atharva101's picture
Upload 2 files
41f2fb7 verified
raw
history blame contribute delete
676 Bytes
from transformers import pipeline
import gradio as gr
# Load pretrained sentiment analysis model
classifier = pipeline("sentiment-analysis")
# Prediction function
def analyze_sentiment(text):
result = classifier(text)
label = result[0]['label']
score = result[0]['score']
return f"Sentiment: {label}\nConfidence: {score:.2f}"
# Create Gradio interface
interface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(lines=3, placeholder="Enter text here..."),
outputs="text",
title="Sentiment Analysis App",
description="AI model deployed using Hugging Face Spaces"
)
# Launch app
interface.launch()