Spaces:
Building
on
CPU Upgrade
Building
on
CPU Upgrade
fix: remove concrete again
Browse files
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 |
-
|
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 |
-
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 |
|