saira-projects's picture
Create app.py
ef18eae verified
import gradio as gr
from transformers import pipeline
# Load sentiment analysis model
sentiment = pipeline("sentiment-analysis")
# Function to analyze text
def analyze_sentiment(text):
if not text.strip():
return "Please enter some text!"
result = sentiment(text)[0]
return f"Label: {result['label']}, Score: {round(result['score'], 2)}"
# Gradio interface
iface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(lines=5, placeholder="Type your text here..."),
outputs="text",
title="๐Ÿ˜Š Sentiment Analyzer",
description="Type any text and see if it is Positive, Negative, or Neutral!"
)
iface.launch()