Spaces:
Sleeping
Sleeping
File size: 623 Bytes
f5deece 974092d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
from transformers import pipeline
# Load pre-trained sentiment analysis model from Hugging Face
classifier = pipeline("sentiment-analysis")
# Define the function to predict sentiment
def predict_sentiment(text):
result = classifier(text)
label = result[0]['label']
confidence = result[0]['score']
return f"Sentiment: {label}, Confidence: {confidence:.2f}"
# Gradio interface
interface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text",
title="Sentiment Analysis", description="Enter text to predict sentiment")
interface.launch(share=True)
|