Spaces:
Sleeping
Sleeping
File size: 498 Bytes
ce695ed 87c2046 ce695ed 87c2046 ce695ed 87c2046 ce695ed 87c2046 ce695ed 87c2046 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from transformers import pipeline
# Load pre-trained sentiment-analysis pipeline
classifier = pipeline("sentiment-analysis")
# Define the function for prediction
def analyze_sentiment(text):
result = classifier(text)[0]
return f"Label: {result['label']} (Score: {result['score']:.2f})"
# Create a Gradio interface
app = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(label="Enter a sentence"),
outputs=gr.Textbox(label="Sentiment")
)
app.launch()
|