File size: 496 Bytes
e9397d6
 
 
 
 
370acfa
e9397d6
 
 
 
 
 
 
 
 
 
 
 
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, BertTokenizer

tokenizer = BertTokenizer.from_pretrained("indobenchmark/indobert-base-p1")
classifier = pipeline(model="umn-cyber/indobert-hoax", tokenizer=tokenizer)

def predict(prompt):
    completion = classifier(prompt)[0]
    return completion['label'], completion['score']


demo = gr.Interface(
    fn=predict,
    inputs=gr.Textbox(label="News Input"),
    outputs=[gr.Text(label="Label"), gr.Number(label="Score")]
)
demo.launch()