Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
romanbredehoft-zama
commited on
Commit
•
5a6dcda
1
Parent(s):
8559d3b
Update developement files to allow cross-platform use
Browse files- README.md +0 -9
- client_server_interface.py +3 -2
- filters/black and white/deployment/client.zip +1 -1
- filters/black and white/deployment/server.zip +2 -2
- filters/blur/deployment/client.zip +1 -1
- filters/blur/deployment/server.zip +2 -2
- filters/identity/deployment/client.zip +1 -1
- filters/identity/deployment/server.zip +2 -2
- filters/inverted/deployment/client.zip +1 -1
- filters/inverted/deployment/server.zip +2 -2
- filters/ridge detection/deployment/client.zip +1 -1
- filters/ridge detection/deployment/server.zip +2 -2
- filters/rotate/deployment/client.zip +1 -1
- filters/rotate/deployment/server.zip +2 -2
- filters/sharpen/deployment/client.zip +1 -1
- filters/sharpen/deployment/server.zip +2 -2
- server.py +7 -3
README.md
CHANGED
@@ -37,15 +37,6 @@ pip3 install -r requirements.txt --ignore-installed
|
|
37 |
|
38 |
The above steps should only be done once.
|
39 |
|
40 |
-
## Generate development files
|
41 |
-
|
42 |
-
If you are not on Linux, you will need to re-generate the development files manually before launching the app.
|
43 |
-
|
44 |
-
```bash
|
45 |
-
python3 generate_dev_filters.py
|
46 |
-
```
|
47 |
-
|
48 |
-
|
49 |
## Run the app
|
50 |
|
51 |
In a terminal, run:
|
|
|
37 |
|
38 |
The above steps should only be done once.
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
## Run the app
|
41 |
|
42 |
In a terminal, run:
|
client_server_interface.py
CHANGED
@@ -65,9 +65,10 @@ class FHEDev:
|
|
65 |
"The model must be compiled before saving it."
|
66 |
)
|
67 |
|
68 |
-
# Save the circuit for the server
|
|
|
69 |
path_circuit_server = self.path_dir / "server.zip"
|
70 |
-
self.filter.fhe_circuit.server.save(path_circuit_server)
|
71 |
|
72 |
# Save the circuit for the client
|
73 |
path_circuit_client = self.path_dir / "client.zip"
|
|
|
65 |
"The model must be compiled before saving it."
|
66 |
)
|
67 |
|
68 |
+
# Save the circuit for the server, using the via_mlir in order to handle cross-platform
|
69 |
+
# execution
|
70 |
path_circuit_server = self.path_dir / "server.zip"
|
71 |
+
self.filter.fhe_circuit.server.save(path_circuit_server, via_mlir=True)
|
72 |
|
73 |
# Save the circuit for the client
|
74 |
path_circuit_client = self.path_dir / "client.zip"
|
filters/black and white/deployment/client.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 348
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1afbf993edf5cdbcc73c2c9fe2bf3748b235738cfb772b849b9058d611e01bcc
|
3 |
size 348
|
filters/black and white/deployment/server.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7d46df3333324fefa8558766fa825adeb579b71930b390673c38783dcdc5743d
|
3 |
+
size 840
|
filters/blur/deployment/client.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 360
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c6b45511096f6da9aa73601b1372ffc42ec9272b40348d92f90427fbddff0571
|
3 |
size 360
|
filters/blur/deployment/server.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8cc44c02ca9ee6523a35dcb1a034b7852e59a3a587dcbf2af71ca4109fc1e138
|
3 |
+
size 824
|
filters/identity/deployment/client.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 347
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:56a6dd6918993c387e9cfa1f9a373fa8acd3ecee01fabae937ca9efa317335d9
|
3 |
size 347
|
filters/identity/deployment/server.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:21c7e3b38e16ee2635989a37c4d903b40af54392c3c1b7c99553f9201c17570f
|
3 |
+
size 564
|
filters/inverted/deployment/client.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 347
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:56a6dd6918993c387e9cfa1f9a373fa8acd3ecee01fabae937ca9efa317335d9
|
3 |
size 347
|
filters/inverted/deployment/server.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0b6e5457007404036aa563166c42ce5a320865b10c12a7cdc64e206b9d8ead88
|
3 |
+
size 663
|
filters/ridge detection/deployment/client.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 369
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c84ac5a4c0e4c5d41ee349e0982706c1a0fdee59571a4e82296e7c7545afe3f6
|
3 |
size 369
|
filters/ridge detection/deployment/server.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5abaeef5ed5754490f4894a7132fd414d191f90548c2ed59c701940d9f234ee1
|
3 |
+
size 952
|
filters/rotate/deployment/client.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 347
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:56a6dd6918993c387e9cfa1f9a373fa8acd3ecee01fabae937ca9efa317335d9
|
3 |
size 347
|
filters/rotate/deployment/server.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7b350fc3287b7eb7f903f66e970d77c28905398c7770351ebdcfa9d65aa019f4
|
3 |
+
size 617
|
filters/sharpen/deployment/client.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 369
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bbca169fd30d0238b2b31213b058d6b3d54b50b2bd7e12225e5f99975302b700
|
3 |
size 369
|
filters/sharpen/deployment/server.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e0557c4bf8cc5816fa78d0b059fdcdd99362969754f8720094b0b7ee1fdd994f
|
3 |
+
size 876
|
server.py
CHANGED
@@ -5,9 +5,13 @@ from typing import List
|
|
5 |
from fastapi import FastAPI, File, Form, UploadFile
|
6 |
from fastapi.responses import JSONResponse, Response
|
7 |
|
8 |
-
from common import FILTERS_PATH, SERVER_TMP_PATH
|
9 |
from client_server_interface import FHEServer
|
10 |
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def get_server_file_path(name, user_id, filter_name):
|
13 |
"""Get the correct temporary file path for the server.
|
@@ -68,8 +72,8 @@ def run_fhe(
|
|
68 |
encrypted_image = encrypted_image_file.read()
|
69 |
evaluation_key = evaluation_key_file.read()
|
70 |
|
71 |
-
# Load the FHE server
|
72 |
-
fhe_server =
|
73 |
|
74 |
# Run the FHE execution
|
75 |
start = time.time()
|
|
|
5 |
from fastapi import FastAPI, File, Form, UploadFile
|
6 |
from fastapi.responses import JSONResponse, Response
|
7 |
|
8 |
+
from common import FILTERS_PATH, SERVER_TMP_PATH, AVAILABLE_FILTERS
|
9 |
from client_server_interface import FHEServer
|
10 |
|
11 |
+
# Load the server objects related to all currently available filters once and for all
|
12 |
+
FHE_SERVERS = {
|
13 |
+
filter: FHEServer(FILTERS_PATH / f"{filter}/deployment") for filter in AVAILABLE_FILTERS
|
14 |
+
}
|
15 |
|
16 |
def get_server_file_path(name, user_id, filter_name):
|
17 |
"""Get the correct temporary file path for the server.
|
|
|
72 |
encrypted_image = encrypted_image_file.read()
|
73 |
evaluation_key = evaluation_key_file.read()
|
74 |
|
75 |
+
# Load the FHE server related to the chosen filter
|
76 |
+
fhe_server = FHE_SERVERS[filter]
|
77 |
|
78 |
# Run the FHE execution
|
79 |
start = time.time()
|