Spaces:
Sleeping
Sleeping
File size: 424 Bytes
a146dfc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import gradio as gr
from transformers import pipeline
# Load the model
classifier = pipeline("sentiment-analysis")
# Define the function for Gradio
def analyze_sentiment(text):
result = classifier(text)[0]
return f"{result['label']} (Confidence: {result['score']:.2f})"
# Create a Gradio interface
interface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text")
# Launch the app
interface.launch()
|