TomSmail commited on
Commit
8c94b6d
·
1 Parent(s): 941e858

fix: remove concrete again

Browse files
Files changed (1) hide show
  1. app.py +31 -33
app.py CHANGED
@@ -1,5 +1,3 @@
1
-
2
- from concrete.ml.deployment import FHEModelClient
3
  from pathlib import Path
4
  import numpy as np
5
  import gradio as gr
@@ -60,42 +58,42 @@ functional_status_input = gr.Radio(choices=additional_categories["Functional_Sta
60
  previous_trial_participation_input = gr.Radio(choices=additional_categories["Previous_Trial_Participation"], label="Previous Trial Participation")
61
 
62
 
63
- def encrypt_array(user_symptoms: np.ndarray, user_id: str) -> bytes:
64
- """
65
- Encrypt the user symptoms vector.
66
 
67
- Args:
68
- user_symptoms (np.ndarray): The vector of symptoms provided by the user.
69
- user_id (str): The current user's ID.
70
 
71
- Returns:
72
- bytes: Encrypted and serialized symptoms.
73
- """
74
 
75
- # Retrieve the client API
76
- client = FHEModelClient(path_dir=DEPLOYMENT_DIR, key_dir=KEYS_DIR / f"{user_id}")
77
- client.load()
78
 
79
- # Ensure the symptoms are properly formatted as an array
80
- user_symptoms = np.array(user_symptoms).reshape(1, -1)
81
 
82
- # Encrypt and serialize the symptoms
83
- encrypted_quantized_user_symptoms = client.quantize_encrypt_serialize(user_symptoms)
84
 
85
- # Ensure the encryption process returned bytes
86
- assert isinstance(encrypted_quantized_user_symptoms, bytes)
87
 
88
- # Save the encrypted data to a file (optional)
89
- encrypted_input_path = KEYS_DIR / f"{user_id}/encrypted_input"
90
- with encrypted_input_path.open("wb") as f:
91
- f.write(encrypted_quantized_user_symptoms)
92
 
93
- # Return the encrypted data
94
- return encrypted_quantized_user_symptoms
95
 
96
 
97
- def decrypt_result(encrypted_answer: bytes, user_id: str) -> bool:
98
- """
99
  Decrypt the encrypted result.
100
 
101
  Args:
@@ -107,14 +105,14 @@ def decrypt_result(encrypted_answer: bytes, user_id: str) -> bool:
107
  """
108
 
109
  # Retrieve the client API
110
- client = FHEModelClient(path_dir=DEPLOYMENT_DIR, key_dir=KEYS_DIR / f"{user_id}")
111
- client.load()
112
 
113
  # Decrypt the result
114
- decrypted_result = client.decrypt_deserialize(encrypted_answer)
115
 
116
- # Return the decrypted result
117
- return decrypted_result
118
 
119
 
120
 
 
 
 
1
  from pathlib import Path
2
  import numpy as np
3
  import gradio as gr
 
58
  previous_trial_participation_input = gr.Radio(choices=additional_categories["Previous_Trial_Participation"], label="Previous Trial Participation")
59
 
60
 
61
+ # def encrypt_array(user_symptoms: np.ndarray, user_id: str) -> bytes:
62
+ # """
63
+ # Encrypt the user symptoms vector.
64
 
65
+ # Args:
66
+ # user_symptoms (np.ndarray): The vector of symptoms provided by the user.
67
+ # user_id (str): The current user's ID.
68
 
69
+ # Returns:
70
+ # bytes: Encrypted and serialized symptoms.
71
+ # """
72
 
73
+ # # Retrieve the client API
74
+ # client = FHEModelClient(path_dir=DEPLOYMENT_DIR, key_dir=KEYS_DIR / f"{user_id}")
75
+ # client.load()
76
 
77
+ # # Ensure the symptoms are properly formatted as an array
78
+ # user_symptoms = np.array(user_symptoms).reshape(1, -1)
79
 
80
+ # # Encrypt and serialize the symptoms
81
+ # encrypted_quantized_user_symptoms = client.quantize_encrypt_serialize(user_symptoms)
82
 
83
+ # # Ensure the encryption process returned bytes
84
+ # assert isinstance(encrypted_quantized_user_symptoms, bytes)
85
 
86
+ # # Save the encrypted data to a file (optional)
87
+ # encrypted_input_path = KEYS_DIR / f"{user_id}/encrypted_input"
88
+ # with encrypted_input_path.open("wb") as f:
89
+ # f.write(encrypted_quantized_user_symptoms)
90
 
91
+ # # Return the encrypted data
92
+ # return encrypted_quantized_user_symptoms
93
 
94
 
95
+ # def decrypt_result(encrypted_answer: bytes, user_id: str) -> bool:
96
+ """
97
  Decrypt the encrypted result.
98
 
99
  Args:
 
105
  """
106
 
107
  # Retrieve the client API
108
+ # client = FHEModelClient(path_dir=DEPLOYMENT_DIR, key_dir=KEYS_DIR / f"{user_id}")
109
+ # client.load()
110
 
111
  # Decrypt the result
112
+ # decrypted_result = client.decrypt_deserialize(encrypted_answer)
113
 
114
+ # # Return the decrypted result
115
+ # return decrypted_result
116
 
117
 
118