Spaces:
Running
Running
Added application file
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
2 |
+
from transformers.pipelines import pipeline
|
3 |
+
import gradio as gr
|
4 |
+
from huggingface_hub import login
|
5 |
+
import os
|
6 |
+
|
7 |
+
login(os.environ['HF_Token'])
|
8 |
+
|
9 |
+
masker = pipeline(
|
10 |
+
task="token-classification",
|
11 |
+
model="Isotonic/distilbert_finetuned_ai4privacy",
|
12 |
+
device="cpu",
|
13 |
+
)
|
14 |
+
|
15 |
+
def ai4p_gradio(input):
|
16 |
+
entities = masker(input)
|
17 |
+
return {"text": input, "entities": entities}
|
18 |
+
|
19 |
+
demo = gr.Interface(
|
20 |
+
fn=ai4p_gradio,
|
21 |
+
inputs=gr.Textbox(lines=5, label="Input"),
|
22 |
+
outputs=gr.HighlightedText(label="output"),
|
23 |
+
)
|
24 |
+
demo.launch()
|