Spaces:
Runtime error
Runtime error
Rivo Juicer Wowor
commited on
Commit
·
e9397d6
1
Parent(s):
cbc53a1
init
Browse files- .ipynb_checkpoints/app-checkpoint.py +18 -0
- app.py +18 -0
.ipynb_checkpoints/app-checkpoint.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
from transformers import pipeline, BertTokenizer
|
| 4 |
+
|
| 5 |
+
tokenizer = BertTokenizer.from_pretrained("indobenchmark/indobert-base-p1")
|
| 6 |
+
classifier = pipeline(model="itshiroto/indobert-hoax-detection", tokenizer=tokenizer)
|
| 7 |
+
|
| 8 |
+
def predict(prompt):
|
| 9 |
+
completion = classifier(prompt)[0]
|
| 10 |
+
return completion['label'], completion['score']
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
demo = gr.Interface(
|
| 14 |
+
fn=predict,
|
| 15 |
+
inputs=gr.Textbox(label="News Input"),
|
| 16 |
+
outputs=[gr.Text(label="Label"), gr.Number(label="Score")]
|
| 17 |
+
)
|
| 18 |
+
demo.launch()
|
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
from transformers import pipeline, BertTokenizer
|
| 4 |
+
|
| 5 |
+
tokenizer = BertTokenizer.from_pretrained("indobenchmark/indobert-base-p1")
|
| 6 |
+
classifier = pipeline(model="itshiroto/indobert-hoax-detection", tokenizer=tokenizer)
|
| 7 |
+
|
| 8 |
+
def predict(prompt):
|
| 9 |
+
completion = classifier(prompt)[0]
|
| 10 |
+
return completion['label'], completion['score']
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
demo = gr.Interface(
|
| 14 |
+
fn=predict,
|
| 15 |
+
inputs=gr.Textbox(label="News Input"),
|
| 16 |
+
outputs=[gr.Text(label="Label"), gr.Number(label="Score")]
|
| 17 |
+
)
|
| 18 |
+
demo.launch()
|