Roman commited on
Commit
2a040cc
•
1 Parent(s): 7b32412

chore: clean and fix typos

Browse files
README.md CHANGED
@@ -41,15 +41,27 @@ pip3 install -U pip wheel setuptools --ignore-installed
41
  pip3 install -r requirements.txt --ignore-installed
42
  ```
43
 
44
- If not on Linux, or if you want to compile the FHE filters by yourself:
 
 
 
 
 
 
45
 
46
  <!--pytest-codeblocks:skip-->
47
 
48
  ```bash
49
- python3 compile.py
 
50
  ```
51
 
52
- Check it finish well (with a "Done!").
 
 
 
 
 
53
 
54
  It is also possible to manually add some new filters in `filters.py`. Yet, in order to be able to use
55
  them interactively in the app, you first need to update the `AVAILABLE_FILTERS` list found in `common.py`
@@ -61,17 +73,5 @@ and then compile them by running :
61
  python3 generate_dev_filters.py
62
  ```
63
 
64
- ## Run the following steps each time you relaunch the application
65
 
66
- In a terminal, run:
67
-
68
- <!--pytest-codeblocks:skip-->
69
-
70
- ```bash
71
- source .venv/bin/activate
72
- python3 app.py
73
- ```
74
-
75
- ## Interacting with the application
76
-
77
- Open the given URL link (search for a line like `Running on local URL: http://127.0.0.1:8888/`).
 
41
  pip3 install -r requirements.txt --ignore-installed
42
  ```
43
 
44
+ If you are not on Linux, you will need to generate the files manually before launching the app.
45
+ See section [Generating new files](#generating-new-files).
46
+
47
+
48
+ ## Run the following steps each time you relaunch the application
49
+
50
+ In a terminal, run:
51
 
52
  <!--pytest-codeblocks:skip-->
53
 
54
  ```bash
55
+ source .venv/bin/activate
56
+ python3 app.py
57
  ```
58
 
59
+ ## Interacting with the application
60
+
61
+ Open the given URL link (search for a line like `Running on local URL: http://127.0.0.1:8888/`).
62
+
63
+
64
+ ## Generating new files
65
 
66
  It is also possible to manually add some new filters in `filters.py`. Yet, in order to be able to use
67
  them interactively in the app, you first need to update the `AVAILABLE_FILTERS` list found in `common.py`
 
73
  python3 generate_dev_filters.py
