kcelia commited on
Commit
49a1dd4
1 Parent(s): 27b2094

chore: add gitignore

Browse files
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ __pycache__/
2
+ .ipynb_checkpoints
app.py CHANGED
@@ -4,18 +4,15 @@ from typing import Dict, List, Tuple
4
 
5
  import gradio as gr
6
  import numpy as np
7
- import pandas as pd
8
  import requests
9
  from symptoms_categories import SYMPTOMS_LIST
10
- from utils import ( # pylint: disable=no-name-in-module
11
  CLIENT_DIR,
12
  CURRENT_DIR,
13
  DEPLOYMENT_DIR,
14
  INPUT_BROWSER_LIMIT,
15
  KEYS_DIR,
16
  SERVER_URL,
17
- TARGET_COLUMNS,
18
- TRAINING_FILENAME,
19
  clean_directory,
20
  get_disease_name,
21
  load_data,
@@ -116,6 +113,7 @@ def get_features_fn(*checked_symptoms: Tuple[str]) -> Dict:
116
  return {
117
  error_box1: gr.update(visible=False),
118
  user_vect_box1: get_user_symptoms_from_checkboxgroup(pretty_print(checked_symptoms)),
 
119
  }
120
 
121
 
@@ -270,7 +268,9 @@ def send_input_fn(user_id: str, user_symptoms: np.ndarray) -> Dict:
270
  files=files,
271
  ) as response:
272
  print(f"Sending Data: {response.ok=}")
273
- return {error_box4: gr.update(visible=False), srv_resp_send_data_box: "Data sent"}
 
 
274
 
275
 
276
  def run_fhe_fn(user_id: str) -> Dict:
@@ -311,6 +311,7 @@ def run_fhe_fn(user_id: str) -> Dict:
311
  return {
312
  error_box5: gr.update(visible=False),
313
  fhe_execution_time_box: gr.update(value=f"{response.json()} seconds"),
 
314
  }
315
 
316
 
@@ -406,7 +407,7 @@ def decrypt_fn(user_id: str, user_symptoms: np.ndarray) -> Dict:
406
  }
407
 
408
 
409
- def clear_all_btn():
410
  """Clear all the box outputs."""
411
 
412
  clean_directory()
@@ -429,6 +430,9 @@ def clear_all_btn():
429
  error_box4: gr.update(visible=False),
430
  error_box5: gr.update(visible=False),
431
  error_box6: gr.update(visible=False),
 
 
 
432
  srv_resp_send_data_box: None,
433
  srv_resp_retrieve_data_box: None,
434
  **{box: None for box in check_boxes},
@@ -441,6 +445,7 @@ CSS = """
441
  #them {font-weight: bold}
442
  .gradio-container {background-color: white}
443
  .feedback {font-size: 3px !important}
 
444
  /* #them {text-align: center} */
445
  """
446
 
@@ -495,12 +500,13 @@ if __name__ == "__main__":
495
  check_boxes = []
496
  for i, category in enumerate(SYMPTOMS_LIST):
497
  with gr.Accordion(
498
- pretty_print(category.keys()), open=False, elem_classes="feedback"
 
 
499
  ) as accordion:
500
  check_box = gr.CheckboxGroup(
501
  pretty_print(category.values()),
502
- label=pretty_print(category.keys()),
503
- info=f"Symptoms related to `{pretty_print(category.values())}`",
504
  )
505
  check_boxes.append(check_box)
506
 
@@ -521,14 +527,21 @@ if __name__ == "__main__":
521
  # Submit botton
522
  submit_button = gr.Button("Submit")
523
 
524
- with gr.Row():
525
- # Clear botton
526
- clear_button = gr.Button("Reset")
 
 
 
 
 
 
 
527
 
528
  submit_button.click(
529
  fn=get_features_fn,
530
  inputs=[*check_boxes],
531
- outputs=[user_vect_box1, error_box1],
532
  )
533
 
534
  with gr.TabItem("2. Data Encryption") as encryption_tab:
@@ -610,14 +623,22 @@ if __name__ == "__main__":
610
  label="Data Sent", show_label=False, interactive=False
611
  )
612
 
 
 
 
 
 
 
 
 
613
  send_input_btn.click(
614
  send_input_fn,
615
  inputs=[user_id_box, user_vect_box1],
616
- outputs=[error_box4, srv_resp_send_data_box],
617
  )
618
 
619
  with gr.TabItem("3. FHE execution") as fhe_tab:
