TSD
TSD copied to clipboard
TypeError "forward() missing 2 required positional arguments: 'feats' and 'rois'" in pytorch2onnx
When I try to convert pytorch model to onnx by running tools/pytorch2onnx.py, I encountered this error.
Script
python tools/pytorch2onnx.py configs/OpenImages_configs/r50-FPN-1x_classsampling_TSD/r50-FPN-1x_classsampling_TSD.py checkpoints/r50-FPN-1x_classsampling_TSD.pth --out r50-FPN-1x_classsampling_TSD.onnx
Environment
sys.platform: linux Python: 3.7.5 (default, Oct 25 2019, 15:51:11) [GCC 7.3.0] CUDA available: True CUDA_HOME: /usr/local/cuda-10.1 NVCC: Cuda compilation tools, release 10.1, V10.1.105 GPU 0: GeForce RTX 2080 Ti GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609 PyTorch: 1.2.0 PyTorch compiling details: PyTorch built with:
- GCC 7.3
- Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v0.18.1
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- NNPACK is enabled
- CUDA Runtime 10.0
- NVCC architecture flags: -gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_50,code=compute_50
- CuDNN 7.6.2
- Magma 2.5.1
- Build settings: BLAS=MKL, BUILD_NAMEDTENSOR=OFF, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DUSE_FBGEMM -DUSE_QNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Wno-stringop-overflow, DISABLE_NUMA=1, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=True, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON,
TorchVision: 0.4.0 OpenCV: 4.1.1 MMCV: 0.4.3 MMDetection: 1.1.0+fb1fdd7 MMDetection Compiler: GCC 5.4 MMDetection CUDA Compiler: 10.1
Error traceback
/content/anaconda3/envs/face/lib/python3.7/site-packages/mmdet-1.1.0+fb1fdd7-py3.7-linux-x86_64.egg/mmdet/core/bbox/transforms.py:163: 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:
/content/anaconda3/envs/face/lib/python3.7/site-packages/mmdet-1.1.0+fb1fdd7-py3.7-linux-x86_64.egg/mmdet/models/roi_extractors/single_level.py:99: 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 inds.any():
/content/anaconda3/envs/face/lib/python3.7/site-packages/mmdet-1.1.0+fb1fdd7-py3.7-linux-x86_64.egg/mmdet/ops/roi_align/roi_align.py:149: 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!
assert rois.dim() == 2 and rois.size(1) == 5
Traceback (most recent call last):
File "tools/pytorch2onnx.py", line 127, in <module>
main()
File "tools/pytorch2onnx.py", line 119, in main
onnx_model = export_onnx_model(model, (input_data,), args.passes)
File "tools/pytorch2onnx.py", line 44, in export_onnx_model
operator_export_type=OperatorExportTypes.ONNX_ATEN_FALLBACK,
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/onnx/__init__.py", line 132, in export
strip_doc_string, dynamic_axes)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/onnx/utils.py", line 64, in export
example_outputs=example_outputs, strip_doc_string=strip_doc_string, dynamic_axes=dynamic_axes)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/onnx/utils.py", line 329, in _export
_retain_param_name, do_constant_folding)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/onnx/utils.py", line 213, in _model_to_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/onnx/utils.py", line 171, in _trace_and_get_graph_from_model
trace, torch_out = torch.jit.get_trace_graph(model, args, _force_outplace=True)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/jit/__init__.py", line 256, in get_trace_graph
return LegacyTracedModule(f, _force_outplace, return_inputs)(*args, **kwargs)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in __call__
result = self.forward(*input, **kwargs)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/jit/__init__.py", line 323, in forward
out = self.inner(*trace_inputs)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/nn/modules/module.py", line 545, in __call__
result = self._slow_forward(*input, **kwargs)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/nn/modules/module.py", line 531, in _slow_forward
result = self.forward(*input, **kwargs)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/mmdet-1.1.0+fb1fdd7-py3.7-linux-x86_64.egg/mmdet/models/detectors/two_stage.py", line 128, in forward_dummy
cls_score, bbox_pred = self.bbox_head(bbox_feats)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/nn/modules/module.py", line 545, in __call__
result = self._slow_forward(*input, **kwargs)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/torch/nn/modules/module.py", line 531, in _slow_forward
result = self.forward(*input, **kwargs)
File "/content/anaconda3/envs/face/lib/python3.7/site-packages/mmdet-1.1.0+fb1fdd7-py3.7-linux-x86_64.egg/mmdet/core/fp16/decorators.py", line 130, in new_func
return old_func(*args, **kwargs)
TypeError: forward() missing 2 required positional arguments: 'feats' and 'rois'
Thanks a lot!
请问解决了吗