From 2223b9f16a7d88714ce415cc20ec384bec64afc3 Mon Sep 17 00:00:00 2001 From: "shouzhou.bx" Date: Mon, 19 Sep 2022 09:44:19 +0800 Subject: [PATCH] [to #42322933] format body 2d keypoint output boxes Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10158585 --- modelscope/outputs.py | 6 +++--- modelscope/pipelines/cv/body_2d_keypoints_pipeline.py | 5 ++++- modelscope/utils/cv/image_utils.py | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modelscope/outputs.py b/modelscope/outputs.py index d7d619bf..b3eb9ad8 100644 --- a/modelscope/outputs.py +++ b/modelscope/outputs.py @@ -202,9 +202,9 @@ TASK_OUTPUTS = { # [[score]*15] # ] # "boxes": [ - # [[x1, y1], [x2, y2]], - # [[x1, y1], [x2, y2]], - # [[x1, y1], [x2, y2]], + # [x1, y1, x2, y2], + # [x1, y1, x2, y2], + # [x1, y1, x2, y2], # ] # } Tasks.body_2d_keypoints: diff --git a/modelscope/pipelines/cv/body_2d_keypoints_pipeline.py b/modelscope/pipelines/cv/body_2d_keypoints_pipeline.py index f9ae4b2c..c6a05195 100644 --- a/modelscope/pipelines/cv/body_2d_keypoints_pipeline.py +++ b/modelscope/pipelines/cv/body_2d_keypoints_pipeline.py @@ -76,8 +76,11 @@ class Body2DKeypointsPipeline(Pipeline): } poses, scores, boxes = self.keypoint_model.postprocess(input) + result_boxes = [] + for box in boxes: + result_boxes.append([box[0][0], box[0][1], box[1][0], box[1][1]]) return { - OutputKeys.BOXES: boxes, + OutputKeys.BOXES: result_boxes, OutputKeys.POSES: poses, OutputKeys.SCORES: scores } diff --git a/modelscope/utils/cv/image_utils.py b/modelscope/utils/cv/image_utils.py index 6175a53f..9ec2c4f3 100644 --- a/modelscope/utils/cv/image_utils.py +++ b/modelscope/utils/cv/image_utils.py @@ -66,8 +66,8 @@ def draw_joints(image, np_kps, score, threshold=0.2): def draw_box(image, box): - cv2.rectangle(image, (int(box[0][0]), int(box[0][1])), - (int(box[1][0]), int(box[1][1])), (0, 0, 255), 2) + cv2.rectangle(image, (int(box[0]), int(box[1])), + (int(box[2]), int(box[3])), (0, 0, 255), 2) def realtime_object_detection_bbox_vis(image, bboxes):