File size: 584 Bytes
2168cf5
 
 
 
ef26fd6
2168cf5
ef26fd6
 
2168cf5
 
 
 
 
 
 
 
ef26fd6
af8323b
b9ea11e
2168cf5
ef26fd6
 
 
9b8a04e
ef26fd6
2168cf5
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
)

examples = [
    "Ada apa dengan Jokowi di istana negara?",
]

def sentiment_analysis(text):
    output = sentiment(text)
    return output[0]

demo = gr.Interface(
    fn=sentiment_analysis, 
    inputs=gr.Textbox(placeholder="Enter a sentence here..."), 
    outputs="label",
    examples=[examples])

if __name__ == "__main__":
    demo.launch()