Roman
commited on
Commit
•
502bbf4
1
Parent(s):
dc93d64
chore: correct phrasing and add tutorial link
Browse files
app.py
CHANGED
@@ -366,17 +366,22 @@ with demo:
|
|
366 |
<a href="https://twitter.com/zama_fhe"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="https://user-images.githubusercontent.com/5758427/197975044-bab9d199-e120-433b-b3be-abd73b211a54.png">@zama_fhe</a>
|
367 |
</p>
|
368 |
<p align="center">
|
369 |
-
|
|
|
|
|
|
|
|
|
|
|
370 |
</p>
|
371 |
"""
|
372 |
)
|
373 |
|
374 |
gr.Markdown("## Client side")
|
375 |
-
gr.Markdown("### Step 1
|
376 |
gr.Markdown(
|
377 |
-
f"The image will automatically be resized to shape ({INPUT_SHAPE[0]}x{INPUT_SHAPE[1]})."
|
378 |
-
"The image
|
379 |
-
"in this demo can be seen in Step
|
380 |
)
|
381 |
with gr.Row():
|
382 |
input_image = gr.Image(
|
@@ -387,7 +392,7 @@ with demo:
|
|
387 |
examples=EXAMPLES, inputs=[input_image], examples_per_page=5, label="Examples to use."
|
388 |
)
|
389 |
|
390 |
-
gr.Markdown("### Step 2
|
391 |
filter_name = gr.Dropdown(
|
392 |
choices=AVAILABLE_FILTERS, value="inverted", label="Choose your filter", interactive=True
|
393 |
)
|
@@ -395,12 +400,12 @@ with demo:
|
|
395 |
gr.Markdown("#### Notes")
|
396 |
gr.Markdown(
|
397 |
"""
|
398 |
-
- The private key is used to encrypt and decrypt the data and
|
399 |
-
- No public key
|
400 |
"""
|
401 |
)
|
402 |
|
403 |
-
gr.Markdown("### Step 3
|
404 |
keygen_button = gr.Button("Generate the private key.")
|
405 |
|
406 |
with gr.Row():
|
@@ -412,7 +417,7 @@ with demo:
|
|
412 |
|
413 |
user_id = gr.Textbox(label="", max_lines=2, interactive=False, visible=False)
|
414 |
|
415 |
-
gr.Markdown("### Step 4
|
416 |
encrypt_button = gr.Button("Encrypt the image using FHE.")
|
417 |
|
418 |
with gr.Row():
|
@@ -431,19 +436,19 @@ with demo:
|
|
431 |
"the encrypted results to the client."
|
432 |
)
|
433 |
|
434 |
-
gr.Markdown("### Step 5
|
435 |
send_input_button = gr.Button("Send the encrypted image to the server.")
|
436 |
send_input_checkbox = gr.Checkbox(label="Encrypted image sent.", interactive=False)
|
437 |
|
438 |
-
gr.Markdown("### Step 6
|
439 |
execute_fhe_button = gr.Button("Run FHE execution.")
|
440 |
fhe_execution_time = gr.Textbox(
|
441 |
label="Total FHE execution time (in seconds):", max_lines=1, interactive=False
|
442 |
)
|
443 |
|
444 |
-
gr.Markdown("### Step 7
|
445 |
gr.Markdown(
|
446 |
-
"The image displayed here is the encrypted result sent by the server which has been "
|
447 |
"decrypted using a different private key. This is only used to visually represent an "
|
448 |
"encrypted image."
|
449 |
)
|
@@ -461,11 +466,11 @@ with demo:
|
|
461 |
|
462 |
gr.Markdown("## Client side")
|
463 |
gr.Markdown(
|
464 |
-
"The encrypted output is sent back to client, who can finally decrypt it with
|
465 |
"private key. Only the client is aware of the original image and its transformed version."
|
466 |
)
|
467 |
|
468 |
-
gr.Markdown("### Step 8
|
469 |
gr.Markdown(
|
470 |
"The image displayed on the left is the input image used during the demo. The output image "
|
471 |
"can be seen on the right."
|
|
|
366 |
<a href="https://twitter.com/zama_fhe"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="https://user-images.githubusercontent.com/5758427/197975044-bab9d199-e120-433b-b3be-abd73b211a54.png">@zama_fhe</a>
|
367 |
</p>
|
368 |
<p align="center">
|
369 |
+
Experiment with photo filtering using Homomorphic Encryption by following our
|
370 |
+
<a href="https://zama.ai/post/encrypted-image-filtering-using-homomorphic-encryption"> tutorial</a>
|
371 |
+
.
|
372 |
+
</p>
|
373 |
+
<p align="center">
|
374 |
+
<img src="https://user-images.githubusercontent.com/56846628/219403891-96591b1d-cbeb-4e81-91a9-7907c7ea91df.png" width="70%" height="70%">
|
375 |
</p>
|
376 |
"""
|
377 |
)
|
378 |
|
379 |
gr.Markdown("## Client side")
|
380 |
+
gr.Markdown("### Step 1: Upload an image. ")
|
381 |
gr.Markdown(
|
382 |
+
f"The image will automatically be resized to shape ({INPUT_SHAPE[0]}x{INPUT_SHAPE[1]}). "
|
383 |
+
"The image here, however, is displayed in its original resolution. The true image used "
|
384 |
+
"in this demo can be seen in Step 8."
|
385 |
)
|
386 |
with gr.Row():
|
387 |
input_image = gr.Image(
|
|
|
392 |
examples=EXAMPLES, inputs=[input_image], examples_per_page=5, label="Examples to use."
|
393 |
)
|
394 |
|
395 |
+
gr.Markdown("### Step 2: Choose your filter.")
|
396 |
filter_name = gr.Dropdown(
|
397 |
choices=AVAILABLE_FILTERS, value="inverted", label="Choose your filter", interactive=True
|
398 |
)
|
|
|
400 |
gr.Markdown("#### Notes")
|
401 |
gr.Markdown(
|
402 |
"""
|
403 |
+
- The private key is used to encrypt and decrypt the data and will never be shared.
|
404 |
+
- No public key is required for these filter operators.
|
405 |
"""
|
406 |
)
|
407 |
|
408 |
+
gr.Markdown("### Step 3: Generate the private key.")
|
409 |
keygen_button = gr.Button("Generate the private key.")
|
410 |
|
411 |
with gr.Row():
|
|
|
417 |
|
418 |
user_id = gr.Textbox(label="", max_lines=2, interactive=False, visible=False)
|
419 |
|
420 |
+
gr.Markdown("### Step 4: Encrypt the image using FHE.")
|
421 |
encrypt_button = gr.Button("Encrypt the image using FHE.")
|
422 |
|
423 |
with gr.Row():
|
|
|
436 |
"the encrypted results to the client."
|
437 |
)
|
438 |
|
439 |
+
gr.Markdown("### Step 5: Send the encrypted image to the server.")
|
440 |
send_input_button = gr.Button("Send the encrypted image to the server.")
|
441 |
send_input_checkbox = gr.Checkbox(label="Encrypted image sent.", interactive=False)
|
442 |
|
443 |
+
gr.Markdown("### Step 6: Run FHE execution.")
|
444 |
execute_fhe_button = gr.Button("Run FHE execution.")
|
445 |
fhe_execution_time = gr.Textbox(
|
446 |
label="Total FHE execution time (in seconds):", max_lines=1, interactive=False
|
447 |
)
|
448 |
|
449 |
+
gr.Markdown("### Step 7: Receive the encrypted output image from the server.")
|
450 |
gr.Markdown(
|
451 |
+
"The image displayed here is the encrypted result sent by the server, which has been "
|
452 |
"decrypted using a different private key. This is only used to visually represent an "
|
453 |
"encrypted image."
|
454 |
)
|
|
|
466 |
|
467 |
gr.Markdown("## Client side")
|
468 |
gr.Markdown(
|
469 |
+
"The encrypted output is sent back to the client, who can finally decrypt it with the "
|
470 |
"private key. Only the client is aware of the original image and its transformed version."
|
471 |
)
|
472 |
|
473 |
+
gr.Markdown("### Step 8: Decrypt the output.")
|
474 |
gr.Markdown(
|
475 |
"The image displayed on the left is the input image used during the demo. The output image "
|
476 |
"can be seen on the right."
|