Ujeshhh's picture
app.py
1886dd0 verified
raw
history blame
751 Bytes
import gradio as gr
from transformers import pipeline
# Load pre-trained sentiment analysis model from Hugging Face
sentiment_pipeline = pipeline("tabularisai/multilingual-sentiment-analysis")
def analyze_sentiment(text):
result = sentiment_pipeline(text)[0]
label = result['label']
score = round(result['score'], 3)
return f"Sentiment: {label} | Confidence: {score}"
# Gradio UI
iface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(label="Enter Text"),
outputs=gr.Textbox(label="Sentiment Result"),
title="Sentiment Analysis with Hugging Face πŸ€—",
description="This app performs sentiment analysis on user input text using Hugging Face Transformers."
)
if __name__ == "__main__":
iface.launch()