620
- gr.Markdown("<span style='color:orange'>Client Side</span>")
621
  gr.Markdown("## Step 5: Run the FHE evaluation")
622
 
623
  run_fhe_btn = gr.Button("Run the FHE evaluation")
@@ -626,16 +647,21 @@ if __name__ == "__main__":
626
  label="Total FHE Execution Time:", interactive=False
627
  )
628
 
 
 
 
 
 
 
 
629
  run_fhe_btn.click(
630
  run_fhe_fn,
631
  inputs=[user_id_box],
632
- outputs=[fhe_execution_time_box, error_box5],
633
  )
634
 
635
  with gr.TabItem("4. Data Decryption") as decryption_tab:
636
-
637
  gr.Markdown("<span style='color:orange'>Client Side</span>")
638
-
639
  gr.Markdown(
640
  "## Step 6: Get the data from the <span style='color:orange'>Server Side</span>"
641
  )
@@ -669,8 +695,11 @@ if __name__ == "__main__":
669
  )
670
 
671
  clear_button.click(
672
- clear_all_btn,
673
  outputs=[
 
 
 
674
  user_vect_box1,
675
  user_vect_box2,
676
  # disease_box,
 
4
 
5
  import gradio as gr
6
  import numpy as np
 
7
  import requests
8
  from symptoms_categories import SYMPTOMS_LIST
9
+ from utils import (
10
  CLIENT_DIR,
11
  CURRENT_DIR,
12
  DEPLOYMENT_DIR,
13
  INPUT_BROWSER_LIMIT,
14
  KEYS_DIR,
15
  SERVER_URL,
 
 
16
  clean_directory,
17
  get_disease_name,
18
  load_data,
 
113
  return {
114
  error_box1: gr.update(visible=False),
115
  user_vect_box1: get_user_symptoms_from_checkboxgroup(pretty_print(checked_symptoms)),
116
+ next_step_tab2: gr.update(visible=True),
117
  }
118
 
119
 
 
268
  files=files,
269
  ) as response:
270
  print(f"Sending Data: {response.ok=}")
271
+ return {error_box4: gr.update(visible=False),
272
+
273
+ next_step_tab3: gr.update(visible=True),srv_resp_send_data_box: "Data sent",}
274
 
275
 
276
  def run_fhe_fn(user_id: str) -> Dict:
 
311
  return {
312
  error_box5: gr.update(visible=False),
313
  fhe_execution_time_box: gr.update(value=f"{response.json()} seconds"),
314
+ next_step_tab4: gr.update(visible=True)
315
  }
316
 
317
 
 
407
  }
408
 
409
 
410
+ def reset_fn():
411
  """Clear all the box outputs."""
412
 
413
  clean_directory()
 
430
  error_box4: gr.update(visible=False),
431
  error_box5: gr.update(visible=False),
432
  error_box6: gr.update(visible=False),
433
+ next_step_tab2: gr.update(visible=False),
434
+ next_step_tab3: gr.update(visible=False),
435
+ next_step_tab4: gr.update(visible=False),
436
  srv_resp_send_data_box: None,
437
  srv_resp_retrieve_data_box: None,
438
  **{box: None for box in check_boxes},
 
445
  #them {font-weight: bold}
446
  .gradio-container {background-color: white}
447
  .feedback {font-size: 3px !important}
448
+ /* .svelte-s1r2yt {color: orange; font-size: 25px, font-weight: bold;} */
449
  /* #them {text-align: center} */
450
  """
451
 
 
500
  check_boxes = []
501
  for i, category in enumerate(SYMPTOMS_LIST):
502
  with gr.Accordion(
503
+ pretty_print(category.keys()),
504
+ open=False,
505
+ elem_classes="feedback",
506
  ) as accordion:
507
  check_box = gr.CheckboxGroup(
508
  pretty_print(category.values()),
509
+ show_label=False,
 
510
  )
511
  check_boxes.append(check_box)
512
 
 
527
  # Submit botton
528
  submit_button = gr.Button("Submit")
529
 
530
+ # Clear botton
531
+ clear_button = gr.Button("Reset Space")
532
+
533
+ next_step_tab2 = gr.Markdown(
534
+ """
535
+ <p align="center">
536
+ <img width="80%" height="20%" src="https://raw.githubusercontent.com/kcelia/Img/main/Go-To-Step2.png">
537
+ </p>
538
+ """, visible=False
539
+ )
540
 
541
  submit_button.click(
542
  fn=get_features_fn,
543
  inputs=[*check_boxes],
544
+ outputs=[user_vect_box1, error_box1, next_step_tab2],
545
  )
546
 
547
  with gr.TabItem("2. Data Encryption") as encryption_tab:
 
623
  label="Data Sent", show_label=False, interactive=False
624
  )
625
 
626
+ next_step_tab3 = gr.Markdown(
627
+ """
628
+ <p align="center">
629
+ <img width="80%" height="20%" src="https://raw.githubusercontent.com/kcelia/Img/main/Go-To-Step3.png">
630
+ </p>
631
+ """, visible=False
632
+ )
633
+
634
  send_input_btn.click(
635
  send_input_fn,
636
  inputs=[user_id_box, user_vect_box1],
637
+ outputs=[error_box4, srv_resp_send_data_box, next_step_tab3],
638
  )
639
 
640
  with gr.TabItem("3. FHE execution") as fhe_tab:
641
+ gr.Markdown("<span style='color:orange'>Server Side</span>")
642
  gr.Markdown("## Step 5: Run the FHE evaluation")
643
 
644
  run_fhe_btn = gr.Button("Run the FHE evaluation")
 
647
  label="Total FHE Execution Time:", interactive=False
648
  )
649
 
650
+ next_step_tab4 = gr.Markdown(
651
+ """
652
+ <p align="center">
653
+ <img width="80%" height="20%" src="https://raw.githubusercontent.com/kcelia/Img/main/Go-to-Step4.png">
654
+ </p>
655
+ """, visible=False
656
+ )
657
  run_fhe_btn.click(
658
  run_fhe_fn,
659
  inputs=[user_id_box],
660
+ outputs=[fhe_execution_time_box, error_box5, next_step_tab4],
661
  )
662
 
663
  with gr.TabItem("4. Data Decryption") as decryption_tab:
 
664
  gr.Markdown("<span style='color:orange'>Client Side</span>")
 
665
  gr.Markdown(
666
  "## Step 6: Get the data from the <span style='color:orange'>Server Side</span>"
667
  )
 
695
  )
696
 
697
  clear_button.click(
698
+ reset_fn,
699
  outputs=[
700
+ next_step_tab2,
701
+ next_step_tab3,
702
+ next_step_tab4,
703
  user_vect_box1,
704
  user_vect_box2,
705
  # disease_box,
deployment/client.zip ADDED
Binary file (89.7 kB). View file
 
deployment/server.zip ADDED
Binary file (1.59 kB). View file
 
deployment/versions.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"concrete-ml": "1.0.3", "concrete-python": "1.0.0", "python": "3.10.6"}
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
  concrete-ml==1.0.3
2
- gradio==3.11.0
3
  uvicorn>=0.21.0
4
  fastapi>=0.93.0
 
1
  concrete-ml==1.0.3
2
+ gradio==3.35.2
3
  uvicorn>=0.21.0
4
  fastapi>=0.93.0
server.py CHANGED
@@ -32,7 +32,7 @@ def send_input(
32
  """Send the inputs to the server."""
33
 
34
  print("\nSend the data to the server ............\n")
35
-
36
  # Receive the Client's files (Evaluation key + Encrypted symptoms)
37
  evaluation_key_path = SERVER_DIR / f"{user_id}_valuation_key"
38
  encrypted_input_path = SERVER_DIR / f"{user_id}_encrypted_input"
@@ -86,7 +86,7 @@ def get_output(user_id: str = Form()):
86
  """Retrieve the encrypted output from the server."""
87
 
88
  print("\nGet the output from the server ............\n")
89
-
90
  # Path where the encrypted output is saved
91
  encrypted_output_path = SERVER_DIR / f"{user_id}_encrypted_output"
92
 
 
32
  """Send the inputs to the server."""
33
 
34
  print("\nSend the data to the server ............\n")
35
+
36
  # Receive the Client's files (Evaluation key + Encrypted symptoms)
37
  evaluation_key_path = SERVER_DIR / f"{user_id}_valuation_key"
38
  encrypted_input_path = SERVER_DIR / f"{user_id}_encrypted_input"
 
86
  """Retrieve the encrypted output from the server."""
87
 
88
  print("\nGet the output from the server ............\n")
89
+
90
  # Path where the encrypted output is saved
91
  encrypted_output_path = SERVER_DIR / f"{user_id}_encrypted_output"
92