Isotonic commited on
Commit
d2a350e
1 Parent(s): ca822f4

Added application file

Browse files
Files changed (2) hide show
  1. app.py +22 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForTokenClassification
2
+ from transformers.pipelines import pipeline
3
+ import gradio as gr
4
+ import os
5
+
6
+
7
+ masker = pipeline(
8
+ task="token-classification",
9
+ model="Isotonic/distilbert_finetuned_ai4privacy_v2",
10
+ device="cpu",
11
+ )
12
+
13
+ def ai4p_gradio(input):
14
+ entities = masker(input)
15
+ return {"text": input, "entities": entities}
16
+
17
+ demo = gr.Interface(
18
+ fn=ai4p_gradio,
19
+ inputs=gr.Textbox(lines=5, label="Input"),
20
+ outputs=gr.HighlightedText(label="output"),
21
+ )
22
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch==2.0.1
2
+ transformers
3
+ gradio
4
+ datasets