Sentiment / app.py
VIATEUR-AI's picture
Update app.py
87c2046 verified
raw
history blame contribute delete
498 Bytes
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()