mmsegmentation icon indicating copy to clipboard operation
mmsegmentation copied to clipboard

模型导出错误:'EncoderDecoder' object has no attribute 'forward_dummy'

Open shuaizzZ opened this issue 1 year ago • 9 comments

1、先是报如下错误: Traceback (most recent call last): File "/mnt/bn/shuaizzz/codes/mmsegmentation/tools/deployment/pytorch2torchscript_defect.py", line 201, in segmentor = build_segmentor( File "/mnt/bn/shuaizzz/codes/mmsegmentation/mmseg/models/builder.py", line 49, in build_segmentor assert cfg.get('test_cfg') is None or test_cfg is None,
AssertionError: test_cfg specified in both outer field and model field

我通过修改pytorch2torchscript.py文件的segmentor定义为test_cfg=None解决了这个报错。

2、然后又报错: KeyError: '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'

我通过修改pytorch2torchscript.py文件,添加如下两行,解决了上述报错: from mmseg.utils import register_all_modules register_all_modules()

3、随后又报错: Traceback (most recent call last): File "/mnt/bn/shuaizzz/codes/mmsegmentation/tools/deployment/pytorch2torchscript_defect.py", line 213, in pytorch2libtorch( File "/mnt/bn/shuaizzz/codes/mmsegmentation/tools/deployment/pytorch2torchscript_defect.py", line 125, in pytorch2libtorch model.forward = model.forward_dummy File "/root/miniconda3/envs/mmseg/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1207, in getattr raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'EncoderDecoder' object has no attribute 'forward_dummy'

请问该如何解决?

shuaizzZ avatar Apr 16 '23 08:04 shuaizzZ