Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -504,8 +504,9 @@ with demo:
|
|
| 504 |
|
| 505 |
gr.Markdown(
|
| 506 |
"""
|
| 507 |
-
<h1 style="text-align: center;">
|
| 508 |
-
<!--
|
|
|
|
| 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,21 +514,27 @@ with demo:
|
|
| 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 |
-
|
| 523 |
-
|
| 524 |
-
|
| 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,6 +620,34 @@ with demo:
|
|
| 613 |
outputs=[gen_key_btn],
|
| 614 |
)
|
| 615 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 616 |
########################## User Query Part ##########################
|
| 617 |
|
| 618 |
gr.Markdown("<hr />")
|
|
@@ -656,7 +691,7 @@ with demo:
|
|
| 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,11 +702,11 @@ with demo:
|
|
| 667 |
run_fhe_btn = gr.Button("De-identify using FHE")
|
| 668 |
|
| 669 |
with gr.Row():
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
|
| 676 |
with gr.Column(scale=5):
|
| 677 |
|
|
@@ -682,11 +717,11 @@ with demo:
|
|
| 682 |
|
| 683 |
identified_words_output_df = gr.Dataframe(label="Identified words:", visible=False)
|
| 684 |
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
|
| 691 |
encrypt_query_btn.click(
|
| 692 |
fn=encrypt_query_fn,
|
|
@@ -701,8 +736,8 @@ with demo:
|
|
| 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 |
|
|
|
|
| 504 |
|
| 505 |
gr.Markdown(
|
| 506 |
"""
|
| 507 |
+
<h1 style="text-align: center;">Secure De-Identification of Audio Files</h1>
|
| 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 |
<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 |
+
<p align="center" style="font-size: 18px;">
|
| 525 |
+
Protecting personal data is more important than ever in today’s digital world. <b>Our project ensures privacy-preserving de-identification of audio data</b> using state-of-the-art <b>Fully Homomorphic Encryption (FHE)</b>, offering a secure and transparent solution for data anonymization.
|
| 526 |
+
</p>
|
|
|
|
|
|
|
|
|
|
| 527 |
|
| 528 |
+
<p align="center" style="font-size: 18px;">
|
| 529 |
+
Traditional methods of de-identification often fall short of true anonymization, merely concealing identifiable information. With FHE, we go beyond obfuscation to provide <b>complete security,</b> allowing computations to be performed directly on encrypted data without ever exposing sensitive details.
|
| 530 |
+
</p>
|
| 531 |
+
|
| 532 |
+
<p align="center" style="font-size: 18px;">
|
| 533 |
+
This technology is crucial in enabling organizations to use and share sensitive data responsibly, while fully respecting individual privacy.
|
| 534 |
+
</p>
|
| 535 |
+
"""
|
| 536 |
+
)
|
| 537 |
+
|
| 538 |
|
| 539 |
# Step 1: Add an audio file
|
| 540 |
gr.Markdown("## Step 1: Add an Audio File")
|
|
|
|
| 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 |
########################## FHE processing Part ##########################
|
| 692 |
|
| 693 |
gr.Markdown("<hr />")
|
| 694 |
+
gr.Markdown("## Step 3: De-identify the document and the prompt using FHE")
|
| 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 |
run_fhe_btn = gr.Button("De-identify using FHE")
|
| 703 |
|
| 704 |
with gr.Row():
|
| 705 |
+
with gr.Column(scale=5):
|
| 706 |
+
|
| 707 |
+
anonymized_doc_output = gr.Textbox(
|
| 708 |
+
label="Decrypted and de-idenntified document", lines=10, interactive=True
|
| 709 |
+
)
|
| 710 |
|
| 711 |
with gr.Column(scale=5):
|
| 712 |
|
|
|
|
| 717 |
|
| 718 |
identified_words_output_df = gr.Dataframe(label="Identified words:", visible=False)
|
| 719 |
|
| 720 |
+
encrypt_doc_btn.click(
|
| 721 |
+
fn=encrypt_doc_fn,
|
| 722 |
+
inputs=[original_sentences_box],
|
| 723 |
+
outputs=[encrypted_doc_box, anonymized_doc_output],
|
| 724 |
+
)
|
| 725 |
|
| 726 |
encrypt_query_btn.click(
|
| 727 |
fn=encrypt_query_fn,
|
|
|
|
| 736 |
|
| 737 |
run_fhe_btn.click(
|
| 738 |
anonymization_with_fn,
|
| 739 |
+
inputs=[original_sentences_box, query_box],
|
| 740 |
+
outputs=[anonymized_doc_output, anonymized_query_output, identified_words_output_df],
|
| 741 |
)
|
| 742 |
|
| 743 |
|