romanbredehoft-zama commited on
Commit
a13c444
1 Parent(s): 75bc44e

Update Concrete ML version and re-generate development files

Browse files
client_server_interface.py CHANGED
@@ -1,6 +1,6 @@
1
  "Client-server interface custom implementation for filter models."
2
 
3
- import concrete.numpy as cnp
4
 
5
  from filters import Filter
6
 
@@ -17,7 +17,7 @@ class FHEServer:
17
  self.path_dir = path_dir
18
 
19
  # Load the FHE circuit
20
- self.server = cnp.Server.load(self.path_dir / "server.zip")
21
 
22
  def run(self, serialized_encrypted_image, serialized_evaluation_keys):
23
  """Run the filter on the server over an encrypted image.
@@ -30,20 +30,14 @@ class FHEServer:
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
 
@@ -98,7 +92,7 @@ class FHEClient:
98
  assert path_dir.exists(), f"{path_dir} does not exist. Please specify a valid path."
99
 
100
  # Load the client
101
- self.client = cnp.Client.load(self.path_dir / "client.zip", self.key_dir)
102
 
103
  # Instantiate the filter
104
  self.filter = Filter(filter_name)
@@ -132,7 +126,7 @@ class FHEClient:
132
  encrypted_image = self.client.encrypt(input_image)
133
 
134
  # Serialize the encrypted image to be sent to the server
135
- serialized_encrypted_image = self.client.specs.serialize_public_args(encrypted_image)
136
  return serialized_encrypted_image
137
 
138
  def deserialize_decrypt_post_process(self, serialized_encrypted_output_image):
@@ -145,7 +139,7 @@ class FHEClient:
145
  numpy.ndarray: The decrypted, deserialized and post-processed image.
146
  """
147
  # Deserialize the encrypted image
148
- encrypted_output_image = self.client.specs.unserialize_public_result(
149
  serialized_encrypted_output_image
150
  )
151
 
 
1
  "Client-server interface custom implementation for filter models."
2
 
3
+ from concrete import fhe
4
 
5
  from filters import Filter
6
 
 
17
  self.path_dir = path_dir
18
 
19
  # Load the FHE circuit
20
+ self.server = fhe.Server.load(self.path_dir / "server.zip")
21
 
22
  def run(self, serialized_encrypted_image, serialized_evaluation_keys):
23
  """Run the filter on the server over an encrypted image.
 
30
  bytes: The filter's output.
31
  """
32
  # Deserialize the encrypted input image and the evaluation keys
33
+ encrypted_image = fhe.Value.deserialize(serialized_encrypted_image)
34
+ evaluation_keys = fhe.EvaluationKeys.deserialize(serialized_evaluation_keys)
 
 
35
 
36
  # Execute the filter in FHE
37
+ encrypted_output = self.server.run(encrypted_image, evaluation_keys=evaluation_keys)
 
 
38
 
39
  # Serialize the encrypted output image
40
+ serialized_encrypted_output = encrypted_output.serialize()
 
 
41
 
42
  return serialized_encrypted_output
43
 
 
92
  assert path_dir.exists(), f"{path_dir} does not exist. Please specify a valid path."
93
 
94
  # Load the client
95
+ self.client = fhe.Client.load(self.path_dir / "client.zip", self.key_dir)
96
 
97
  # Instantiate the filter
98
  self.filter = Filter(filter_name)
 
126
  encrypted_image = self.client.encrypt(input_image)
127
 
128
  # Serialize the encrypted image to be sent to the server
129
+ serialized_encrypted_image = encrypted_image.serialize()
130
  return serialized_encrypted_image
131
 
132
  def deserialize_decrypt_post_process(self, serialized_encrypted_output_image):
 
139
  numpy.ndarray: The decrypted, deserialized and post-processed image.
