Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def gradio_anonymize(text):
|
4 |
+
anonymized_text, lookup_table = anonymize_text_including_proper_nouns_and_addresses(text, pii_config)
|
5 |
+
return anonymized_text, str(lookup_table)
|
6 |
+
|
7 |
+
def gradio_deanonymize(anonymized_text, lookup_table):
|
8 |
+
lookup_table = eval(lookup_table)
|
9 |
+
restored_text = deanonymize_text(lookup_table, anonymized_text)
|
10 |
+
return restored_text
|
11 |
+
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=[gradio_anonymize, gradio_deanonymize],
|
14 |
+
inputs=[
|
15 |
+
gr.inputs.Textbox(lines=5, label="Text to Anonymize"),
|
16 |
+
gr.inputs.Textbox(lines=5, label="Anonymized Text"),
|
17 |
+
gr.inputs.Textbox(lines=5, label="Lookup Table")
|
18 |
+
],
|
19 |
+
outputs=[
|
20 |
+
gr.outputs.Textbox(label="Anonymized Text"),
|
21 |
+
gr.outputs.Textbox(label="Lookup Table"),
|
22 |
+
gr.outputs.Textbox(label="Restored Text")
|
23 |
+
]
|
24 |
+
)
|
25 |
+
iface.launch()
|