Skip to content

Commit 5fc7c5c

Browse files
authored
fix beit model converter (open-mmlab#1616)
* fix beit model converter * Update beit2mmseg.py I have modified the code according to your suggestion. Thanks.
1 parent 5ecf45d commit 5fc7c5c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/model_converters/beit2mmseg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ def convert_beit(ckpt):
1212
new_ckpt = OrderedDict()
1313

1414
for k, v in ckpt.items():
15-
if k.startswith('patch_embed'):
16-
new_key = k.replace('patch_embed.proj', 'patch_embed.projection')
17-
new_ckpt[new_key] = v
1815
if k.startswith('blocks'):
1916
new_key = k.replace('blocks', 'layers')
2017
if 'norm' in new_key:
@@ -24,6 +21,9 @@ def convert_beit(ckpt):
2421
elif 'mlp.fc2' in new_key:
2522
new_key = new_key.replace('mlp.fc2', 'ffn.layers.1')
2623
new_ckpt[new_key] = v
24+
elif k.startswith('patch_embed'):
25+
new_key = k.replace('patch_embed.proj', 'patch_embed.projection')
26+
new_ckpt[new_key] = v
2727
else:
2828
new_key = k
2929
new_ckpt[new_key] = v

0 commit comments

Comments
 (0)