Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
from predictor import predict, key_already_generated, pre_process_encrypt_send_purchase, decrypt_prediction
|
3 |
-
import base64
|
4 |
-
|
5 |
-
import os
|
6 |
-
zama_path = os.path.join(os.path.dirname(__file__), "Img", "zama.png")
|
7 |
-
epita_path = os.path.join(os.path.dirname(__file__), "Img", "Epita.png")
|
8 |
-
|
9 |
-
def encode_image_to_base64(image_path):
|
10 |
-
with open(image_path, "rb") as image_file:
|
11 |
-
return base64.b64encode(image_file.read()).decode("utf-8")
|
12 |
-
|
13 |
|
14 |
def key_generated():
|
15 |
"""
|
@@ -28,23 +18,19 @@ def key_generated():
|
|
28 |
print("Keys have been generated ✅")
|
29 |
return {gen_key_btn: gr.update(value="Keys have been generated ✅")}
|
30 |
|
|
|
31 |
demo = gr.Blocks(css=".markdown-body { font-size: 18px; }")
|
32 |
|
33 |
with demo:
|
34 |
-
zama_base64 = encode_image_to_base64(zama_path)
|
35 |
-
epita_base64 = encode_image_to_base64(epita_path)
|
36 |
-
|
37 |
gr.Markdown(
|
38 |
-
|
39 |
<div style="display: flex; justify-content: center; align-items: center;">
|
40 |
-
<img style="margin-right: 50px;" width=200 src="
|
41 |
-
<img width=200 src="
|
42 |
</div>
|
43 |
"""
|
44 |
)
|
45 |
|
46 |
-
|
47 |
-
|
48 |
gr.Markdown(
|
49 |
"""
|
50 |
<h1 style="text-align: center;">Fraud Detection with FHE Model</h1>
|
@@ -107,11 +93,10 @@ with demo:
|
|
107 |
"""
|
108 |
)
|
109 |
|
110 |
-
schema_base64 = encode_image_to_base64("Img/schema.png")
|
111 |
gr.Markdown(
|
112 |
-
|
113 |
<p align="center">
|
114 |
-
<img width="75%" height="30%" src="
|
115 |
</p>
|
116 |
"""
|
117 |
)
|
@@ -135,7 +120,7 @@ with demo:
|
|
135 |
key_generated,
|
136 |
inputs=[],
|
137 |
outputs=[gen_key_btn],
|
138 |
-
)
|
139 |
|
140 |
gr.Markdown("<hr />")
|
141 |
|
@@ -268,7 +253,6 @@ with demo:
|
|
268 |
label="Total FHE execution time (in seconds):", max_lines=1, interactive=False
|
269 |
)
|
270 |
|
271 |
-
# Button to send the encodings to the server using post method
|
272 |
execute_fhe_button.click(predict, outputs=[fhe_execution_time, execute_fhe_button])
|
273 |
|
274 |
gr.Markdown("<hr />")
|
@@ -305,4 +289,4 @@ with demo:
|
|
305 |
)
|
306 |
|
307 |
if __name__ == "__main__":
|
308 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from predictor import predict, key_already_generated, pre_process_encrypt_send_purchase, decrypt_prediction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
def key_generated():
|
5 |
"""
|
|
|
18 |
print("Keys have been generated ✅")
|
19 |
return {gen_key_btn: gr.update(value="Keys have been generated ✅")}
|
20 |
|
21 |
+
|
22 |
demo = gr.Blocks(css=".markdown-body { font-size: 18px; }")
|
23 |
|
24 |
with demo:
|
|
|
|
|
|
|
25 |
gr.Markdown(
|
26 |
+
"""
|
27 |
<div style="display: flex; justify-content: center; align-items: center;">
|
28 |
+
<img style="margin-right: 50px;" width=200 src="/file=Img/zama.png">
|
29 |
+
<img width=200 src="/file=Img/Epita.png">
|
30 |
</div>
|
31 |
"""
|
32 |
)
|
33 |
|
|
|
|
|
34 |
gr.Markdown(
|
35 |
"""
|
36 |
<h1 style="text-align: center;">Fraud Detection with FHE Model</h1>
|
|
|
93 |
"""
|
94 |
)
|
95 |
|
|
|
96 |
gr.Markdown(
|
97 |
+
"""
|
98 |
<p align="center">
|
99 |
+
<img width="75%" height="30%" src="/file=Img/schema.png">
|
100 |
</p>
|
101 |
"""
|
102 |
)
|
|
|
120 |
key_generated,
|
121 |
inputs=[],
|
122 |
outputs=[gen_key_btn],
|
123 |
+
)
|
124 |
|
125 |
gr.Markdown("<hr />")
|
126 |
|
|
|
253 |
label="Total FHE execution time (in seconds):", max_lines=1, interactive=False
|
254 |
)
|
255 |
|
|
|
256 |
execute_fhe_button.click(predict, outputs=[fhe_execution_time, execute_fhe_button])
|
257 |
|
258 |
gr.Markdown("<hr />")
|
|
|
289 |
)
|
290 |
|
291 |
if __name__ == "__main__":
|
292 |
+
demo.launch()
|