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

Encrypted Anonymization Using Fully Homomorphic Encryption

Concrete-ML Documentation Community @zama_fhe

""" ) 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( """

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