Srijith Rajamohan commited on
Commit
ef2841e
·
1 Parent(s): c3b8449

Added custom handler

Browse files
Files changed (1) hide show
  1. handler.py +22 -0
handler.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List, Any
2
+
3
+ class EndpointHandler():
4
+ def __init__(self, path=""):
5
+ # Preload all the elements you are going to need at inference.
6
+ # pseudo:
7
+ self.model= load_model(path)
8
+
9
+ def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
10
+ """
11
+ data args:
12
+ inputs (:obj: `str` | `PIL.Image` | `np.array`)
13
+ kwargs
14
+ Return:
15
+ A :obj:`list` | `dict`: will be serialized and returned
16
+ """
17
+
18
+ # pseudo
19
+ inputs = data.pop("inputs", data)
20
+ #self.model(input)
21
+
22
+ return [{"outputs": inputs}]