open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.31k stars 9.42k forks source link

请问我该如何使用mmdetection加载自己的预训练权重 #11097

Open woshinangua opened 11 months ago

woshinangua commented 11 months ago

我首先修改了init_cfg中的内容init_cfg=dict(type='Pretrained', checkpoint='/root/mmdetection/checkpoints/my_pretrained.pth')),后来又修改load_from参数加载指定目录下的权重,都显示 2023/10/27 06:43:57 - mmengine - WARNING - The model and loaded state dict do not match exactly, unexpected key in source state_dict....,

missing keys in source state_dict......,

Name of parameter - Initialization information

backbone.conv1.weight - torch.Size([64, 3, 7, 7]): The value is the same before and after calling init_weights of RetinaNet

backbone.bn1.weight - torch.Size([64]): The value is the same before and after calling init_weights of RetinaNet

backbone.bn1.bias - torch.Size([64]): The value is the same before and after calling init_weights of RetinaNet

backbone.layer1.0.conv1.weight - torch.Size([64, 64, 1, 1]): The value is the same before and after calling init_weights of RetinaNet

hhaAndroid commented 11 months ago

这种写法是正确的。提示的话要根据你的场景来判断是否合理,不是说有警告就说明是错的