From 692d732994660ceba82c75034c802eb1138239cf Mon Sep 17 00:00:00 2001 From: Wenyu Date: Wed, 22 Dec 2021 11:59:32 +0800 Subject: [PATCH] swin shift window (#4954) --- ppdet/modeling/backbones/swin_transformer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ppdet/modeling/backbones/swin_transformer.py b/ppdet/modeling/backbones/swin_transformer.py index 027e4f67a..8509b5164 100644 --- a/ppdet/modeling/backbones/swin_transformer.py +++ b/ppdet/modeling/backbones/swin_transformer.py @@ -493,8 +493,13 @@ class BasicLayer(nn.Layer): cnt = 0 for h in h_slices: for w in w_slices: - img_mask[:, h, w, :] = cnt + try: + img_mask[:, h, w, :] = cnt + except: + pass + cnt += 1 + mask_windows = window_partition( img_mask, self.window_size) # nW, window_size, window_size, 1 mask_windows = mask_windows.reshape( -- GitLab