Spaces:
Sleeping
Sleeping
File size: 751 Bytes
aaf19ed 1886dd0 aaf19ed 1886dd0 aaf19ed 1886dd0 aaf19ed 1886dd0 aaf19ed 1886dd0 aaf19ed 1886dd0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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()
|