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

Error with YOLOv10 video inference #134

Open
tuannhtn opened this issue Jul 3, 2024 · 1 comment
Open

Error with YOLOv10 video inference #134

tuannhtn opened this issue Jul 3, 2024 · 1 comment

Comments

@tuannhtn
Copy link

tuannhtn commented Jul 3, 2024

I could run your code with TensorRT 10 on images, but when running on video file I got this error:
Traceback (most recent call last):
File "D:\study\yolov10\TensorRT-For-YOLO-Series-cuda-python\trt.py", line 35, in
pred.detect_video(video, conf=0.1, end2end=args.end2end) # set 0 use a webcam
File "D:\study\yolov10\TensorRT-For-YOLO-Series-cuda-python\utils\utils.py", line 118, in detect_video
dets = np.concatenate([np.array(final_boxes)[:int(num[0])], np.array(final_scores)[:int(num[0])], np.array(final_cls_inds)[:int(num[0])]], axis=-1)
File "<array_function internals>", line 200, in concatenate
ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 300 and the array at index 1 has size 1
Could anyone encountered this error and knew how to fix it? Thank you.

@Arshia-HZ
Copy link

I had the same problem with the detect_video function for YOLOv8! I tried this code for end2end section and problem resolved:

if end2end:
    num, final_boxes, final_scores, final_cls_inds = data

    final_boxes = np.reshape(final_boxes/ratio, (-1, 4))
    # Check if final_scores and final_cls_inds are empty
    if final_scores.size == 0 or final_cls_inds.size == 0:
        print("No detections found or output arrays are empty.")
        dets = final_boxes  # or set to an empty list/array if preferred
    else:
        # Ensure final_scores and final_cls_inds have shape (num_detections, 1)
        final_scores = np.array(final_scores).reshape(-1, 1)  # Shape: (num_detections, 1)
        final_cls_inds = np.array(final_cls_inds).reshape(-1, 1)  # Shape: (num_detections, 1)

        # Ensure that the number of detections is consistent
        if len(final_boxes) != len(final_scores) or len(final_boxes) != len(final_cls_inds):
            print("Mismatch in detection counts!")
            dets = final_boxes  # or set to an empty list/array if preferred
        else:
            # Concatenate final_boxes, final_scores, and final_cls_inds along the last axis
            dets = np.concatenate([final_boxes, final_scores, final_cls_inds], axis=-1)  

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