File size: 4,542 Bytes
646bd9e
 
 
 
 
 
 
 
 
 
 
 
2b591f4
 
 
 
 
 
 
646bd9e
2b591f4
646bd9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b591f4
 
 
 
 
 
646bd9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b591f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"""A Gradio app for anonymizing text data using FHE."""

import gradio as gr
import re
from fhe_anonymizer import FHEAnonymizer
import pandas as pd


anonymizer = FHEAnonymizer()


def deidentify_text(input_text):
    anonymized_text, identified_words_with_prob = anonymizer(input_text)

    # Convert the list of identified words and probabilities into a DataFrame
    if identified_words_with_prob:
        identified_df = pd.DataFrame(
            identified_words_with_prob, columns=["Identified Words", "Probability"]
        )
    else:
        identified_df = pd.DataFrame(columns=["Identified Words", "Probability"])
    return anonymized_text, identified_df


# Default demo text from the file
with open("demo_text.txt", "r") as file:
    default_demo_text = file.read()

demo = gr.Blocks()

with demo:
    gr.Markdown(
        """
        <p align="center">
            <img width=200 src="file/images/logos/zama.jpg">
        </p>
        <h1 style="text-align: center;">Encrypted Anonymization Using Fully Homomorphic Encryption</h1>
        <p align="center">
            <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>

            <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>

            <a href="https://zama.ai/community"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/community.png">Community</a>

            <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>
        </p>
        """
    )

    with gr.Accordion("What is Encrypted Anonymization?", open=False):
        gr.Markdown(
            """
            Encrypted Anonymization leverages Fully Homomorphic Encryption (FHE) to protect sensitive information during data processing. This approach allows for the anonymization of text data, such as personal identifiers, while ensuring that the data remains encrypted throughout the entire process. It enables organizations to utilize sensitive data for analytics and machine learning without compromising individual privacy or security.
            """
        )

    with gr.Accordion("Why is privacy important in data processing?", open=False):
        gr.Markdown(
            """
            Privacy in data processing is critical to protect individuals' personal information from unauthorized access and potential misuse. With the increasing amount of personal data being collected and analyzed, the risks associated with data breaches and identity theft have also risen. By implementing privacy-preserving techniques, such as encrypted anonymization, organizations can safeguard sensitive information, build trust with their customers, and comply with stringent data protection regulations.
            """
        )

    with gr.Accordion(
        "How does Fully Homomorphic Encryption enhance data privacy?", open=False
    ):
        gr.Markdown(
            """
            Fully Homomorphic Encryption (FHE) enhances data privacy by enabling computations on encrypted data without needing to decrypt it first. This revolutionary technology ensures that sensitive data can be processed and analyzed securely, without exposing it to potential threats. FHE is a game-changer for privacy-preserving computations, allowing for the secure analysis of encrypted data, which is particularly beneficial in sectors like finance, healthcare, and beyond.
            """
        )

    gr.Markdown(
        """
        <p align="center">
            <img src="file/images/banner.png">
        </p>
        """
    )

    with gr.Row():
        input_text = gr.Textbox(
            value=default_demo_text,
            lines=13,
            placeholder="Input text here...",
            label="Input",
        )

        anonymized_text_output = gr.Textbox(label="Anonymized Text", lines=13)

    identified_words_output = gr.Dataframe(label="Identified Words")

    submit_button = gr.Button("Anonymize")

    submit_button.click(
        deidentify_text,
        inputs=[input_text],
        outputs=[anonymized_text_output, identified_words_output],
    )


# Launch the app
demo.launch(share=False)