demo-class / app.py
thak123's picture
Create app.py
f7bbbbc verified
raw
history blame
533 Bytes
import gradio as gr
from transformers import pipeline
# Load the pre-trained sentiment analysis model
sentiment_analysis = pipeline("sentiment-analysis")
# Define the function for sentiment prediction
def predict_sentiment(text):
result = sentiment_analysis(text)
return result[0]['label']
# Create the Gradio interface
iface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text",
title="Sentiment Analyser",
description="Here's a demo SA.",)
# Launch the app
iface.launch(share=True)