ibaiGorordo / ONNX-YOLOv8-Object-Detection

Python scripts performing object detection using the YOLOv8 model in ONNX.
MIT License
369 stars 93 forks source link

image_object_detection.py run error #16

Open osenberg-x opened 1 year ago

osenberg-x commented 1 year ago

└─[$]> python3 image_object_detection.py Traceback (most recent call last): File "/home/x/ws/ml/ONNX-YOLOv8-Object-Detection/image_object_detection.py", line 16, in boxes, scores, class_ids = yolov8_detector(img) File "/home/x/ws/ml/ONNX-YOLOv8-Object-Detection/yolov8/YOLOv8.py", line 19, in call return self.detect_objects(image) File "/home/x/ws/ml/ONNX-YOLOv8-Object-Detection/yolov8/YOLOv8.py", line 31, in detect_objects input_tensor = self.prepare_input(image) File "/home/x/ws/ml/ONNX-YOLOv8-Object-Detection/yolov8/YOLOv8.py", line 46, in prepare_input input_img = cv2.resize(input_img, (self.input_width, self.input_height)) cv2.error: OpenCV(4.8.0) :-1: error: (-5:Bad argument) in function 'resize'

Overload resolution failed:

  • Can't parse 'dsize'. Sequence item with index 0 has a wrong type
  • Can't parse 'dsize'. Sequence item with index 0 has a wrong type
ibaiGorordo commented 1 year ago

What is the input size of your model? Are you using an ONNX model with dynamic input size? (That probably won't work)

zoldaten commented 5 months ago

@ibaiGorordo u have names missmatch and wrong resize function in YOLOv8.py: input_img = cv2.resize(input_img, (int(self.img_width), int(self.img_height)),interpolation=cv2.INTER_AREA)

but even with fix it doesnt work:

File "/home/pi/.local/lib/python3.9/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 200, in run
    return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running Concat node. Name:'/model.11/Concat' Status Message: concat.cc:159 PrepareForCompute Non concat axis dimensions must match: Axis 2 has mismatched dimensions of 45 and 46