romanbredehoft-zama
commited on
Commit
•
0a14c46
1
Parent(s):
8e0d56d
Improve app display
Browse files
app.py
CHANGED
@@ -61,9 +61,9 @@ with demo:
|
|
61 |
"""
|
62 |
)
|
63 |
|
64 |
-
gr.Markdown("# Applicant, Bank and Credit bureau setup")
|
65 |
-
|
66 |
gr.Markdown("## Step 1: Generate the keys.")
|
|
|
|
|
67 |
gr.Markdown(
|
68 |
"""
|
69 |
- The private key is generated jointly by the entities that collaborate to compute the
|
@@ -86,6 +86,8 @@ with demo:
|
|
86 |
)
|
87 |
|
88 |
gr.Markdown("## Step 2: Fill in some information.")
|
|
|
|
|
89 |
gr.Markdown(
|
90 |
"""
|
91 |
Select the information that corresponds to the profile you want to evaluate. Three sources
|
@@ -104,7 +106,7 @@ with demo:
|
|
104 |
|
105 |
with gr.Row():
|
106 |
with gr.Column():
|
107 |
-
gr.Markdown("### Applicant information")
|
108 |
bool_inputs = gr.CheckboxGroup(
|
109 |
["Car", "Property", "Mobile phone"],
|
110 |
label="Which of the following do you actively hold or own?"
|
@@ -167,42 +169,45 @@ with demo:
|
|
167 |
info="In what type of housing do you live ?"
|
168 |
)
|
169 |
|
170 |
-
|
|
|
171 |
encrypt_button_applicant = gr.Button("Encrypt the inputs and send to server.")
|
172 |
|
173 |
encrypted_input_applicant = gr.Textbox(
|
174 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
175 |
)
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
with gr.Row():
|
178 |
with gr.Column(scale=2):
|
179 |
-
gr.Markdown("### Bank information")
|
180 |
-
account_age = gr.Slider(
|
181 |
-
**ACCOUNT_MIN_MAX,
|
182 |
-
step=1,
|
183 |
-
label="Account age (months)",
|
184 |
-
info="How long have this person had this bank account (in months) ?"
|
185 |
-
)
|
186 |
-
|
187 |
-
with gr.Column():
|
188 |
encrypt_button_bank = gr.Button("Encrypt the inputs and send to server.")
|
189 |
|
190 |
encrypted_input_bank = gr.Textbox(
|
191 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
192 |
)
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
with gr.Row():
|
195 |
with gr.Column(scale=2):
|
196 |
-
gr.Markdown("### Credit bureau information ")
|
197 |
-
employed = gr.Radio(["Yes", "No"], label="Is the person employed ?", value="Yes")
|
198 |
-
years_employed = gr.Dropdown(
|
199 |
-
choices=YEARS_EMPLOYED_BINS,
|
200 |
-
value=YEARS_EMPLOYED_BINS[0],
|
201 |
-
label="Years of employment",
|
202 |
-
info="How long have this person been employed (in years) ?"
|
203 |
-
)
|
204 |
-
|
205 |
-
with gr.Column():
|
206 |
encrypt_button_credit_bureau = gr.Button("Encrypt the inputs and send to server.")
|
207 |
|
208 |
encrypted_input_credit_bureau = gr.Textbox(
|
@@ -234,7 +239,9 @@ with demo:
|
|
234 |
outputs=[encrypted_input_credit_bureau],
|
235 |
)
|
236 |
|
237 |
-
gr.Markdown("
|
|
|
|
|
238 |
gr.Markdown(
|
239 |
"""
|
240 |
Once the server receives the encrypted inputs, it can compute the prediction without ever
|
@@ -245,7 +252,6 @@ with demo:
|
|
245 |
"""
|
246 |
)
|
247 |
|
248 |
-
gr.Markdown("## Step 4: Run FHE execution.")
|
249 |
execute_fhe_button = gr.Button("Run FHE execution.")
|
250 |
fhe_execution_time = gr.Textbox(
|
251 |
label="Total FHE execution time (in seconds):", max_lines=1, interactive=False
|
@@ -254,7 +260,9 @@ with demo:
|
|
254 |
# Button to send the encodings to the server using post method
|
255 |
execute_fhe_button.click(run_fhe, inputs=[client_id], outputs=[fhe_execution_time])
|
256 |
|
257 |
-
gr.Markdown("
|
|
|
|
|
258 |
gr.Markdown(
|
259 |
"""
|
260 |
Once the server completed the inference, the encrypted output is returned to the applicant.
|
@@ -264,8 +272,6 @@ with demo:
|
|
264 |
only decrypt the full result when all three parties decrypt their share of the result.
|
265 |
"""
|
266 |
)
|
267 |
-
|
268 |
-
gr.Markdown("## Step 5: Receive the encrypted output from the server and decrypt.")
|
269 |
gr.Markdown(
|
270 |
"""
|
271 |
The first value displayed below is a shortened byte representation of the actual encrypted
|
@@ -289,7 +295,8 @@ with demo:
|
|
289 |
outputs=[prediction_output, encrypted_output_representation],
|
290 |
)
|
291 |
|
292 |
-
gr.Markdown("## Step
|
|
|
293 |
gr.Markdown(
|
294 |
"""
|
295 |
In case the credit card is likely to be denied, the applicant can ask for how many years of
|
|
|
61 |
"""
|
62 |
)
|
63 |
|
|
|
|
|
64 |
gr.Markdown("## Step 1: Generate the keys.")
|
65 |
+
gr.Markdown("<hr />")
|
66 |
+
gr.Markdown("<span style='color:grey'>Applicant, Bank and Credit bureau setup</span>")
|
67 |
gr.Markdown(
|
68 |
"""
|
69 |
- The private key is generated jointly by the entities that collaborate to compute the
|
|
|
86 |
)
|
87 |
|
88 |
gr.Markdown("## Step 2: Fill in some information.")
|
89 |
+
gr.Markdown("<hr />")
|
90 |
+
gr.Markdown("<span style='color:grey'>Applicant, Bank and Credit bureau setup</span>")
|
91 |
gr.Markdown(
|
92 |
"""
|
93 |
Select the information that corresponds to the profile you want to evaluate. Three sources
|
|
|
106 |
|
107 |
with gr.Row():
|
108 |
with gr.Column():
|
109 |
+
gr.Markdown("### Step 2.1 - Applicant information")
|
110 |
bool_inputs = gr.CheckboxGroup(
|
111 |
["Car", "Property", "Mobile phone"],
|
112 |
label="Which of the following do you actively hold or own?"
|
|
|
169 |
info="In what type of housing do you live ?"
|
170 |
)
|
171 |
|
172 |
+
with gr.Row():
|
173 |
+
with gr.Column(scale=2):
|
174 |
encrypt_button_applicant = gr.Button("Encrypt the inputs and send to server.")
|
175 |
|
176 |
encrypted_input_applicant = gr.Textbox(
|
177 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
178 |
)
|
179 |
|
180 |
+
gr.Markdown("<hr />")
|
181 |
+
with gr.Column():
|
182 |
+
gr.Markdown("### Step 2.2 - Bank information")
|
183 |
+
account_age = gr.Slider(
|
184 |
+
**ACCOUNT_MIN_MAX,
|
185 |
+
step=1,
|
186 |
+
label="Account age (months)",
|
187 |
+
info="How long have this person had this bank account (in months) ?"
|
188 |
+
)
|
189 |
+
|
190 |
with gr.Row():
|
191 |
with gr.Column(scale=2):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
encrypt_button_bank = gr.Button("Encrypt the inputs and send to server.")
|
193 |
|
194 |
encrypted_input_bank = gr.Textbox(
|
195 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
196 |
)
|
197 |
|
198 |
+
gr.Markdown("<hr />")
|
199 |
+
with gr.Column():
|
200 |
+
gr.Markdown("### Step 2.3 - Credit bureau information")
|
201 |
+
employed = gr.Radio(["Yes", "No"], label="Is the person employed ?", value="Yes")
|
202 |
+
years_employed = gr.Dropdown(
|
203 |
+
choices=YEARS_EMPLOYED_BINS,
|
204 |
+
value=YEARS_EMPLOYED_BINS[0],
|
205 |
+
label="Years of employment",
|
206 |
+
info="How long have this person been employed (in years) ?"
|
207 |
+
)
|
208 |
+
|
209 |
with gr.Row():
|
210 |
with gr.Column(scale=2):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
encrypt_button_credit_bureau = gr.Button("Encrypt the inputs and send to server.")
|
212 |
|
213 |
encrypted_input_credit_bureau = gr.Textbox(
|
|
|
239 |
outputs=[encrypted_input_credit_bureau],
|
240 |
)
|
241 |
|
242 |
+
gr.Markdown("## Step 3: Run FHE execution.")
|
243 |
+
gr.Markdown("<hr />")
|
244 |
+
gr.Markdown("<span style='color:grey'>Server Side</span>")
|
245 |
gr.Markdown(
|
246 |
"""
|
247 |
Once the server receives the encrypted inputs, it can compute the prediction without ever
|
|
|
252 |
"""
|
253 |
)
|
254 |
|
|
|
255 |
execute_fhe_button = gr.Button("Run FHE execution.")
|
256 |
fhe_execution_time = gr.Textbox(
|
257 |
label="Total FHE execution time (in seconds):", max_lines=1, interactive=False
|
|
|
260 |
# Button to send the encodings to the server using post method
|
261 |
execute_fhe_button.click(run_fhe, inputs=[client_id], outputs=[fhe_execution_time])
|
262 |
|
263 |
+
gr.Markdown("## Step 4: Receive the encrypted output from the server and decrypt.")
|
264 |
+
gr.Markdown("<hr />")
|
265 |
+
gr.Markdown("<span style='color:grey'>Applicant, Bank and Credit bureau decryption</span>")
|
266 |
gr.Markdown(
|
267 |
"""
|
268 |
Once the server completed the inference, the encrypted output is returned to the applicant.
|
|
|
272 |
only decrypt the full result when all three parties decrypt their share of the result.
|
273 |
"""
|
274 |
)
|
|
|
|
|
275 |
gr.Markdown(
|
276 |
"""
|
277 |
The first value displayed below is a shortened byte representation of the actual encrypted
|
|
|
295 |
outputs=[prediction_output, encrypted_output_representation],
|
296 |
)
|
297 |
|
298 |
+
gr.Markdown("## Step 5 (optional): Explain the prediction.")
|
299 |
+
gr.Markdown("<hr />")
|
300 |
gr.Markdown(
|
301 |
"""
|
302 |
In case the credit card is likely to be denied, the applicant can ask for how many years of
|