File size: 560 Bytes
f7bbbbc
 
 
 
139933c
f7bbbbc
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
from transformers import pipeline

# Load the pre-trained sentiment analysis model
sentiment_analysis = pipeline(model="siebert/sentiment-roberta-large-english")

# 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)