????????在使用mmseg的模型进行推理导出为torchscript时出错:
KeyError: "class `EncoderDecoder` in mmseg/models/segmentors/encoder_decoder.py: 'SegDataPreProcessor is not in the model registry. Please check whether the value of `SegDataPreProcessor` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'"
????????出错原因是模块没在注册信息中找到,需要添加mmseg注册模块代码。
from mmseg.utils import register_all_modules
register_all_modules()
? ? ? ? 具体参考:
Here is the answer :?#9719 (comment)
The whole thing can be fixed by adding this to you inference script :from mmdet.utils import register_all_modules
register_all_modules()
I explain some of what I understood in the issue above, it's a problem of modules not being registered in mmengine MODELS registry (because they are in the mmdet MODELS registry) but the data preprocessors are initialized in mmengine scope so they are not found. I think this is an actual issue that could be fixed by using mmengine registry methods to search in the children of the MODELS registry in mmengine which contains the mmdet MODELS registry.