open-mmlab/mmaction2

Error in converting SlowFast model to onnx using tools/pytorch2onnx.py

Open

#756 opened on Mar 25, 2021

View on GitHub
 (18 comments) (0 reactions) (0 assignees)Python (3,648 stars) (1,137 forks)batch import
help wantedonnx

Description

Getting error like below while executing the conversion script: python3 tools/pytorch2onnx.py /home/dev3/Documents/new_mmaction/mmaction2/work_dirs/ava/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb_new-data_e20-2class/custom_slowfast.py /home/dev3/Documents/new_mmaction/mmaction2/work_dirs/ava/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb_new-data_e20-2class/best_mAP@0.5IOU_epoch_1.pth --is-localizer /home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/functional.py:3103: UserWarning: The default behavior for interpolate/upsample with float scale_factor changed in 1.6.0 to align with other frameworks/libraries, and now uses scale_factor directly, instead of relying on the computed output size. If you wish to restore the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details. warnings.warn("The default behavior for interpolate/upsample with float scale_factor changed " /home/dev3/mmdetection/mmdet/core/bbox/transforms.py:70: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! if bboxes.size(0) > 0: Traceback (most recent call last): File "tools/pytorch2onnx.py", line 163, in verify=args.verify) File "tools/pytorch2onnx.py", line 74, in pytorch2onnx opset_version=opset_version) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/onnx/init.py", line 230, in export custom_opsets, enable_onnx_checker, use_external_data_format) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 91, in export use_external_data_format=use_external_data_format) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 639, in _export dynamic_axes=dynamic_axes) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 411, in _model_to_graph use_new_jit_passes) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 379, in _create_jit_graph graph, torch_out = _trace_and_get_graph_from_model(model, args) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/onnx/utils.py", line 342, in _trace_and_get_graph_from_model torch.jit._get_trace_graph(model, args, strict=False, _force_outplace=False, _return_inputs_states=True) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/jit/_trace.py", line 1148, in _get_trace_graph outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/jit/_trace.py", line 130, in forward self._force_outplace, File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/jit/_trace.py", line 116, in wrapper outs.append(self.inner(*trace_inputs)) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 725, in _call_impl result = self._slow_forward(*input, **kwargs) File "/home/dev3/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 709, in _slow_forward result = self.forward(*input, **kwargs) File "/home/dev3/mmdetection/mmdet/models/detectors/two_stage.py", line 101, in forward_dummy roi_outs = self.roi_head.forward_dummy(x, proposals) File "/home/dev3/mmdetection/mmdet/models/roi_heads/standard_roi_head.py", line 60, in forward_dummy bbox_results = self._bbox_forward(x, rois) TypeError: _bbox_forward() missing 1 required positional argument: 'img_metas'

Contributor guide