From f76686ff1c7193ca20457d15ff6f5c681732d117 Mon Sep 17 00:00:00 2001 From: Tau-J <674106399@qq.com> Date: Mon, 13 Mar 2023 19:41:56 +0800 Subject: [PATCH 1/3] show keypoint indexes --- demo/bottomup_demo.py | 3 ++- demo/image_demo.py | 6 ++++++ demo/topdown_demo_with_mmdet.py | 6 ++++++ mmpose/visualization/local_visualizer.py | 18 +++++++++++++++--- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/demo/bottomup_demo.py b/demo/bottomup_demo.py index acc588742e..3e5ea27218 100644 --- a/demo/bottomup_demo.py +++ b/demo/bottomup_demo.py @@ -34,8 +34,9 @@ def process_one_image(args, img_path, pose_estimator, visualizer, data_sample=results, draw_gt=False, draw_bbox=False, - show=args.show, draw_heatmap=args.draw_heatmap, + show_kpt_idx=args.show_kpt_idx, + show=args.show, wait_time=show_interval, out_file=out_file, kpt_score_thr=args.kpt_thr) diff --git a/demo/image_demo.py b/demo/image_demo.py index d595ed43c9..0aa4a9e057 100644 --- a/demo/image_demo.py +++ b/demo/image_demo.py @@ -20,6 +20,11 @@ def parse_args(): '--draw-heatmap', action='store_true', help='Visualize the predicted heatmap') + parser.add_argument( + '--show-kpt-idx', + action='store_true', + default=False, + help='Whether to show the index of keypoints') parser.add_argument( '--show', action='store_true', @@ -61,6 +66,7 @@ def main(): draw_gt=False, draw_bbox=True, draw_heatmap=args.draw_heatmap, + show_kpt_idx=args.show_kpt_idx, show=args.show, out_file=args.out_file) diff --git a/demo/topdown_demo_with_mmdet.py b/demo/topdown_demo_with_mmdet.py index f1a4e42b4d..418f3695b9 100644 --- a/demo/topdown_demo_with_mmdet.py +++ b/demo/topdown_demo_with_mmdet.py @@ -54,6 +54,7 @@ def process_one_image(args, img_path, detector, pose_estimator, visualizer, draw_gt=False, draw_heatmap=args.draw_heatmap, draw_bbox=args.draw_bbox, + show_kpt_idx=args.show_kpt_idx, show=args.show, wait_time=show_interval, out_file=out_file, @@ -115,6 +116,11 @@ def main(): action='store_true', default=False, help='Draw heatmap predicted by the model') + parser.add_argument( + '--show-kpt-idx', + action='store_true', + default=False, + help='Whether to show the index of keypoints') parser.add_argument( '--radius', type=int, diff --git a/mmpose/visualization/local_visualizer.py b/mmpose/visualization/local_visualizer.py index ba0a8cfdff..efa4ff1549 100644 --- a/mmpose/visualization/local_visualizer.py +++ b/mmpose/visualization/local_visualizer.py @@ -211,7 +211,8 @@ def _draw_instances_bbox(self, image: np.ndarray, def _draw_instances_kpts(self, image: np.ndarray, instances: InstanceData, - kpt_score_thr: float = 0.3): + kpt_score_thr: float = 0.3, + show_kpt_idx: bool = False): """Draw keypoints and skeletons (optional) of GT or prediction. Args: @@ -276,6 +277,14 @@ def _draw_instances_kpts(self, edge_colors=color, alpha=transparency, line_widths=self.radius) + if show_kpt_idx: + self.draw_texts( + str(kid), + kpt, + colors=color, + font_sizes=self.radius * 2, + vertical_alignments='bottom', + horizontal_alignments='center') # draw links if self.skeleton is not None and self.link_color is not None: @@ -400,6 +409,7 @@ def add_datasample(self, draw_pred: bool = True, draw_heatmap: bool = False, draw_bbox: bool = False, + show_kpt_idx: bool = False, show: bool = False, wait_time: float = 0, out_file: Optional[str] = None, @@ -448,7 +458,8 @@ def add_datasample(self, # draw bboxes & keypoints if 'gt_instances' in data_sample: gt_img_data = self._draw_instances_kpts( - gt_img_data, data_sample.gt_instances, kpt_score_thr) + gt_img_data, data_sample.gt_instances, kpt_score_thr, + show_kpt_idx) if draw_bbox: gt_img_data = self._draw_instances_bbox( gt_img_data, data_sample.gt_instances) @@ -468,7 +479,8 @@ def add_datasample(self, # draw bboxes & keypoints if 'pred_instances' in data_sample: pred_img_data = self._draw_instances_kpts( - pred_img_data, data_sample.pred_instances, kpt_score_thr) + pred_img_data, data_sample.pred_instances, kpt_score_thr, + show_kpt_idx) if draw_bbox: pred_img_data = self._draw_instances_bbox( pred_img_data, data_sample.pred_instances) From ba915e78a881b7f7661d40011c4bc925f83ca448 Mon Sep 17 00:00:00 2001 From: Tau-J <674106399@qq.com> Date: Mon, 13 Mar 2023 19:45:53 +0800 Subject: [PATCH 2/3] show keypoint indexes --- mmpose/visualization/local_visualizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmpose/visualization/local_visualizer.py b/mmpose/visualization/local_visualizer.py index efa4ff1549..fdb30026f5 100644 --- a/mmpose/visualization/local_visualizer.py +++ b/mmpose/visualization/local_visualizer.py @@ -282,7 +282,7 @@ def _draw_instances_kpts(self, str(kid), kpt, colors=color, - font_sizes=self.radius * 2, + font_sizes=self.radius * 10, vertical_alignments='bottom', horizontal_alignments='center') From 8d89d67b69660037aa4065b87d4694998caa5703 Mon Sep 17 00:00:00 2001 From: Tau-J <674106399@qq.com> Date: Mon, 13 Mar 2023 23:21:35 +0800 Subject: [PATCH 3/3] show keypoint indexes --- demo/bottomup_demo.py | 5 +++++ mmpose/visualization/local_visualizer.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/demo/bottomup_demo.py b/demo/bottomup_demo.py index 3e5ea27218..8d27a17178 100644 --- a/demo/bottomup_demo.py +++ b/demo/bottomup_demo.py @@ -72,6 +72,11 @@ def parse_args(): '--draw-heatmap', action='store_true', help='Visualize the predicted heatmap') + parser.add_argument( + '--show-kpt-idx', + action='store_true', + default=False, + help='Whether to show the index of keypoints') parser.add_argument( '--kpt-thr', type=float, default=0.3, help='Keypoint score threshold') parser.add_argument( diff --git a/mmpose/visualization/local_visualizer.py b/mmpose/visualization/local_visualizer.py index fdb30026f5..1743ef7997 100644 --- a/mmpose/visualization/local_visualizer.py +++ b/mmpose/visualization/local_visualizer.py @@ -282,7 +282,7 @@ def _draw_instances_kpts(self, str(kid), kpt, colors=color, - font_sizes=self.radius * 10, + font_sizes=self.radius * 3, vertical_alignments='bottom', horizontal_alignments='center')