ScaledYOLOv4
ScaledYOLOv4 copied to clipboard
Tiny version has wrong shape inference
I have successfully converted yolo tiny to ONNX. Using the .cfg file https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-tiny/cfg/yolov4-tiny.cfg and the export.py code here https://github.com/linghu8812/tensorrt_inference/blob/master/Yolov4/export_onnx.py. The problem comes when I try to test the model using this code
`def onnx_test(onnx_model):
mod_name = weights_file.replace('.weights', '.onnx') # filename
img_rand = torch.randn((1,3,416,416))
ort_session = onnxruntime.InferenceSession(mod_name)
def to_numpy(tensor):
return tensor.detach().numpy()
# compute ONNX Runtime output prediction
ort_inputs_rand = {ort_session.get_inputs()[0].name: to_numpy(img_rand)}
ort_outs_rand = ort_session.run(None, ort_inputs_rand)
hfile = weights_file.replace('.weights', '.h5') # filename
hf = h5py.File(hfile, 'w')
hf.create_dataset('input_rand', data=to_numpy(img_rand))
hf.create_dataset('output_rand', data=ort_outs_rand)
hf.close()`
It gives the following:
Traceback (most recent call last): File "models/export_cfg.py", line 1109, in <module> main(cfg_file=args.cfg_file, weights_file=args.weights_file, output_file=args.output_file, strides=args.strides, File "models/export_cfg.py", line 1099, in main onnx_test(onnx_model) File "models/export_cfg.py", line 1084, in onnx_test ort_outs_rand = ort_session.run(None, ort_inputs_rand) File "C:\Users\siria\.conda\envs\scaledyolov4\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 192, in run return self._sess.run(output_names, input_feed, run_options) onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node. Name:'' Status Message: D:\a\_work\1\s\onnxruntime\core\providers\cpu\tensor\reshape_helper.h:42 onnxruntime::ReshapeHelper::ReshapeHelper gsl::narrow_cast<int64_t>(input_shape.Size()) == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{1,255,13,13}, requested shape:{1,3,85,52,52}
I tried the same procedure with yolo csp with no problems. Any idea? Thanks in advance.
Hi. I'm facing the same issue.
Did you find any solution? @siriasadeddin