aim-uofa / AdelaiDet

AdelaiDet is an open source toolbox for multiple instance-level detection and recognition tasks.
https://git.io/AdelaiDet
Other
3.38k stars 650 forks source link

How to conver condinst toonnx version? #424

Open LIYHUI opened 3 years ago

LIYHUI commented 3 years ago

I use the script as follows to convert pth to onnx.

python onnx/export_model_to_onnx.py \
    --config-file configs/CondInst/MS_R_50_BiFPN_3x_sem.yaml\
    --output output/CondInst_MS_R_50_BiFPN_3x_sem.onnx
    --opts MODEL.WEIGHTS CondInst_MS_R_50_BiFPN_3x_sem.pth

but there is an error for it:

`/home/lyh/Instance/AdelaiDet/onnx/export_onnx_v2.py:164: 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 int(factor) == factor /home/lyh/Instance/AdelaiDet/onnx/export_onnx_v2.py:166: 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 factor == 1: Traceback (most recent call last): File "/home/lyh/Instance/AdelaiDet/onnx/export_onnx_v2.py", line 300, in main() File "/home/lyh/Instance/AdelaiDet/onnx/export_onnx_v2.py", line 293, in main opset_version=11, File "/opt/conda/lib/python3.7/site-packages/torch/onnx/init.py", line 280, in export custom_opsets, enable_onnx_checker, use_external_data_format) File "/opt/conda/lib/python3.7/site-packages/torch/onnx/utils.py", line 94, in export use_external_data_format=use_external_data_format) File "/opt/conda/lib/python3.7/site-packages/torch/onnx/utils.py", line 695, in _export dynamic_axes=dynamic_axes) File "/opt/conda/lib/python3.7/site-packages/torch/onnx/utils.py", line 487, in _model_to_graph torch._C._jit_pass_onnx_assign_output_shape(graph, output_tensors, out_desc, _onnx_shape_inference) RuntimeError: ArrayRef: invalid index Index = 21; Length = 21

Process finished with exit code 1 `

sssimpleboy commented 1 year ago

hello, have you solved it ?