Closed wiekern closed 2 years ago
If I set ONNX_EXPORT=True
, then start training, the same runtime error of invalid output sizes occurs
RuntimeError: input and output sizes should be greater than 0, but got input (H: 10, W: 10) output (H: 0, W: 0)
configuring ONNX_EXPORT=False
in models/models.py, the conversion is successful by running https://github.com/NNDam/yolor/blob/main/convert_to_onnx.py in which you need to specify your custom arguments of weights, cfg, output, max_size. The environment is from the docker image nvcr.io/nvidia/pytorch:21.03-py3
.
python convert_to_onnx.py
I get an error when I attempt to convert torch model as onnx format, The main error message shows below
This error comes from the upsample operator in pytorch.
I notice the falg
ONNX_EXPORT
in models/models.py, but I have no clue how to use it properly. In my case, this flag is False by default before training, and then I have a trained model of YOLOR_P6 with single class instead of 85 coco classes, now I need to export onnx, so set this flag to True and specify the weights file of the trained model, starting converting and this error appears. If you look into the source code, the 0 output size generated by the upsample factor namely variableg
which is 0 since yolo_index always -1. I tried to print mdef['stride'] out, getting 2, then hardcodeg = 2
avoiding the caseg=0
, however another error appears (sizes mismatch due to wrong output size, my image input size is 640x640).This tells me that I configure the output size incorrectly, so could anyone help me to solve it? It is very helpful if the tutorial steps are listed, many thanks!
convert script I applied is https://github.com/NNDam/yolor/blob/main/convert_to_onnx.py Related defect of upsample/interpolate in pytorch I found a fix request at https://github.com/pytorch/pytorch/pull/18875