oscarfu0501 commited on
Commit
ee790b1
1 Parent(s): 714e84b

Upload handler.py

Browse files
Files changed (1) hide show
  1. handler.py +6 -5
handler.py CHANGED
@@ -8,17 +8,18 @@ from inference_sdk import InferenceHTTPClient
8
 
9
  class EndpointHandler():
10
  def __init__(self, key): #pass api key to model
11
- self.CLIENT = InferenceHTTPClient(
12
- api_url="https://detect.roboflow.com",
13
- api_key=key
14
- )
15
- print(key)
16
 
17
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
18
  inputs = data.get("inputs")
19
  isurl = inputs.get("isurl")
20
  path = inputs.get("path")
 
21
  ########################### Load Image #################################
 
 
 
 
22
  if(isurl): # for url set isurl = 1
23
  req = urllib.request.urlopen(path)
24
  arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
 
8
 
9
  class EndpointHandler():
10
  def __init__(self, key): #pass api key to model
11
+ pass
 
 
 
 
12
 
13
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
14
  inputs = data.get("inputs")
15
  isurl = inputs.get("isurl")
16
  path = inputs.get("path")
17
+ key = inputs.get("key")
18
  ########################### Load Image #################################
19
+ self.CLIENT = InferenceHTTPClient(
20
+ api_url="https://detect.roboflow.com",
21
+ api_key=key
22
+ )
23
  if(isurl): # for url set isurl = 1
24
  req = urllib.request.urlopen(path)
25
  arr = np.asarray(bytearray(req.read()), dtype=np.uint8)