Update handler.py
Browse files- handler.py +3 -0
handler.py
CHANGED
|
@@ -18,6 +18,7 @@ class EndpointHandler:
|
|
| 18 |
key = inputs.get("key")
|
| 19 |
########################### Load Image #################################
|
| 20 |
CLIENT = InferenceHTTPClient(api_url="https://detect.roboflow.com", api_key=key)
|
|
|
|
| 21 |
if isurl: # for url set isurl = 1
|
| 22 |
req = urllib.request.urlopen(path)
|
| 23 |
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
|
|
@@ -32,6 +33,7 @@ class EndpointHandler:
|
|
| 32 |
# clothing-segmentation-dataset/1
|
| 33 |
# t-shirts-detector/1
|
| 34 |
# mainmodel/2
|
|
|
|
| 35 |
result = CLIENT.infer(path, model_id="mainmodel/2")
|
| 36 |
detections = sv.Detections.from_inference(result)
|
| 37 |
# print(detections)
|
|
@@ -40,6 +42,7 @@ class EndpointHandler:
|
|
| 40 |
########################### Data proccessing #################################
|
| 41 |
# only pass the first detection
|
| 42 |
# change 1 -> to len(detections.xyxy) to pass all photos
|
|
|
|
| 43 |
if detections.confidence.size == 0:
|
| 44 |
return "Not Found"
|
| 45 |
else:
|
|
|
|
| 18 |
key = inputs.get("key")
|
| 19 |
########################### Load Image #################################
|
| 20 |
CLIENT = InferenceHTTPClient(api_url="https://detect.roboflow.com", api_key=key)
|
| 21 |
+
print("get client")
|
| 22 |
if isurl: # for url set isurl = 1
|
| 23 |
req = urllib.request.urlopen(path)
|
| 24 |
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
|
|
|
|
| 33 |
# clothing-segmentation-dataset/1
|
| 34 |
# t-shirts-detector/1
|
| 35 |
# mainmodel/2
|
| 36 |
+
print("start model detection")
|
| 37 |
result = CLIENT.infer(path, model_id="mainmodel/2")
|
| 38 |
detections = sv.Detections.from_inference(result)
|
| 39 |
# print(detections)
|
|
|
|
| 42 |
########################### Data proccessing #################################
|
| 43 |
# only pass the first detection
|
| 44 |
# change 1 -> to len(detections.xyxy) to pass all photos
|
| 45 |
+
print("Data processing")
|
| 46 |
if detections.confidence.size == 0:
|
| 47 |
return "Not Found"
|
| 48 |
else:
|