74
  ```
75
 
76
+ Check it finishes well (by printing "Done!").
77
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -33,7 +33,7 @@ def decrypt_output_with_wrong_key(encrypted_image, filter_name):
33
  filter_path = FILTERS_PATH / f"{filter_name}/deployment"
34
 
35
  # Instantiate the client interface and generate a new private key
36
- wrong_client = FHEClient(filter_path, WRONG_KEYS_PATH)
37
  wrong_client.generate_private_and_evaluation_keys(force=True)
38
 
39
  # Deserialize, decrypt and post-process the encrypted output using the new private key
@@ -72,7 +72,9 @@ def get_client(user_id, filter_name):
72
  FHEClient: The client API.
73
  """
74
  return FHEClient(
75
- FILTERS_PATH / f"{filter_name}/deployment", KEYS_PATH / f"{filter_name}_{user_id}"
 
 
76
  )
77
 
78
 
 
33
  filter_path = FILTERS_PATH / f"{filter_name}/deployment"
34
 
35
  # Instantiate the client interface and generate a new private key
36
+ wrong_client = FHEClient(filter_path, WRONG_KEYS_PATH, filter_name)
37
  wrong_client.generate_private_and_evaluation_keys(force=True)
38
 
39
  # Deserialize, decrypt and post-process the encrypted output using the new private key
 
72
  FHEClient: The client API.
73
  """
74
  return FHEClient(
75
+ FILTERS_PATH / f"{filter_name}/deployment",
76
+ KEYS_PATH / f"{filter_name}_{user_id}",
77
+ filter_name,
78
  )
79
 
80
 
client_server_interface.py CHANGED
@@ -1,10 +1,9 @@
1
  "Client-server interface custom implementation for filter models."
2
 
3
- import zipfile
4
- import json
5
  from filters import Filter
6
 
7
- import concrete.numpy as cnp
8
 
9
  class FHEServer:
10
  """Server interface run a FHE circuit."""
@@ -31,20 +30,22 @@ class FHEServer:
31
  bytes: The filter's output.
32
  """
33
  # Deserialize the encrypted input image and the evaluation keys
34
- deserialized_encrypted_image = self.server.client_specs.unserialize_public_args(
35
  serialized_encrypted_image
36
  )
37
- deserialized_evaluation_keys = cnp.EvaluationKeys.unserialize(serialized_evaluation_keys)
38
 
39
  # Execute the filter in FHE
40
- result = self.server.run(
41
- deserialized_encrypted_image, deserialized_evaluation_keys
42
  )
43
 
44
  # Serialize the encrypted output image
45
- serialized_result = self.server.client_specs.serialize_public_result(result)
 
 
46
 
47
- return serialized_result
48
 
49
 
50
  class FHEDev:
@@ -70,13 +71,6 @@ class FHEDev:
70
  "The model must be compiled before saving it."
71
  )
72
 
73
- # Export to json the parameters needed for loading the filter in the other interfaces
74
- serialized_processing = {"filter_name": self.filter.filter_name}
75
-
76
- json_path = self.path_dir / "serialized_processing.json"
77
- with open(json_path, "w", encoding="utf-8") as file:
78
- json.dump(serialized_processing, file)
79
-
80
  # Save the circuit for the server
81
  path_circuit_server = self.path_dir / "server.zip"
82
  self.filter.fhe_circuit.server.save(path_circuit_server)
@@ -85,19 +79,16 @@ class FHEDev:
85
  path_circuit_client = self.path_dir / "client.zip"
86
  self.filter.fhe_circuit.client.save(path_circuit_client)
87
 
88
- with zipfile.ZipFile(path_circuit_client, "a") as zip_file:
89
- zip_file.write(filename=json_path, arcname="serialized_processing.json")
90
-
91
 
92
  class FHEClient:
93
  """Client interface to encrypt and decrypt FHE data associated to a Filter."""
94
 
95
- def __init__(self, path_dir, key_dir):
96
  """Initialize the FHE interface.
97
 
98
  Args:
99
- path_dir (Path): the path to the directory where the circuit is saved
100
- key_dir (Path): the path to the directory where the keys are stored
101
  """
102
  self.path_dir = path_dir
103
  self.key_dir = key_dir
@@ -108,13 +99,7 @@ class FHEClient:
108
  # Load the client
109
  self.client = cnp.Client.load(self.path_dir / "client.zip", self.key_dir)
110
 
111
- # Load the parameters
112
- with zipfile.ZipFile(self.path_dir / "client.zip") as client_zip:
113
- with client_zip.open("serialized_processing.json", mode="r") as file:
114
- serialized_processing = json.load(file)
115
-
116
  # Instantiate the filter
117
- filter_name = serialized_processing["filter_name"]
118
  self.filter = Filter(filter_name)
119
 
120
  def generate_private_and_evaluation_keys(self, force=False):
@@ -134,7 +119,7 @@ class FHEClient:
134
  return self.client.evaluation_keys.serialize()
135
 
136
  def pre_process_encrypt_serialize(self, input_image):
137
- """Pre-process, encrypt and serialize the input image.
138
 
139
  Args:
140
  input_image (numpy.ndarray): The image to pre-process, encrypt and serialize.
@@ -153,7 +138,7 @@ class FHEClient:
153
  return serialized_encrypted_image
154
 
155
  def deserialize_decrypt_post_process(self, serialized_encrypted_output_image):
156
- """Deserialize, decrypt and post-process the output image.
157
 
158
  Args:
159
  serialized_encrypted_output_image (bytes): The serialized and encrypted output image.
 
1
  "Client-server interface custom implementation for filter models."
2
 
3
+ import concrete.numpy as cnp
4
+
5
  from filters import Filter
6
 
 
7
 
8
  class FHEServer:
9
  """Server interface run a FHE circuit."""
 
30
  bytes: The filter's output.
31
  """
32
  # Deserialize the encrypted input image and the evaluation keys
33
+ encrypted_image = self.server.client_specs.unserialize_public_args(
34
  serialized_encrypted_image
35
  )
36
+ evaluation_keys = cnp.EvaluationKeys.unserialize(serialized_evaluation_keys)
37
 
38
  # Execute the filter in FHE
39
+ encrypted_output = self.server.run(
40
+ encrypted_image, evaluation_keys
41
  )
42
 
43
  # Serialize the encrypted output image
44
+ serialized_encrypted_output = self.server.client_specs.serialize_public_result(
45
+ encrypted_output
46
+ )
47
 
48
+ return serialized_encrypted_output
49
 
50
 
51
  class FHEDev:
 
71
  "The model must be compiled before saving it."
72
  )
73
 
 
 
 
 
 
 
 
74
  # Save the circuit for the server
75
  path_circuit_server = self.path_dir / "server.zip"
76
  self.filter.fhe_circuit.server.save(path_circuit_server)
 
79
  path_circuit_client = self.path_dir / "client.zip"
80
  self.filter.fhe_circuit.client.save(path_circuit_client)
81
 
 
 
 
82
 
83
  class FHEClient:
84
  """Client interface to encrypt and decrypt FHE data associated to a Filter."""
85
 
86
+ def __init__(self, path_dir, key_dir, filter_name):
87
  """Initialize the FHE interface.
88
 
89
  Args:
90
+ path_dir (Path): The path to the directory where the circuit is saved.
91
+ key_dir (Path): The path to the directory where the keys are stored.
92
  """
93
  self.path_dir = path_dir
94
  self.key_dir = key_dir
 
99
  # Load the client
100
  self.client = cnp.Client.load(self.path_dir / "client.zip", self.key_dir)
101
 
 
 
 
 
 
102
  # Instantiate the filter
 
103
  self.filter = Filter(filter_name)
104
 
105
  def generate_private_and_evaluation_keys(self, force=False):
 
119
  return self.client.evaluation_keys.serialize()
120
 
121
  def pre_process_encrypt_serialize(self, input_image):
122
+ """Pre-process, encrypt and serialize the input image in the clear.
123
 
124
  Args:
125
  input_image (numpy.ndarray): The image to pre-process, encrypt and serialize.
 
138
  return serialized_encrypted_image
139
 
140
  def deserialize_decrypt_post_process(self, serialized_encrypted_output_image):
141
+ """Deserialize, decrypt and post-process the output image in the clear.
142
 
143
  Args:
144
  serialized_encrypted_output_image (bytes): The serialized and encrypted output image.
compile.py DELETED
@@ -1,45 +0,0 @@
1
- "A script to manually compile all filters."
2
-
3
- import json
4
- import shutil
5
- import onnx
6
-
7
- from common import AVAILABLE_FILTERS, FILTERS_PATH, KEYS_PATH
8
- from client_server_interface import FHEClient, FHEDev
9
-
10
- print("Starting compiling the filters.")
11
-
12
- for filter_name in AVAILABLE_FILTERS:
13
- print("\nCompiling filter:", filter_name)
14
-
15
- # Retrieve the deployment files associated to the current filter
16
- deployment_path = FILTERS_PATH / f"{filter_name}/deployment"
17
-
18
- # Retrieve the client associated to the current filter
19
- filter = FHEClient(deployment_path, KEYS_PATH).filter
20
-
21
- # Load the onnx graph
22
- onnx_graph = onnx.load(FILTERS_PATH / f"{filter_name}/server.onnx")
23
-
24
- # Compile the filter on a representative inputset, using the loaded onnx graph
25
- filter.compile(onnx_graph=onnx_graph)
26
-
27
- processing_json_path = deployment_path / "serialized_processing.json"
28
-
29
- # Load the serialized_processing.json file
30
- with open(processing_json_path, "r") as f:
31
- serialized_processing = json.load(f)
32
-
33
- # Delete the deployment folder and its content if it exist
34
- if deployment_path.is_dir():
35
- shutil.rmtree(deployment_path)
36
-
37
- # Save the development files needed for deployment
38
- fhe_dev = FHEDev(filter, deployment_path)
39
- fhe_dev.save()
40
-
41
- # Write the serialized_processing.json file in the deployment directory
42
- with open(processing_json_path, "w") as f:
43
- json.dump(serialized_processing, f)
44
-
45
- print("Done!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
filters.py CHANGED
@@ -7,7 +7,6 @@ from common import AVAILABLE_FILTERS, INPUT_SHAPE
7
 
8
  from concrete.numpy.compilation.compiler import Compiler
9
  from concrete.ml.common.utils import generate_proxy_function
10
- from concrete.ml.onnx.convert import get_equivalent_numpy_forward
11
  from concrete.ml.torch.numpy_module import NumpyModule
12
 
13
 
@@ -57,7 +56,7 @@ class TorchRotate(nn.Module):
57
 
58
 
59
  class TorchConv(nn.Module):
60
- """Torch model for applying convolution operators on images."""
61
 
62
  def __init__(self, kernel, n_in_channels=3, n_out_channels=3, groups=1, threshold=None):
63
  """Initialize the filter.
@@ -73,14 +72,13 @@ class TorchConv(nn.Module):
73
  self.threshold = threshold
74
 
75
  def forward(self, x):
76
- """Forward pass for filtering the image using a 1D or 2D kernel.
77
 
78
  Args:
79
  x (torch.Tensor): The input image.
80
 
81
  Returns:
82
  torch.Tensor: The filtered image.
83
-
84
  """
85
  # Define the convolution parameters
86
  stride = 1
@@ -207,43 +205,36 @@ class Filter:
207
  # ususally displayed as such
208
  self.repeat_out_channels = True
209
 
210
- def compile(self, onnx_graph=None):
211
- """Compile the model on a representative inputset.
212
-
213
- Args:
214
- onnx_graph (onnx.ModelProto): The loaded onnx model to consider. If None, it will be
215
- generated automatically using a NumpyModule. Default to None.
216
- """
217
  # Generate a random representative set of images used for compilation, following Torch's
218
  # shape format (batch, in_channels, image_height, image_width) for each samples
219
  # This version's compiler only handles tuples of 1-batch array as inputset, meaning we need
220
  # to define the inputset as a Tuple[np.ndarray[shape=(1, 3, H, W)]]
221
  np.random.seed(42)
222
  inputset = tuple(
223
- np.random.randint(0, 255, size=((1, 3) + INPUT_SHAPE), dtype=np.int64) for _ in range(10)
224
  )
225
 
226
- # If no onnx model was given, generate a new one.
227
- if onnx_graph is None:
228
- numpy_module = NumpyModule(
229
- self.torch_model,
230
- dummy_input=torch.from_numpy(inputset[0]),
231
- )
232
-
233
- onnx_graph = numpy_module.onnx_model
234
-
235
- # Get the proxy function and parameter mappings for initializing the compiler
236
- self.onnx_graph = onnx_graph
237
- numpy_filter = get_equivalent_numpy_forward(onnx_graph)
238
 
239
- numpy_filter_proxy, parameters_mapping = generate_proxy_function(numpy_filter, ["inputs"])
 
 
 
 
 
 
240
 
 
241
  compiler = Compiler(
242
  numpy_filter_proxy,
243
  {parameters_mapping["inputs"]: "encrypted"},
244
  )
245
-
246
- # Compile the filter
247
  self.fhe_circuit = compiler.compile(inputset)
248
 
249
  return self.fhe_circuit
 
7
 
8
  from concrete.numpy.compilation.compiler import Compiler
9
  from concrete.ml.common.utils import generate_proxy_function
 
10
  from concrete.ml.torch.numpy_module import NumpyModule
11
 
12
 
 
56
 
57
 
58
  class TorchConv(nn.Module):
59
+ """Torch model with a single convolution operator."""
60
 
61
  def __init__(self, kernel, n_in_channels=3, n_out_channels=3, groups=1, threshold=None):
62
  """Initialize the filter.
 
72
  self.threshold = threshold
73
 
74
  def forward(self, x):
75
+ """Forward pass with a single convolution using a 1D or 2D kernel.
76
 
77
  Args:
78
  x (torch.Tensor): The input image.
79
 
80
  Returns:
81
  torch.Tensor: The filtered image.
 
82
  """
83
  # Define the convolution parameters
84
  stride = 1
 
205
  # ususally displayed as such
206
  self.repeat_out_channels = True
207
 
208
+ def compile(self):
209
+ """Compile the filter on a representative inputset."""
 
 
 
 
 
210
  # Generate a random representative set of images used for compilation, following Torch's
211
  # shape format (batch, in_channels, image_height, image_width) for each samples
212
  # This version's compiler only handles tuples of 1-batch array as inputset, meaning we need
213
  # to define the inputset as a Tuple[np.ndarray[shape=(1, 3, H, W)]]
214
  np.random.seed(42)
215
  inputset = tuple(
216
+ np.random.randint(0, 256, size=((1, 3) + INPUT_SHAPE), dtype=np.int64) for _ in range(100)
217
  )
218
 
219
+ # Convert the Torch module to a Numpy module
220
+ numpy_module = NumpyModule(
221
+ self.torch_model,
222
+ dummy_input=torch.from_numpy(inputset[0]),
223
+ )
 
 
 
 
 
 
 
224
 
225
+ # Get the proxy function and parameter mappings used for initializing the compiler
226
+ # This is done in order to be able to provide any modules with arbitrary numbers of
227
+ # encrypted arguments to Concrete Numpy's compiler
228
+ numpy_filter_proxy, parameters_mapping = generate_proxy_function(
229
+ numpy_module.numpy_forward,
230
+ ["inputs"]
231
+ )
232
 
233
+ # Compile the filter and retrieve its FHE circuit
234
  compiler = Compiler(
235
  numpy_filter_proxy,
236
  {parameters_mapping["inputs"]: "encrypted"},
237
  )
 
 
238
  self.fhe_circuit = compiler.compile(inputset)
239
 
240
  return self.fhe_circuit
filters/black and white/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fa7aa78811be0810d523a8d94a1aa27e24e40d29eced0395fd3bc743568b62b8
3
- size 550
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d715c22a7efedd7e592bc04e4e7f722e2a72de12fadcd526bc2dde6465053d51
3
+ size 388
filters/black and white/deployment/serialized_processing.json DELETED
@@ -1 +0,0 @@
1
- {"filter_name": "black and white"}
 
 
filters/black and white/deployment/server.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5fe0885c010b076062a9b5887d0ee5ebf07f7b879633324af1b14e58a2fefeec
3
  size 4364
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4477689ba8760c3ee2239f25b783cb4629df831fbee9a6fde063b047219a4507
3
  size 4364
filters/black and white/server.onnx DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5699206ad340e82b59392054f70b82327090bfee4909f4a0ffbd52614affc33f
3
- size 336
 
 
 
 
filters/blur/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9fafcd6cd32109e17bad3ee5945b54c64525f3db5d3e893a5618cfb765a8748e
3
- size 542
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07437fc6167a00e2fc72427254829c466600f5baacaa75abab6d023f07ebd657
3
+ size 391
filters/blur/deployment/serialized_processing.json DELETED
@@ -1 +0,0 @@
1
- {"filter_name": "blur"}
 
 
filters/blur/deployment/server.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:49b6c8a391e67ba424f156ef6049175e5c49b13d5b92052fddf05214741175c6
3
  size 7263
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:94ecbd3c5a43abd6864538f92aec8634b1e29191c5f8f5925effc25ae1906213
3
  size 7263
filters/blur/server.onnx DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b8fd3d313ec3a9d565a0621921768317f66e53596ad950ca2be6b1efbcf984bd
3
- size 532
 
 
 
 
filters/identity/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:19a7d7831af7f4a7a55a734a12e772ec41058502138e15925e229c89fcd8b195
3
- size 533
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0245406eed38f2a0c5f0afdacd5aab3746b5c7f3542f77a1ac2962355d732dbb
3
+ size 378
filters/identity/deployment/serialized_processing.json DELETED
@@ -1 +0,0 @@
1
- {"filter_name": "identity"}
 
 
filters/identity/deployment/server.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d2891ffa3e35d14d40a79b533fb331d557c82b4a8fe20568aa095aa7a22164a9
3
  size 2559
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78d4b454bd5fe0d624bacfc9119e18c8c334f9e2db6c83e5f3a212d76a9ea99a
3
  size 2559
filters/identity/server.onnx DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:71a8a398ea2edac9b0dfd41232c74549d1b8c159d391a4b3d42e2b4b731da02b
3
- size 155
 
 
 
 
filters/inverted/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:67169abe3c33f7c7f377cd7e3b17031dd43054432a9d1b39f5469417156b5f2d
3
- size 533
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0245406eed38f2a0c5f0afdacd5aab3746b5c7f3542f77a1ac2962355d732dbb
3
+ size 378
filters/inverted/deployment/serialized_processing.json DELETED
@@ -1 +0,0 @@
1
- {"filter_name": "inverted"}
 
 
filters/inverted/deployment/server.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:781488531b0049ecd05d3cc0e0eb95a9350553848bf218e726e97dce2b3ebd42
3
  size 4179
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d673c0980ec6987ff88b96c8c642082377de4158153a0828430717284575b629
3
  size 4179
filters/inverted/server.onnx DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b2fead709dbc8f0ab1f19ff1878e0ac9ce110b2b3ced261d7a87d32e0fc58b61
3
- size 211
 
 
 
 
filters/ridge detection/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:05b54c87d88297316aeb864d7292c9a4c930d486e7d0b7232bdf77e9b76a7692
3
- size 559
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d27edd60ab1d7186a6053209211922e256e86d9ae223f7056d8932890d3c50e
3
+ size 397
filters/ridge detection/deployment/serialized_processing.json DELETED
@@ -1 +0,0 @@
1
- {"filter_name": "ridge detection"}
 
 
filters/ridge detection/deployment/server.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:238980dd76c8155164b84d0096d11a8cbba25c933f4335fc7369e77f2328bd26
3
  size 5043
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3839b27ece3a2bd7caf37a5285674a88abf026c6f8bff550c47a84b4846f0ac
3
  size 5043
filters/ridge detection/server.onnx DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:42f9914e64003c33c7eceb639a001ceb4460c8226e0e380cb032741851e41c49
3
- size 648
 
 
 
 
filters/rotate/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a7a3c2ae45ef9887682e3e89d4138b2ce74b8e560b858f3adc0461f98f223f3f
3
- size 531
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0245406eed38f2a0c5f0afdacd5aab3746b5c7f3542f77a1ac2962355d732dbb
3
+ size 378
filters/rotate/deployment/serialized_processing.json DELETED
@@ -1 +0,0 @@
1
- {"filter_name": "rotate"}
 
 
filters/rotate/deployment/server.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a92a49387f05f4548cb4910506e66a6a2fa591b8f27818934d4283c8c2981a99
3
  size 4431
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3abdc1b55d1c63783b2d081ff67ca47c20b02ae1fd462a6398f7a80318c8529d
3
  size 4431
filters/rotate/server.onnx DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:aa03ea9a684b65c29c2cc0e6ab20f6b6349f35c4bd70921d264e74298a758de1
3
- size 178
 
 
 
 
filters/sharpen/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8cf53584e83a91cb975e9f078ef63e777f11453582b664f65685b3a6da89f17e
3
- size 550
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21c933a828da907162224c3d13fb1b546316fa0be838ee6ee94659a27302ae67
3
+ size 396
filters/sharpen/deployment/serialized_processing.json DELETED
@@ -1 +0,0 @@
1
- {"filter_name": "sharpen"}
 
 
filters/sharpen/deployment/server.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4710fbe92afdd4f8f6beff7eca302a46ee4fde5b85fe8aa7d6ab832080ae5a2e
3
  size 7311
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a137527248ec826be5b971f645e80be95c614f82c47225d73fc11d803df93d26
3
  size 7311
filters/sharpen/server.onnx DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c7958a3c9be1b578486ec1708701340263ce3ad70b7cd3ff281230797f67de0d
3
- size 532
 
 
 
 
generate_dev_files.py CHANGED
@@ -1,7 +1,6 @@
1
  "A script to generate all development files necessary for the image filtering demo."
2
 
3
  import shutil
4
- import onnx
5
  from common import AVAILABLE_FILTERS, FILTERS_PATH
6
  from filters import Filter
7
  from client_server_interface import FHEDev
@@ -17,11 +16,8 @@ for filter_name in AVAILABLE_FILTERS:
17
  # Compile the model on a representative inputset
18
  filter.compile()
19
 
20
- # Define the directory path associated to this filter
21
- filter_path = FILTERS_PATH / filter_name
22
-
23
  # Define the directory path associated to this filter's deployment files
24
- deployment_path = filter_path / "deployment"
25
 
26
  # Delete the deployment folder and its content if it already exists
27
  if deployment_path.is_dir():
@@ -31,7 +27,4 @@ for filter_name in AVAILABLE_FILTERS:
31
  fhe_dev_filter = FHEDev(filter, deployment_path)
32
  fhe_dev_filter.save()
33
 
34
- # Save the ONNX model
35
- onnx.save(filter.onnx_graph, filter_path / "server.onnx")
36
-
37
  print("Done !")
 
1
  "A script to generate all development files necessary for the image filtering demo."
2
 
3
  import shutil
 
4
  from common import AVAILABLE_FILTERS, FILTERS_PATH
5
  from filters import Filter
6
  from client_server_interface import FHEDev
 
16
  # Compile the model on a representative inputset
17
  filter.compile()
18
 
 
 
 
19
  # Define the directory path associated to this filter's deployment files
20
+ deployment_path = FILTERS_PATH / (filter_name + "/deployment")
21
 
22
  # Delete the deployment folder and its content if it already exists
23
  if deployment_path.is_dir():
 
27
  fhe_dev_filter = FHEDev(filter, deployment_path)
28
  fhe_dev_filter.save()
29
 
 
 
 
30
  print("Done !")