Skip to content

Commit

Permalink
Prompt friendly messages if the docker_torchserve returns an error #…
Browse files Browse the repository at this point in the history
  • Loading branch information
yihleego committed Apr 27, 2023
1 parent ceda092 commit 1615d50
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/image_to_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def image_to_annotations(img_fn: str, out_dir: str) -> None:
img_b = cv2.imencode('.png', img)[1].tobytes()
request_data = {'data': img_b}
resp = requests.post("http://localhost:8080/predictions/drawn_humanoid_detector", files=request_data, verify=False)
if resp is None or resp.status_code >= 300:
raise Exception(f"Failed to get bounding box, please check if the 'docker_torchserve' is running and healthy, resp: {resp}")

detection_results = json.loads(resp.content)

# error check detection_results
Expand Down Expand Up @@ -90,6 +93,9 @@ def image_to_annotations(img_fn: str, out_dir: str) -> None:
# send cropped image to pose estimator
data_file = {'data': cv2.imencode('.png', cropped)[1].tobytes()}
resp = requests.post("http://localhost:8080/predictions/drawn_humanoid_pose_estimator", files=data_file, verify=False)
if resp is None or resp.status_code >= 300:
raise Exception(f"Failed to get skeletons, please check if the 'docker_torchserve' is running and healthy, resp: {resp}")

pose_results = json.loads(resp.content)

# error check pose_results
Expand Down

0 comments on commit 1615d50

Please sign in to comment.