Facing error in trensor matching while using hailo libraries. in our custom code

we are trying to use the hailo libraries in our custom script file using pre-trained hef model but we are facing error in function reorganize_split_out_numpy and reorganize_split_output in file yolo.py ,the error indicates the dimension difference .
"device: [‘0000:3a:00.0’]
hef config: {‘yolox_s_leaky’: <hailo_platform.pyhailort._pyhailort.ConfigureParams object at 0x7f1838f42870>}
Network group: <hailo_platform.pyhailort.pyhailort.ConfiguredNetwork object at 0x7f1838491340>
network group params: <hailo_platform.pyhailort._pyhailort.ActivateNetworkGroupParams object at 0x7f1838fbbc30>
input vstream info: VStreamInfo(“yolox_s_leaky/input_layer1”)
output vstream info: VStreamInfo(“yolox_s_leaky/conv55”)
input vstream params: {‘yolox_s_leaky/input_layer1’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbbe70>}
input vstream params: {‘yolox_s_leaky/conv54’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbbbb0>, ‘yolox_s_leaky/conv55’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbb370>, ‘yolox_s_leaky/conv56’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbb0b0>, ‘yolox_s_leaky/conv68’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbb5f0>, ‘yolox_s_leaky/conv69’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbb6b0>, ‘yolox_s_leaky/conv70’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbffb0>, ‘yolox_s_leaky/conv81’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbfd30>, ‘yolox_s_leaky/conv82’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbf070>, ‘yolox_s_leaky/conv83’: <hailo_platform.pyhailort._pyhailort.VStreamParams object at 0x7f1838fbfc70>}

model data input shape info: (640, 640, 3)
reading :/home/hailo/Umraz/exp-1/data/detection12.mp4
frame number: 1
layer shapes :############ {(1, 20, 20, 80): ‘yolox_s_leaky/conv81’, (1, 40, 40, 4): ‘yolox_s_leaky/conv69’, (1, 80, 80, 4): ‘yolox_s_leaky/conv55’, (1, 20, 20, 4): ‘yolox_s_leaky/conv82’, (1, 40, 40, 1): ‘yolox_s_leaky/conv70’, (1, 40, 40, 80): ‘yolox_s_leaky/conv68’, (1, 80, 80, 80): ‘yolox_s_leaky/conv54’, (1, 80, 80, 1): ‘yolox_s_leaky/conv56’, (1, 20, 20, 1): ‘yolox_s_leaky/conv83’}
2024-06-19 16:43:26.211271: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-06-19 16:43:27.900746: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
anchors : {‘strides’: [32, 16, 8], ‘sizes’: [[1, 1], [1, 1], [1, 1]]}
post proc: <hailo_model_zoo.core.postprocessing.detection.yolo.YoloPostProc object at 0x7f18395eb5e0>
Transposed endnodes shapes:
Shape of endnode 0: (1, 4, 80, 80)
Shape of endnode 1: (1, 1, 80, 80)
Shape of endnode 2: (1, 80, 80, 80)
Shape of endnode 3: (1, 4, 40, 40)
Shape of endnode 4: (1, 1, 40, 40)
Shape of endnode 5: (1, 80, 40, 40)
Shape of endnode 6: (1, 4, 20, 20)
Shape of endnode 7: (1, 1, 20, 20)
Shape of endnode 8: (1, 80, 20, 20)
Traceback (most recent call last):
File “test.py”, line 234, in
hailo_preds = yolox_post_proc.yolo_postprocessing(endnodes_transposed)
File “/local/workspace/hailo_model_zoo/hailo_model_zoo/core/postprocessing/detection/yolo.py”, line 339, in yolo_postprocessing
endnodes = self.reorganize_split_output(endnodes)
File “/local/workspace/hailo_model_zoo/hailo_model_zoo/core/postprocessing/detection/yolo.py”, line 535, in reorganize_split_output
branch_endnodes = tf.numpy_function(self.reorganize_split_output_numpy,
File “/local/workspace/hailo_virtualenv/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py”, line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File “/local/workspace/hailo_model_zoo/hailo_model_zoo/core/postprocessing/detection/yolo.py”, line 577, in reorganize_split_output_numpy
partial_concat = np.concatenate([center_slice, scale_slice, obj_slice, prob_slice], axis=-1)
File “<array_function internals>”, line 180, in concatenate
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 4 and the array at index 2 has size 1".

please resolve it.

hey @prateek.s

can you please provide how do you run the script and what size of data you give it ?
it seems there is mismatch between the sizes needed and given.
if you want to see an example of yolox_s_leaky you can check out :

1 Like

thank you for sharing the repository with us , so while running the code for yolox_stream_inference.py we came accross an error :
“(hailo_virtualenv) hailo@auto:/local/workspace/Hailo-Application-Code-Examples/runtime/python/yolox_streaming_inference$ ./yolox_stream_inference.py
2024-06-20 15:41:04.960035: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-06-20 15:41:05.700099: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
File “./yolox_stream_inference.py”, line 87, in
hailo_preds = yolox_post_proc.yolo_postprocessing(endnodes)
File “/local/workspace/hailo_model_zoo/hailo_model_zoo/core/postprocessing/detection/yolo.py”, line 123, in yolo_postprocessing
detection_boxes, detection_scores = tf.numpy_function(self.yolo_postprocess_numpy,
File “/local/workspace/hailo_virtualenv/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py”, line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File “/local/workspace/hailo_model_zoo/hailo_model_zoo/core/postprocessing/detection/yolo.py”, line 188, in yolo_postprocess_numpy
pred = net_out.transpose((0, 3, 1, 2)) # now dims are: [N,C,H,W] as in Gluon.
ValueError: axes don’t match array”

note : we have create a fresh hailo_env so files are intact and we followed the same instructions to run provided in README.txt from the repository.

Also, our goal is to provide detection for a single class (person) and extract bounding box coordinates along with other features from preds.
please provide a solution for it considering on the above repository.

It is given in yolo.py code that (net_out is shape: [N, 19, 19, 255] or [N, 38, 38, 255] or [N, 76, 76, 255]) but we are getting net_out : (80, 80, 85) for the above case. I think problem lies here, can you please solve and explain this part in reference to above error.