Spaces:
Sleeping
Sleeping
Update backend.py
Browse files- backend.py +10 -10
backend.py
CHANGED
@@ -32,8 +32,8 @@ from settings import (
|
|
32 |
from utils.client_server_interface import MultiInputsFHEModelClient
|
33 |
|
34 |
# Define the messages associated to the predictions
|
35 |
-
APPROVED_MESSAGE = "
|
36 |
-
DENIED_MESSAGE = "
|
37 |
|
38 |
# Load pre-processor instances
|
39 |
with (
|
@@ -199,7 +199,7 @@ def keygen_send():
|
|
199 |
# Create a truncated version of the evaluation key for display
|
200 |
evaluation_key_short = shorten_bytes_object(evaluation_key)
|
201 |
|
202 |
-
return client_id, evaluation_key_short, gr.update(value="
|
203 |
|
204 |
|
205 |
def _encrypt_send(client_id, inputs, client_type):
|
@@ -242,7 +242,7 @@ def _encrypt_send(client_id, inputs, client_type):
|
|
242 |
|
243 |
_send_to_server(client_id, client_type, file_name)
|
244 |
|
245 |
-
return encrypted_inputs_short, gr.update(value="
|
246 |
|
247 |
|
248 |
def pre_process_encrypt_send_applicant(client_id, *inputs):
|
@@ -355,9 +355,9 @@ def run_fhe(client_id):
|
|
355 |
data=data,
|
356 |
) as response:
|
357 |
if response.ok:
|
358 |
-
return response.json(), gr.update(value="FHE
|
359 |
else:
|
360 |
-
raise gr.Error("
|
361 |
|
362 |
|
363 |
def get_output_and_decrypt(client_id):
|
@@ -402,11 +402,11 @@ def get_output_and_decrypt(client_id):
|
|
402 |
return (
|
403 |
APPROVED_MESSAGE if output == 1 else DENIED_MESSAGE,
|
404 |
encrypted_output_short,
|
405 |
-
gr.update(value="
|
406 |
)
|
407 |
|
408 |
else:
|
409 |
-
raise gr.Error("
|
410 |
|
411 |
|
412 |
def explain_encrypt_run_decrypt(client_id, prediction_output, *inputs):
|
@@ -425,10 +425,10 @@ def explain_encrypt_run_decrypt(client_id, prediction_output, *inputs):
|
|
425 |
|
426 |
if "approved" in prediction_output:
|
427 |
raise gr.Error(
|
428 |
-
"
|
429 |
)
|
430 |
|
431 |
-
button_update = gr.update(value="
|
432 |
|
433 |
# Retrieve the credit bureau inputs
|
434 |
years_employed, employed = inputs
|
|
|
32 |
from utils.client_server_interface import MultiInputsFHEModelClient
|
33 |
|
34 |
# Define the messages associated to the predictions
|
35 |
+
APPROVED_MESSAGE = "信用卡申请可以批准 ✅"
|
36 |
+
DENIED_MESSAGE = "信用卡申请可能被拒绝 ❌"
|
37 |
|
38 |
# Load pre-processor instances
|
39 |
with (
|
|
|
199 |
# Create a truncated version of the evaluation key for display
|
200 |
evaluation_key_short = shorten_bytes_object(evaluation_key)
|
201 |
|
202 |
+
return client_id, evaluation_key_short, gr.update(value="密钥已生成并且计算密钥已发送✅")
|
203 |
|
204 |
|
205 |
def _encrypt_send(client_id, inputs, client_type):
|
|
|
242 |
|
243 |
_send_to_server(client_id, client_type, file_name)
|
244 |
|
245 |
+
return encrypted_inputs_short, gr.update(value="输入被加密发送到服务器。 ✅")
|
246 |
|
247 |
|
248 |
def pre_process_encrypt_send_applicant(client_id, *inputs):
|
|
|
355 |
data=data,
|
356 |
) as response:
|
357 |
if response.ok:
|
358 |
+
return response.json(), gr.update(value="FHE计算已完成。 ✅")
|
359 |
else:
|
360 |
+
raise gr.Error("三个单位的输入都要先发送到服务器。")
|
361 |
|
362 |
|
363 |
def get_output_and_decrypt(client_id):
|
|
|
402 |
return (
|
403 |
APPROVED_MESSAGE if output == 1 else DENIED_MESSAGE,
|
404 |
encrypted_output_short,
|
405 |
+
gr.update(value="已从服务器接收加密输出。 ✅"),
|
406 |
)
|
407 |
|
408 |
else:
|
409 |
+
raise gr.Error("请先运行FHE计算并等待其完成。")
|
410 |
|
411 |
|
412 |
def explain_encrypt_run_decrypt(client_id, prediction_output, *inputs):
|
|
|
425 |
|
426 |
if "approved" in prediction_output:
|
427 |
raise gr.Error(
|
428 |
+
"仅当信用卡可能被拒绝时才能解释该预测。"
|
429 |
)
|
430 |
|
431 |
+
button_update = gr.update(value="预测已经得到解释。 ✅")
|
432 |
|
433 |
# Retrieve the credit bureau inputs
|
434 |
years_employed, employed = inputs
|