English
detection
open-world
open-set
Inference Endpoints
kelvinou01 commited on
Commit
d846043
1 Parent(s): 9156bad

Add custom handler

Browse files
Files changed (1) hide show
  1. handler.py +23 -0
handler.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from typing import Dict, List, Any
3
+
4
+ class EndpointHandler():
5
+ def __init__(self, path=""):
6
+ # Preload all the elements you are going to need at inference.
7
+ pass
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
+ image = data.pop("image")
18
+ prompt = data.pop("prompt")
19
+
20
+ return [{
21
+ "image": image,
22
+ "prompt": prompt,
23
+ }]