mzameshina commited on
Commit
1238607
1 Parent(s): 4681155

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -63
app.py CHANGED
@@ -709,82 +709,21 @@ with demo:
709
  gr.Markdown(
710
  """This step will demonstrate de-identification using both FHE and Presidio methods.
711
  The same prompt will be used for both to allow for direct comparison."""
712
- )
713
-
714
  with gr.Row():
715
- with gr.Column(scale=1, min_width=6):
716
- run_fhe_btn = gr.Button("De-identify using FHE")
717
- with gr.Column(scale=1, min_width=6):
718
- run_presidio_btn = gr.Button("De-identify using Presidio")
719
- with gr.Column(scale=1, min_width=6):
720
- run_both_btn = gr.Button("Run Both De-identification Methods")
721
-
722
- with gr.Row():
723
- with gr.Column(scale=5):
724
- anonymized_doc_output = gr.Textbox(
725
- label="FHE: Decrypted and de-identified document", lines=10, interactive=True
726
- )
727
-
728
- with gr.Column(scale=5):
729
- anonymized_query_output = gr.Textbox(
730
- label="FHE: Decrypted and de-identified prompt", lines=10, interactive=True
731
- )
732
 
733
  with gr.Row():
734
  presidio_output = gr.Textbox(
735
  label="Presidio: De-identified prompt", lines=10, interactive=True
736
  )
737
 
738
- identified_words_output_df = gr.Dataframe(label="FHE: Identified words:", visible=False)
739
-
740
- encrypt_doc_btn.click(
741
- fn=encrypt_doc_fn,
742
- inputs=[original_sentences_box],
743
- outputs=[encrypted_doc_box, anonymized_doc_output],
744
- )
745
-
746
- encrypt_query_btn.click(
747
- fn=encrypt_query_fn,
748
- inputs=[query_box],
749
- outputs=[
750
- query_box,
751
- output_encrypted_box,
752
- anonymized_query_output,
753
- identified_words_output_df,
754
- ],
755
- )
756
-
757
- run_fhe_btn.click(
758
- anonymization_with_fn,
759
- inputs=[original_sentences_box, query_box],
760
- outputs=[anonymized_doc_output, anonymized_query_output, identified_words_output_df],
761
- )
762
-
763
  run_presidio_btn.click(
764
  anonymization_with_presidio,
765
  inputs=[query_box],
766
  outputs=[presidio_output],
767
  )
768
 
769
- def run_both_deidentification(selected_sentences, query):
770
- # Run FHE de-identification
771
- fhe_results = anonymization_with_fn(selected_sentences, query)
772
-
773
- # Run Presidio de-identification
774
- presidio_result = anonymization_with_presidio(query)
775
-
776
- # Combine results
777
- return {
778
- **fhe_results,
779
- 'presidio_output': gr.update(value=presidio_result)
780
- }
781
-
782
- run_both_btn.click(
783
- run_both_deidentification,
784
- inputs=[original_sentences_box, query_box],
785
- outputs=[anonymized_doc_output, anonymized_query_output, identified_words_output_df, presidio_output],
786
- )
787
-
788
 
789
  # Launch the app
790
  demo.launch(share=False)
 
709
  gr.Markdown(
710
  """This step will demonstrate de-identification using both FHE and Presidio methods.
711
  The same prompt will be used for both to allow for direct comparison."""
712
+
 
713
  with gr.Row():
714
+ run_presidio_btn = gr.Button("De-identify using Presidio")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
715
 
716
  with gr.Row():
717
  presidio_output = gr.Textbox(
718
  label="Presidio: De-identified prompt", lines=10, interactive=True
719
  )
720
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
721
  run_presidio_btn.click(
722
  anonymization_with_presidio,
723
  inputs=[query_box],
724
  outputs=[presidio_output],
725
  )
726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
727
 
728
  # Launch the app
729
  demo.launch(share=False)