Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# Load the sentiment analysis pipeline | |
pipe = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment") | |
def analyze_sentiment(text): | |
# Analyze sentiment using the pipeline | |
result = pipe(text)[0] | |
label = result['label'] | |
score = result['score'] | |
return f"Sentiment: {label}, Score: {score}" | |
# Create the Gradio interface | |
text_input = gr.inputs.Textbox(label="Enter Text") | |
output_text = gr.outputs.Textbox(label="Sentiment Analysis Result") | |
gr.Interface(fn=analyze_sentiment, inputs=text_input, outputs=output_text).launch() | |