【mmseg】‘SegDataPreProcessor is not in the model registry问题解决

发布时间:2024年01月12日

问题描述:

????????在使用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.

文章来源:https://blog.csdn.net/dou3516/article/details/135554019
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。