140
  """
141
  # Deserialize the encrypted image
142
+ encrypted_output_image = fhe.Value.deserialize(
143
  serialized_encrypted_output_image
144
  )
145
 
filters.py CHANGED
@@ -5,7 +5,7 @@ import torch
5
  from torch import nn
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.torch.numpy_module import NumpyModule
11
 
 
5
  from torch import nn
6
  from common import AVAILABLE_FILTERS, INPUT_SHAPE
7
 
8
+ from concrete.fhe.compilation.compiler import Compiler
9
  from concrete.ml.common.utils import generate_proxy_function
10
  from concrete.ml.torch.numpy_module import NumpyModule
11
 
filters/black and white/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:009a1f53994ae2776806eef65f516b40b8366b7e16d28b4037bdeebf3f742261
3
- size 378
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f224e21a8a189c8b9431de533c3401f174fe97f455b347309256d5c61c91c2f
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:f1e3227d75f87cad545ba34391f23b1aa37fc808cb6a2e3ec34f76e3ab1af0b9
3
- size 5871
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6811bb8621f87ceb1c7eaa18439daabe0400d3f206e6fb7d034b7258ab3f47e7
3
+ size 5120
filters/blur/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ad80a31b1f0aae22fa3520319f30ccea41210223946e74c00a8c7493cc1c7b46
3
- size 391
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:784113c8aa6256ae136dcdcef246eb726c0a30a7bf79f91fc458e13cfdaeed66
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:5c58d04b6c75c926a0d98dc3376761dea78445a27224d63ab37e01a062b1781d
3
- size 8716
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc03fc47e2f1c4ddedcf9e0dd9c46890b79e0de5c75bc3523c0be9eb504fc544
3
+ size 7356
filters/identity/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:69590288fb2da2e41d772572e959e6ea01e26836ae412e36f927b1a4e7998fb0
3
- size 376
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2ff4b6d075e418d6577f88fe77e580949023837708a52cd377fa4388d38ad1f
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:c8221f0473d76d0df4242e03b339068276e865b67748cb87f4a3c71eebf99ffe
3
- size 2537
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5a2cd8e175ff9b99dc1b9700884ae40c24afc7375005833f7410dcd73f0cfee
3
+ size 2818
filters/inverted/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:433a5406b400f59ada754ebd0ff1cc55cdcffaf628acf82f24820fdb2b3d3fb4
3
- size 376
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2ff4b6d075e418d6577f88fe77e580949023837708a52cd377fa4388d38ad1f
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:16ee970649f7dcc0be9fe5ca4de1fd0077b307956761aa45b48ae78eb3ab2f7a
3
- size 4152
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb99ecacca176c7f5cca0fbf577af46495e028074169495aa3f6af5beafa1855
3
+ size 4026
filters/ridge detection/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:233f8eb49ac2a5d4fe6bb761c1234249c18f13c6a6158548f5489f78bdb780ed
3
- size 396
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6d461d356570d465d012715048d824b76b31668d80678e5e5083e9c8a93e6e6
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:1b662157b5b7517a18b0a6cacb9c1800b124424f38a5a4230829c7a1ddb2a62b
3
- size 6697
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0275c0bc7fbc90b19ccc16b87d220fd9be72cef303775245725845b1f1f918d7
3
+ size 6082
filters/rotate/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:433a5406b400f59ada754ebd0ff1cc55cdcffaf628acf82f24820fdb2b3d3fb4
3
- size 376
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2ff4b6d075e418d6577f88fe77e580949023837708a52cd377fa4388d38ad1f
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:b55e20b3c46d9609a1f2c0be3b3db5bd0d4e288061a1428e17c9abbe67ed3e10
3
- size 4387
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfc258c33a41a748949729e0a443c7f667b1b5b52db43966d2e8257979a82b36
3
+ size 3831
filters/sharpen/deployment/client.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:789caedfe972a3108187614b66d15bca0a64fa0bb24840cbec9e8f93211f3750
3
- size 396
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63bdea70a18addfa2ee8667a6be682f4b9856b9776a707f2ecebe56359066897
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:23fe93ee2d0154c15eeae9aacc2f1b4bb41c3a832b9c71b91406e0190138e451
3
- size 8735
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0635f6e814ad6a55806d93d804afea95c264b30c08dc81b110d4a8b348b701f9
3
+ size 7891
requirements.txt CHANGED
@@ -1,4 +1,2 @@
1
- concrete-ml==0.6.1
2
  gradio==3.11.0
3
- uvicorn==0.20.0
4
- fastapi==0.87.0
 
1
+ concrete-ml==1.1.0
2
  gradio==3.11.0