open-mmlab / mmsegmentation

OpenMMLab Semantic Segmentation Toolbox and Benchmark.
https://mmsegmentation.readthedocs.io/en/main/
Apache License 2.0
8.25k stars 2.61k forks source link

TypeError: forward() got multiple values for argument 'img_metas' #2109

Open Jing-W98 opened 2 years ago

Jing-W98 commented 2 years ago

I try pytorch2onnx.

It reports the following error: Traceback (most recent call last): File "tools/pytorch2onnx.py", line 393, in dynamic_export=args.dynamic_export) File "tools/pytorch2onnx.py", line 204, in pytorch2onnx dynamic_axes=dynamic_axes) File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/onnx/init.py", line 365, in export export_modules_as_functions, File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 178, in export export_modules_as_functions=export_modules_as_functions, File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 1084, in _export dynamic_axes=dynamic_axes, File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 727, in _model_to_graph graph, params, torch_out, module = _create_jit_graph(model, args) File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 602, in _create_jit_graph graph, torch_out = _trace_and_get_graph_from_model(model, args) File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 518, in _trace_and_get_graph_from_model model, args, strict=False, _force_outplace=False, _return_inputs_states=True File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/jit/_trace.py", line 1175, in _get_trace_graph outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, kwargs) File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, kwargs) File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/jit/_trace.py", line 132, in forward self._force_outplace, File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/jit/_trace.py", line 118, in wrapper outs.append(self.inner(trace_inputs)) File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, kwargs) File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1118, in _slow_forward result = self.forward(*input, kwargs) File "/home/research/wangjing/anaconda3/envs/openmmlab/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 116, in new_func return old_func(*args, **kwargs) TypeError: forward() got multiple values for argument 'img_metas'

How can I solve it? Thank you !

MengzhangLI commented 2 years ago

Seems like it is caused by mmcv version conflict.

https://github.com/open-mmlab/mmsegmentation/issues/1962

Jing-W98 commented 2 years ago

It conflicts with pytorch1.12?

Kerwin0621 commented 1 year ago

I have the same issue, did you solve it?