binoua commited on
Commit
5ac98ad
1 Parent(s): 57da008

Upload handler.py

Browse files
Files changed (1) hide show
  1. handler.py +7 -2
handler.py CHANGED
@@ -3,6 +3,11 @@ import numpy as np
3
  from concrete.ml.deployment import FHEModelServer
4
 
5
 
 
 
 
 
 
6
  class EndpointHandler:
7
  def __init__(self, path="benoit.model"):
8
 
@@ -19,10 +24,10 @@ class EndpointHandler:
19
  """
20
 
21
  # Get inputs
22
- encrypted_inputs = data.pop("encrypted_inputs", data)
23
 
24
  # Get keys
25
- evaluation_keys = data.pop("evaluation_keys", data)
26
 
27
  # Run CML prediction
28
  encrypted_prediction = self.fhemodel_server.run(encrypted_inputs, evaluation_keys)
 
3
  from concrete.ml.deployment import FHEModelServer
4
 
5
 
6
+ def from_json(python_object):
7
+ if "__class__" in python_object:
8
+ return bytes(python_object["__value__"])
9
+
10
+
11
  class EndpointHandler:
12
  def __init__(self, path="benoit.model"):
13
 
 
24
  """
25
 
26
  # Get inputs
27
+ encrypted_inputs = from_json(data.pop("encrypted_inputs", data))
28
 
29
  # Get keys
30
+ evaluation_keys = from_json(data.pop("evaluation_keys", data))
31
 
32
  # Run CML prediction
33
  encrypted_prediction = self.fhemodel_server.run(encrypted_inputs, evaluation_keys)