Spaces:
Runtime error
Runtime error
Commit
·
9aede51
1
Parent(s):
8d0f5dc
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
from transformers import TextClassificationPipeline, DistilBertTokenizer, DistilBertForSequenceClassification
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# model path in hugginface
|
| 7 |
model_path = "yabramuvdi/distilbert-wfh"
|
| 8 |
tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-uncased")
|
|
@@ -53,7 +58,8 @@ app = gr.Interface(fn=[predict_wfh],
|
|
| 53 |
article=article,
|
| 54 |
examples=examples,
|
| 55 |
allow_flagging="manual",
|
| 56 |
-
flagging_options=["mistake",
|
|
|
|
| 57 |
)
|
| 58 |
|
| 59 |
app.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
import numpy as np
|
| 3 |
import torch
|
| 4 |
import gradio as gr
|
| 5 |
from transformers import TextClassificationPipeline, DistilBertTokenizer, DistilBertForSequenceClassification
|
| 6 |
|
| 7 |
+
# HuggingFace dataset to save the flagged examples
|
| 8 |
+
HF_TOKEN = os.getenv('HF_TOKEN')
|
| 9 |
+
hf_saver = gr.HuggingFaceDatasetSaver(HF_TOKEN, "wfh-problematic")
|
| 10 |
+
|
| 11 |
# model path in hugginface
|
| 12 |
model_path = "yabramuvdi/distilbert-wfh"
|
| 13 |
tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-uncased")
|
|
|
|
| 58 |
article=article,
|
| 59 |
examples=examples,
|
| 60 |
allow_flagging="manual",
|
| 61 |
+
flagging_options=["mistake"],
|
| 62 |
+
flagging_callback=hf_saver
|
| 63 |
)
|
| 64 |
|
| 65 |
app.launch()
|