From f3fb639c67a610670761a80a5c4ec22f0596d3d2 Mon Sep 17 00:00:00 2001 From: lupeng Date: Fri, 18 Nov 2022 12:46:33 +0800 Subject: [PATCH 1/3] remove gaussian blur for offset in udp-regress --- .../body_2d_keypoint/topdown_heatmap/coco/hrnet_udp_coco.md | 2 +- mmpose/codecs/udp_heatmap.py | 5 +---- mmpose/codecs/utils/offset_heatmap.py | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/configs/body_2d_keypoint/topdown_heatmap/coco/hrnet_udp_coco.md b/configs/body_2d_keypoint/topdown_heatmap/coco/hrnet_udp_coco.md index 8f4e67597f..34e05740fb 100644 --- a/configs/body_2d_keypoint/topdown_heatmap/coco/hrnet_udp_coco.md +++ b/configs/body_2d_keypoint/topdown_heatmap/coco/hrnet_udp_coco.md @@ -58,6 +58,6 @@ Results on COCO val2017 with detector having human AP of 56.4 on COCO val2017 da | [pose_hrnet_w32_udp](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_udp-8xb64-210e_coco-384x288.py) | 384x288 | 0.768 | 0.909 | 0.832 | 0.815 | 0.945 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_udp-8xb64-210e_coco-384x288-9a3f7c85_20220914.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_udp-8xb64-210e_coco-384x288_20220914.log) | | [pose_hrnet_w48_udp](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w48_udp-8xb32-210e_coco-256x192.py) | 256x192 | 0.768 | 0.908 | 0.833 | 0.817 | 0.945 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w48_udp-8xb32-210e_coco-256x192-3feaef8f_20220913.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w48_udp-8xb32-210e_coco-256x192_20220913.log) | | [pose_hrnet_w48_udp](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w48_udp-8xb32-210e_coco-384x288.py) | 384x288 | 0.773 | 0.911 | 0.836 | 0.821 | 0.946 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w48_udp-8xb32-210e_coco-384x288-70d7ab01_20220913.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w48_udp-8xb32-210e_coco-384x288_20220913.log) | -| [pose_hrnet_w32_udp_regress](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_udp-regress-8xb64-210e_coco-256x192.py) | 256x192 | 0.757 | 0.907 | 0.824 | 0.812 | 0.942 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_udp-regress-8xb64-210e_coco-256x192-9c0b77b4_20220926.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_udp-regress-8xb64-210e_coco-256x192_20220226.log) | +| [pose_hrnet_w32_udp_regress](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_udp-regress-8xb64-210e_coco-256x192.py) | 256x192 | 0.759 | 0.907 | 0.827 | 0.813 | 0.943 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_udp-regress-8xb64-210e_coco-256x192-9c0b77b4_20220926.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_udp-regress-8xb64-210e_coco-256x192_20220226.log) | Note that, UDP also adopts the unbiased encoding/decoding algorithm of [DARK](https://mmpose.readthedocs.io/en/1.x/model_zoo_papers/techniques.html#darkpose-cvpr-2020). diff --git a/mmpose/codecs/udp_heatmap.py b/mmpose/codecs/udp_heatmap.py index 18caad4abf..d915fe2055 100644 --- a/mmpose/codecs/udp_heatmap.py +++ b/mmpose/codecs/udp_heatmap.py @@ -163,10 +163,7 @@ def decode(self, encoded: np.ndarray) -> Tuple[np.ndarray, np.ndarray]: if k % 3 == 0: # for classification map ks = 2 * self.blur_kernel_size + 1 - else: - # for offset map - ks = self.blur_kernel_size - cv2.GaussianBlur(heatmaps[k], (ks, ks), 0, heatmaps[k]) + cv2.GaussianBlur(heatmaps[k], (ks, ks), 0, heatmaps[k]) # valid radius radius = self.radius_factor * max(W, H) diff --git a/mmpose/codecs/utils/offset_heatmap.py b/mmpose/codecs/utils/offset_heatmap.py index 5b017ffd5b..64b757bd31 100644 --- a/mmpose/codecs/utils/offset_heatmap.py +++ b/mmpose/codecs/utils/offset_heatmap.py @@ -63,8 +63,6 @@ def generate_offset_heatmap( heatmaps[k, 1] = x_offset heatmaps[k, 2] = y_offset - # keep only valid region in offset maps - heatmaps[:, 1:] *= heatmaps[:, :1] heatmaps = heatmaps.reshape(K * 3, H, W) return heatmaps, keypoint_weights From 95e55021a09c2de53899c129267de10619e9f3db Mon Sep 17 00:00:00 2001 From: lupeng Date: Fri, 18 Nov 2022 17:26:16 +0800 Subject: [PATCH 2/3] resolve comments --- mmpose/codecs/udp_heatmap.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mmpose/codecs/udp_heatmap.py b/mmpose/codecs/udp_heatmap.py index d915fe2055..b78707c748 100644 --- a/mmpose/codecs/udp_heatmap.py +++ b/mmpose/codecs/udp_heatmap.py @@ -159,11 +159,10 @@ def decode(self, encoded: np.ndarray) -> Tuple[np.ndarray, np.ndarray]: elif self.heatmap_type == 'combined': _K, H, W = heatmaps.shape K = _K // 3 - for k in range(_K): - if k % 3 == 0: - # for classification map - ks = 2 * self.blur_kernel_size + 1 - cv2.GaussianBlur(heatmaps[k], (ks, ks), 0, heatmaps[k]) + + for cls_heatmap in heatmaps[::3]: + ks = 2 * self.blur_kernel_size + 1 + cv2.GaussianBlur(cls_heatmap, (ks, ks), 0, cls_heatmap) # valid radius radius = self.radius_factor * max(W, H) From d21f60e56d49a57789c736ac3f253f1e8cb79987 Mon Sep 17 00:00:00 2001 From: Yining Li Date: Wed, 23 Nov 2022 13:25:18 +0800 Subject: [PATCH 3/3] Update udp_heatmap.py --- mmpose/codecs/udp_heatmap.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mmpose/codecs/udp_heatmap.py b/mmpose/codecs/udp_heatmap.py index b78707c748..c38ea17be4 100644 --- a/mmpose/codecs/udp_heatmap.py +++ b/mmpose/codecs/udp_heatmap.py @@ -161,6 +161,7 @@ def decode(self, encoded: np.ndarray) -> Tuple[np.ndarray, np.ndarray]: K = _K // 3 for cls_heatmap in heatmaps[::3]: + # Apply Gaussian blur on classification maps ks = 2 * self.blur_kernel_size + 1 cv2.GaussianBlur(cls_heatmap, (ks, ks), 0, cls_heatmap)