Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Invalid output layout or shape with converted ONNX model when running validate_yolo.py #246

Open
Kylemaycry opened this issue Nov 27, 2023 · 2 comments

Comments

@Kylemaycry
Copy link

Kylemaycry commented Nov 27, 2023

I am converting a .weight model, first to .h5 and then to .pb. Both are successful and can be verified by the validate_yolo.py
(In addition, can this repo convert .h5 to a TF savedmodel? )
The conversion to .onnx is also successful, but model cannot be verified with validate_yolo.py. The error message is as following:
Thanks in advance!!

The device support i8sdot:0, support fp16:0, support i8mm: 0
2023-11-27 21:24:16.453009: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2023-11-27 21:24:16.453046: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2023-11-27 21:24:19.901064: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/lib/python3.8/dist-packages/cv2/../../lib64:
2023-11-27 21:24:19.901113: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
2023-11-27 21:24:19.901152: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (art-ipc427d): /proc/driver/nvidia/version does not exist
(416, 416)
2023-11-27 21:24:20.029914655 [W:onnxruntime:Default, upsamplebase.h:101 UpsampleBase] tf_half_pixel_for_nn is deprecated since opset 13, yet this opset 13 model uses the deprecated attribute
NCHW input layout
Traceback (most recent call last):
File "./tools/evaluation/validate_yolo.py", line 520, in
main()
File "./tools/evaluation/validate_yolo.py", line 511, in main
validate_yolo_model_onnx(model, image_file, anchors, class_names, args.elim_grid_sense, args.v5_decode, args.loop_count, args.output_path)
File "./tools/evaluation/validate_yolo.py", line 335, in validate_yolo_model_onnx
raise ValueError('invalid output layout or shape')
ValueError: invalid output layout or shape

The output of print(output_tensors[0],output_tensors[1]):
NodeArg(name='conv2d_9', type='tensor(float)', shape=['unk__308', 30, 0, 0]) NodeArg(name='conv2d_12', type='tensor(float)', shape=['unk__311', 30, 0, 0])

@david8862
Copy link
Owner

@Kylemaycry how did you convert to the .onnx model?

@Kylemaycry
Copy link
Author

@Kylemaycry how did you convert to the .onnx model?
Hi @david8862, I used the following commands, found them here:https://github.com/david8862/keras-YOLOv3-model-set#onnx-model-convert
Thanks the help!

export TF_KERAS=1
python3 tools/model_converter/keras_to_onnx.py
--keras_model_file=${MODEL_FOLDER}/yolov3-tiny.h5
--output_file=${MODEL_FOLDER}/yolo-v3-tiny.onnx
--op_set=15 --inputs_as_nchw

python3 tools/model_converter/onnx_edit.py
--input_model=${MODEL_FOLDER}/yolo-v3-tiny.onnx
--output_model=${MODEL_FOLDER}/yolo-v3-tiny-nchw.onnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants