File size: 847 Bytes
be526a2
 
df9cd1e
be526a2
 
 
25daa45
be526a2
 
25daa45
be526a2
 
 
 
 
 
 
 
 
 
57da008
ba3700b
be526a2
57da008
ba3700b
be526a2
57da008
 
be526a2
ba3700b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from typing import Dict, List, Any
import numpy as np
from concrete.ml.deployment import FHEModelServer


class EndpointHandler:
    def __init__(self, path=""):

        # For server
        self.fhemodel_server = FHEModelServer(path + "/compiled_model")

    def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
        """
         data args:
              inputs (:obj: `str`)
              date (:obj: `str`)
        Return:
              A :obj:`list` | `dict`: will be serialized and returned
        """

        # Get inputs
        encrypted_inputs = data.pop("encrypted_inputs", data)

        # Get keys
        evaluation_keys = data.pop("evaluation_keys", data)

        # Run CML prediction
        encrypted_prediction = self.fhemodel_server.run(encrypted_inputs, evaluation_keys)

        return encrypted_prediction