from transformers import pipeline import gradio as gr pretrained_name = "w11wo/indonesian-roberta-base-sentiment-classifier" sentiment = pipeline( "sentiment-analysis", model=pretrained_name, tokenizer=pretrained_name, return_all_scores=True ) examples = [ "Masyarakat sangat kecewa dengan tragedi Kanjuruhan", ] def sentiment_analysis(text): output = sentiment(text) return {elm["label"]: elm["score"] for elm in output[0]} demo = gr.Interface( fn=sentiment_analysis, inputs=gr.Textbox(placeholder="Enter a sentence here..."), outputs="label", interpretation="default", examples=[examples]) if __name__ == "__main__": demo.launch()