Spaces:
Running
Running
Commit
·
47850ae
1
Parent(s):
82320dd
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,7 +23,8 @@ if os.path.isdir(cache_dir):
|
|
| 23 |
else:
|
| 24 |
gr.Warning("Cache directory creation error")
|
| 25 |
|
| 26 |
-
policy_help_string = """
|
|
|
|
| 27 |
|
| 28 |
1. **Annotate** - replace the PII instance by a \<TYPE:VALUE\> string, i.e. include both the PII type and its value
|
| 29 |
2. **Redact** - all PII instances are replaced by a \<PII\> generic string
|
|
@@ -38,13 +39,13 @@ header_string = """
|
|
| 38 |
PII within large scale language data. It uses best of breed tools like [🤗 transformers](https://huggingface.co/docs/transformers/index) libraries,
|
| 39 |
[spaCy](https://spacy.io/), regular expressions, [Faker](https://faker.readthedocs.io/en/master/) and [Presidio](https://microsoft.github.io/presidio/)
|
| 40 |
to leverage best practices for effectively managing data privacy in accordance with your privacy policies.
|
| 41 |
-
|
| 42 |
Important links:
|
| 43 |
1. [PIISA API docs](https://github.com/piisa/piisa)
|
| 44 |
2. [Blog](https://privacyprotection.substack.com/)
|
| 45 |
3. [LinkedIn](https://www.linkedin.com/company/piisa/)
|
| 46 |
"""
|
| 47 |
|
|
|
|
| 48 |
def change_language(language_selection):
|
| 49 |
global language_code
|
| 50 |
language_code = language_choices[language_selection]
|
|
@@ -75,8 +76,11 @@ def get_full_example(idx):
|
|
| 75 |
|
| 76 |
|
| 77 |
with gr.Blocks() as demo:
|
| 78 |
-
|
| 79 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
with gr.Column(scale=0, min_width=100):
|
| 81 |
logo = gr.Image(
|
| 82 |
"image.jpeg",
|
|
@@ -87,32 +91,26 @@ with gr.Blocks() as demo:
|
|
| 87 |
show_share_button=False,
|
| 88 |
mask_opacity=1.0,
|
| 89 |
)
|
| 90 |
-
with gr.Column():
|
| 91 |
-
pass
|
| 92 |
-
with gr.Column(
|
| 93 |
-
scale=0,
|
| 94 |
-
min_width=200,
|
| 95 |
-
):
|
| 96 |
-
lang_picker = gr.Dropdown(
|
| 97 |
-
choices=list(language_choices.keys()),
|
| 98 |
-
label="Select Language",
|
| 99 |
-
value=list(language_choices.keys())[0],
|
| 100 |
-
type="value",
|
| 101 |
-
)
|
| 102 |
-
lang_picker.select(change_language, inputs=lang_picker, outputs=None)
|
| 103 |
-
with gr.Row():
|
| 104 |
-
header = gr.Markdown(value=header_string)
|
| 105 |
with gr.Row():
|
| 106 |
with gr.Column(scale=2, min_width=400):
|
| 107 |
text_original = gr.Textbox(
|
| 108 |
label="Original Text",
|
| 109 |
-
lines=
|
| 110 |
placeholder="Enter the text you would like to analyze, or select from one of the examples below",
|
| 111 |
)
|
| 112 |
with gr.Column(scale=0, min_width=25):
|
| 113 |
pass
|
| 114 |
with gr.Column(scale=0, min_width=150):
|
| 115 |
-
gr.Markdown(value="""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
annotate_btn = gr.Button(value="Annotate", variant="primary", size="sm")
|
| 117 |
redact_btn = gr.Button(value="Redact", variant="primary", size="sm")
|
| 118 |
anonymize_btn = gr.Button(value="Synthetic", variant="primary", size="sm")
|
|
@@ -128,7 +126,7 @@ with gr.Blocks() as demo:
|
|
| 128 |
):
|
| 129 |
text_modified = gr.TextArea(
|
| 130 |
label="Transformed Text",
|
| 131 |
-
lines=
|
| 132 |
show_copy_button=True,
|
| 133 |
interactive=False,
|
| 134 |
)
|
|
@@ -168,5 +166,5 @@ with gr.Blocks() as demo:
|
|
| 168 |
)
|
| 169 |
with gr.Accordion(label="Help Panel", open=False):
|
| 170 |
gr.Markdown(value=policy_help_string)
|
| 171 |
-
|
| 172 |
demo.queue().launch()
|
|
|
|
|
|
| 23 |
else:
|
| 24 |
gr.Warning("Cache directory creation error")
|
| 25 |
|
| 26 |
+
policy_help_string = """
|
| 27 |
+
Policies are defined as follows:
|
| 28 |
|
| 29 |
1. **Annotate** - replace the PII instance by a \<TYPE:VALUE\> string, i.e. include both the PII type and its value
|
| 30 |
2. **Redact** - all PII instances are replaced by a \<PII\> generic string
|
|
|
|
| 39 |
PII within large scale language data. It uses best of breed tools like [🤗 transformers](https://huggingface.co/docs/transformers/index) libraries,
|
| 40 |
[spaCy](https://spacy.io/), regular expressions, [Faker](https://faker.readthedocs.io/en/master/) and [Presidio](https://microsoft.github.io/presidio/)
|
| 41 |
to leverage best practices for effectively managing data privacy in accordance with your privacy policies.
|
|
|
|
| 42 |
Important links:
|
| 43 |
1. [PIISA API docs](https://github.com/piisa/piisa)
|
| 44 |
2. [Blog](https://privacyprotection.substack.com/)
|
| 45 |
3. [LinkedIn](https://www.linkedin.com/company/piisa/)
|
| 46 |
"""
|
| 47 |
|
| 48 |
+
|
| 49 |
def change_language(language_selection):
|
| 50 |
global language_code
|
| 51 |
language_code = language_choices[language_selection]
|
|
|
|
| 76 |
|
| 77 |
|
| 78 |
with gr.Blocks() as demo:
|
|
|
|
| 79 |
with gr.Row():
|
| 80 |
+
with gr.Column():
|
| 81 |
+
gr.Markdown(value=header_string)
|
| 82 |
+
with gr.Column(scale=0, min_width=100):
|
| 83 |
+
pass
|
| 84 |
with gr.Column(scale=0, min_width=100):
|
| 85 |
logo = gr.Image(
|
| 86 |
"image.jpeg",
|
|
|
|
| 91 |
show_share_button=False,
|
| 92 |
mask_opacity=1.0,
|
| 93 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
with gr.Row():
|
| 95 |
with gr.Column(scale=2, min_width=400):
|
| 96 |
text_original = gr.Textbox(
|
| 97 |
label="Original Text",
|
| 98 |
+
lines=13,
|
| 99 |
placeholder="Enter the text you would like to analyze, or select from one of the examples below",
|
| 100 |
)
|
| 101 |
with gr.Column(scale=0, min_width=25):
|
| 102 |
pass
|
| 103 |
with gr.Column(scale=0, min_width=150):
|
| 104 |
+
gr.Markdown(value="""<p style="text-align: center;">Select Language</p>""")
|
| 105 |
+
lang_picker = gr.Dropdown(
|
| 106 |
+
choices=list(language_choices.keys()),
|
| 107 |
+
label="",
|
| 108 |
+
value=list(language_choices.keys())[0],
|
| 109 |
+
type="value",
|
| 110 |
+
container=False,
|
| 111 |
+
)
|
| 112 |
+
lang_picker.select(change_language, inputs=lang_picker, outputs=None)
|
| 113 |
+
gr.Markdown(value="""<p style="text-align: center;">Select Policy</p>""")
|
| 114 |
annotate_btn = gr.Button(value="Annotate", variant="primary", size="sm")
|
| 115 |
redact_btn = gr.Button(value="Redact", variant="primary", size="sm")
|
| 116 |
anonymize_btn = gr.Button(value="Synthetic", variant="primary", size="sm")
|
|
|
|
| 126 |
):
|
| 127 |
text_modified = gr.TextArea(
|
| 128 |
label="Transformed Text",
|
| 129 |
+
lines=13,
|
| 130 |
show_copy_button=True,
|
| 131 |
interactive=False,
|
| 132 |
)
|
|
|
|
| 166 |
)
|
| 167 |
with gr.Accordion(label="Help Panel", open=False):
|
| 168 |
gr.Markdown(value=policy_help_string)
|
|
|
|
| 169 |
demo.queue().launch()
|
| 170 |
+
|