open-mmlab / mmocr

OpenMMLab Text Detection, Recognition and Understanding Toolbox
https://mmocr.readthedocs.io/en/dev-1.x/
Apache License 2.0
4.28k stars 743 forks source link

加载部分预训练模型 #687

Closed GaoXinJian-USTC closed 2 years ago

GaoXinJian-USTC commented 2 years ago

请问如果我想加载某个网络的某个部分的预训练模型,该如何操作呢?我注意到ABINet里加载language model 是通过在配置文件里配置 load_from = "xxx.pth"进行的,mmocr会自动把加载的模型对应的相应的部分吗?如果我想同时加载一个网络多个部分的预训练模型该如何操作呢?

cuhk-hbsun commented 2 years ago

load_from = "xxx.pth"进行的,mmocr会自动把加载的模型对应的相应的部分吗?

Yes, just add load_from = xxx.pth in config file to load the pretrained model. Any weight in the pretrained model with same name and shape of your model will be applied to your model.

cuhk-hbsun commented 2 years ago

如果我想同时加载一个网络多个部分的预训练模型该如何操作呢?

Currently, it doesn't support loading multiple pretrained checkpoints at the same time. You can merge these pretrained checkpoints to one dictionary and then use load_from.