Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -504,9 +504,8 @@ with demo:
|
|
| 504 |
|
| 505 |
gr.Markdown(
|
| 506 |
"""
|
| 507 |
-
<h1 style="text-align: center;">
|
| 508 |
-
<!--
|
| 509 |
-
<p align="center">
|
| 510 |
<a href="https://github.com/zama-ai/concrete-ml"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/github.png">Concrete-ML</a>
|
| 511 |
—
|
| 512 |
<a href="https://docs.zama.ai/concrete-ml"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/documentation.png">Documentation</a>
|
|
@@ -514,27 +513,21 @@ with demo:
|
|
| 514 |
<a href=" https://community.zama.ai/c/concrete-ml/8"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/community.png">Community</a>
|
| 515 |
—
|
| 516 |
<a href="https://twitter.com/zama_fhe"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/x.png">@zama_fhe</a>
|
| 517 |
-
</p>
|
| 518 |
-
-->
|
| 519 |
"""
|
| 520 |
)
|
| 521 |
-
|
| 522 |
gr.Markdown(
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
</p>
|
| 531 |
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
</p>
|
| 535 |
-
"""
|
| 536 |
-
)
|
| 537 |
-
|
| 538 |
|
| 539 |
# Step 1: Add an audio file
|
| 540 |
gr.Markdown("## Step 1: Add an Audio File")
|
|
@@ -620,34 +613,6 @@ with demo:
|
|
| 620 |
outputs=[gen_key_btn],
|
| 621 |
)
|
| 622 |
|
| 623 |
-
########################## Main document Part ##########################
|
| 624 |
-
|
| 625 |
-
gr.Markdown("<hr />")
|
| 626 |
-
gr.Markdown("## Step 2.1: Select the document you want to encrypt\n\n"
|
| 627 |
-
"""To make it simple, we pre-compiled the following document, but you are free to choose
|
| 628 |
-
on which part you want to run this example.
|
| 629 |
-
"""
|
| 630 |
-
)
|
| 631 |
-
|
| 632 |
-
with gr.Row():
|
| 633 |
-
with gr.Column(scale=5):
|
| 634 |
-
original_sentences_box = gr.CheckboxGroup(
|
| 635 |
-
ORIGINAL_DOCUMENT,
|
| 636 |
-
value=ORIGINAL_DOCUMENT,
|
| 637 |
-
label="Contract:",
|
| 638 |
-
show_label=True,
|
| 639 |
-
)
|
| 640 |
-
|
| 641 |
-
with gr.Column(scale=1, min_width=6):
|
| 642 |
-
gr.HTML("<div style='height: 77px;'></div>")
|
| 643 |
-
encrypt_doc_btn = gr.Button("Encrypt the document")
|
| 644 |
-
|
| 645 |
-
with gr.Column(scale=5):
|
| 646 |
-
encrypted_doc_box = gr.Textbox(
|
| 647 |
-
label="Encrypted document:", show_label=True, interactive=False, lines=10
|
| 648 |
-
)
|
| 649 |
-
|
| 650 |
-
|
| 651 |
########################## User Query Part ##########################
|
| 652 |
|
| 653 |
gr.Markdown("<hr />")
|
|
@@ -691,7 +656,7 @@ with demo:
|
|
| 691 |
########################## FHE processing Part ##########################
|
| 692 |
|
| 693 |
gr.Markdown("<hr />")
|
| 694 |
-
gr.Markdown("## Step 3: De-identify the
|
| 695 |
gr.Markdown(
|
| 696 |
"""Once the client encrypts the document and the prompt locally, it will be sent to a remote
|
| 697 |
server to perform the de-identification on encrypted data. When the computation is done, the
|
|
@@ -702,11 +667,11 @@ with demo:
|
|
| 702 |
run_fhe_btn = gr.Button("De-identify using FHE")
|
| 703 |
|
| 704 |
with gr.Row():
|
| 705 |
-
with gr.Column(scale=5):
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
|
| 711 |
with gr.Column(scale=5):
|
| 712 |
|
|
@@ -717,11 +682,11 @@ with demo:
|
|
| 717 |
|
| 718 |
identified_words_output_df = gr.Dataframe(label="Identified words:", visible=False)
|
| 719 |
|
| 720 |
-
encrypt_doc_btn.click(
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
)
|
| 725 |
|
| 726 |
encrypt_query_btn.click(
|
| 727 |
fn=encrypt_query_fn,
|
|
@@ -736,8 +701,8 @@ with demo:
|
|
| 736 |
|
| 737 |
run_fhe_btn.click(
|
| 738 |
anonymization_with_fn,
|
| 739 |
-
inputs=[
|
| 740 |
-
outputs=[
|
| 741 |
)
|
| 742 |
|
| 743 |
|
|
|
|
| 504 |
|
| 505 |
gr.Markdown(
|
| 506 |
"""
|
| 507 |
+
<h1 style="text-align: center;">Encrypted de-identification Audio Files Using Fully Homomorphic Encryption</h1>
|
| 508 |
+
<!-- <p align="center">
|
|
|
|
| 509 |
<a href="https://github.com/zama-ai/concrete-ml"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/github.png">Concrete-ML</a>
|
| 510 |
—
|
| 511 |
<a href="https://docs.zama.ai/concrete-ml"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/documentation.png">Documentation</a>
|
|
|
|
| 513 |
<a href=" https://community.zama.ai/c/concrete-ml/8"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/community.png">Community</a>
|
| 514 |
—
|
| 515 |
<a href="https://twitter.com/zama_fhe"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/x.png">@zama_fhe</a>
|
| 516 |
+
</p> -->
|
|
|
|
| 517 |
"""
|
| 518 |
)
|
| 519 |
+
|
| 520 |
gr.Markdown(
|
| 521 |
+
"""
|
| 522 |
+
<p align="center" style="font-size: 16px;">
|
| 523 |
+
Anonymization makes it impossible to identify a person from a data set and thus allows their privacy to be respected </p> Concealing some of PII information is a helpful technique for de-identification. However, this can't be considered as anonymization.
|
| 524 |
+
<p align="center" style="font-size: 16px;">
|
| 525 |
+
De-identification uses Fully Homomorphic Encryption (FHE) to conceal personally
|
| 526 |
+
identifiable information (PII) within encrypted documents, enabling computations to be
|
| 527 |
+
performed on the encrypted data.</p>
|
|
|
|
| 528 |
|
| 529 |
+
"""
|
| 530 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 531 |
|
| 532 |
# Step 1: Add an audio file
|
| 533 |
gr.Markdown("## Step 1: Add an Audio File")
|
|
|
|
| 613 |
outputs=[gen_key_btn],
|
| 614 |
)
|
| 615 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 616 |
########################## User Query Part ##########################
|
| 617 |
|
| 618 |
gr.Markdown("<hr />")
|
|
|
|
| 656 |
########################## FHE processing Part ##########################
|
| 657 |
|
| 658 |
gr.Markdown("<hr />")
|
| 659 |
+
gr.Markdown("## Step 3: De-identify the prompt using FHE")
|
| 660 |
gr.Markdown(
|
| 661 |
"""Once the client encrypts the document and the prompt locally, it will be sent to a remote
|
| 662 |
server to perform the de-identification on encrypted data. When the computation is done, the
|
|
|
|
| 667 |
run_fhe_btn = gr.Button("De-identify using FHE")
|
| 668 |
|
| 669 |
with gr.Row():
|
| 670 |
+
#with gr.Column(scale=5):
|
| 671 |
+
#
|
| 672 |
+
# anonymized_doc_output = gr.Textbox(
|
| 673 |
+
# label="Decrypted and de-idenntified document", lines=10, interactive=True
|
| 674 |
+
# )
|
| 675 |
|
| 676 |
with gr.Column(scale=5):
|
| 677 |
|
|
|
|
| 682 |
|
| 683 |
identified_words_output_df = gr.Dataframe(label="Identified words:", visible=False)
|
| 684 |
|
| 685 |
+
#encrypt_doc_btn.click(
|
| 686 |
+
# fn=encrypt_doc_fn,
|
| 687 |
+
# inputs=[original_sentences_box],
|
| 688 |
+
# outputs=[encrypted_doc_box, anonymized_doc_output],
|
| 689 |
+
#)
|
| 690 |
|
| 691 |
encrypt_query_btn.click(
|
| 692 |
fn=encrypt_query_fn,
|
|
|
|
| 701 |
|
| 702 |
run_fhe_btn.click(
|
| 703 |
anonymization_with_fn,
|
| 704 |
+
inputs=[query_box],
|
| 705 |
+
outputs=[anonymized_query_output, identified_words_output_df],
|
| 706 |
)
|
| 707 |
|
| 708 |
|