From 54a784602dd88482990b4dbb1d718b81e131d8cd Mon Sep 17 00:00:00 2001 From: ly015 Date: Wed, 22 Feb 2023 10:33:31 +0800 Subject: [PATCH 1/3] fix a bug in swin initialization --- mmpose/models/backbones/swin.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mmpose/models/backbones/swin.py b/mmpose/models/backbones/swin.py index a3462931b2..9e076c174f 100644 --- a/mmpose/models/backbones/swin.py +++ b/mmpose/models/backbones/swin.py @@ -1,5 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from collections import OrderedDict from copy import deepcopy import torch @@ -668,13 +667,11 @@ def init_weights(self, pretrained=None): and self.init_cfg['type'] == 'Pretrained'): # Suppress zero_init_residual if use pretrained model. logger = get_root_logger() - _state_dict = get_state_dict( + state_dict = get_state_dict( self.init_cfg['checkpoint'], map_location='cpu') if self.convert_weights: # supported loading weight from original repo, - _state_dict = swin_converter(_state_dict) - - state_dict = OrderedDict() + state_dict = swin_converter(state_dict) # strip prefix of state_dict if list(state_dict.keys())[0].startswith('module.'): From bef2736e6494cbd98023b84e94a1096620dba9cb Mon Sep 17 00:00:00 2001 From: Yining Li Date: Wed, 22 Feb 2023 13:21:27 +0800 Subject: [PATCH 2/3] Update mmpose/models/backbones/swin.py Co-authored-by: Peng Lu --- mmpose/models/backbones/swin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmpose/models/backbones/swin.py b/mmpose/models/backbones/swin.py index 9e076c174f..a8f7c97278 100644 --- a/mmpose/models/backbones/swin.py +++ b/mmpose/models/backbones/swin.py @@ -670,7 +670,7 @@ def init_weights(self, pretrained=None): state_dict = get_state_dict( self.init_cfg['checkpoint'], map_location='cpu') if self.convert_weights: - # supported loading weight from original repo, + # supported loading weight from original repo state_dict = swin_converter(state_dict) # strip prefix of state_dict From 4fa4866502b1001f35d42389cef2735da6767b52 Mon Sep 17 00:00:00 2001 From: ly015 Date: Wed, 22 Feb 2023 18:20:39 +0800 Subject: [PATCH 3/3] fix paramwise_cfg --- .../td-hm_hrformer-base_8xb32-210e_coco-256x192.py | 6 +++--- .../td-hm_hrformer-base_8xb32-210e_coco-384x288.py | 6 +++--- .../td-hm_hrformer-small_8xb32-210e_coco-256x192.py | 6 +++--- .../td-hm_hrformer-small_8xb32-210e_coco-384x288.py | 6 +++--- .../td-hm_swin-l-p4-w7_8xb32-210e_coco-256x192.py | 13 +++++++------ .../td-hm_swin-l-p4-w7_8xb32-210e_coco-384x288.py | 13 +++++++------ 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-base_8xb32-210e_coco-256x192.py b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-base_8xb32-210e_coco-256x192.py index 480f8ecc62..af1397bf73 100644 --- a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-base_8xb32-210e_coco-256x192.py +++ b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-base_8xb32-210e_coco-256x192.py @@ -10,9 +10,9 @@ lr=5e-4, betas=(0.9, 0.999), weight_decay=0.01, - paramwise_cfg=dict( - custom_keys={'relative_position_bias_table': dict( - decay_mult=0.)}))) + ), + paramwise_cfg=dict( + custom_keys={'relative_position_bias_table': dict(decay_mult=0.)})) # learning policy param_scheduler = [ diff --git a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-base_8xb32-210e_coco-384x288.py b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-base_8xb32-210e_coco-384x288.py index 2f90bd3514..97d80e94aa 100644 --- a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-base_8xb32-210e_coco-384x288.py +++ b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-base_8xb32-210e_coco-384x288.py @@ -10,9 +10,9 @@ lr=5e-4, betas=(0.9, 0.999), weight_decay=0.01, - paramwise_cfg=dict( - custom_keys={'relative_position_bias_table': dict( - decay_mult=0.)}))) + ), + paramwise_cfg=dict( + custom_keys={'relative_position_bias_table': dict(decay_mult=0.)})) # learning policy param_scheduler = [ diff --git a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-small_8xb32-210e_coco-256x192.py b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-small_8xb32-210e_coco-256x192.py index 9e726b52f2..1d5123f44d 100644 --- a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-small_8xb32-210e_coco-256x192.py +++ b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-small_8xb32-210e_coco-256x192.py @@ -10,9 +10,9 @@ lr=5e-4, betas=(0.9, 0.999), weight_decay=0.01, - paramwise_cfg=dict( - custom_keys={'relative_position_bias_table': dict( - decay_mult=0.)}))) + ), + paramwise_cfg=dict( + custom_keys={'relative_position_bias_table': dict(decay_mult=0.)})) # learning policy param_scheduler = [ diff --git a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-small_8xb32-210e_coco-384x288.py b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-small_8xb32-210e_coco-384x288.py index 46cdeb3add..4fb03097bb 100644 --- a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-small_8xb32-210e_coco-384x288.py +++ b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrformer-small_8xb32-210e_coco-384x288.py @@ -10,9 +10,9 @@ lr=5e-4, betas=(0.9, 0.999), weight_decay=0.01, - paramwise_cfg=dict( - custom_keys={'relative_position_bias_table': dict( - decay_mult=0.)}))) + ), + paramwise_cfg=dict( + custom_keys={'relative_position_bias_table': dict(decay_mult=0.)})) # learning policy param_scheduler = [ diff --git a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_swin-l-p4-w7_8xb32-210e_coco-256x192.py b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_swin-l-p4-w7_8xb32-210e_coco-256x192.py index 2a437039b7..b1862fa3e0 100644 --- a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_swin-l-p4-w7_8xb32-210e_coco-256x192.py +++ b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_swin-l-p4-w7_8xb32-210e_coco-256x192.py @@ -10,12 +10,13 @@ lr=5e-4, betas=(0.9, 0.999), weight_decay=0.01, - paramwise_cfg=dict( - custom_keys={ - 'absolute_pos_embed': dict(decay_mult=0.), - 'relative_position_bias_table': dict(decay_mult=0.), - 'norm': dict(decay_mult=0.) - }))) + ), + paramwise_cfg=dict( + custom_keys={ + 'absolute_pos_embed': dict(decay_mult=0.), + 'relative_position_bias_table': dict(decay_mult=0.), + 'norm': dict(decay_mult=0.) + })) # learning policy param_scheduler = [ diff --git a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_swin-l-p4-w7_8xb32-210e_coco-384x288.py b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_swin-l-p4-w7_8xb32-210e_coco-384x288.py index d6a9ee5f97..8d09cb1d24 100644 --- a/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_swin-l-p4-w7_8xb32-210e_coco-384x288.py +++ b/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_swin-l-p4-w7_8xb32-210e_coco-384x288.py @@ -10,12 +10,13 @@ lr=5e-4, betas=(0.9, 0.999), weight_decay=0.01, - paramwise_cfg=dict( - custom_keys={ - 'absolute_pos_embed': dict(decay_mult=0.), - 'relative_position_bias_table': dict(decay_mult=0.), - 'norm': dict(decay_mult=0.) - }))) + ), + paramwise_cfg=dict( + custom_keys={ + 'absolute_pos_embed': dict(decay_mult=0.), + 'relative_position_bias_table': dict(decay_mult=0.), + 'norm': dict(decay_mult=0.) + })) # learning policy param_scheduler = [