Open utterances-bot opened 2 hours ago
Hi @cj-mills!
I get the following error when I run the code under Detect, Track and Annotate Objects in Video Frames in the final part of the guide where we loop through the video to detect and annotate.
{ "name": "IndexError", "message": "too many indices for array: array is 1-dimensional, but 2 were indexed", "stack": "--------------------------------------------------------------------------- IndexError Traceback (most recent call last) Cell In[35], line 44 39 # Update tracker with detections 40 tracks = tracker.update( 41 output_results=np.concatenate([tlbr_boxes, probs_list[:, np.newaxis]], axis=1), 42 img_info=rgb_img.size, 43 img_size=rgb_img.size) ---> 44 track_ids = match_detections_with_tracks(tlbr_boxes=tlbr_boxes, track_ids=track_ids, tracks=tracks) 46 # End performance counter 47 end_time = time.perf_counter()
File ~/anaconda3/envs/torch-yolox/lib/python3.9/site-packages/cjm_byte_track/matching.py:120, in match_detections_with_tracks(tlbr_boxes, track_ids, tracks) 118 # Calculate IOU 119 tracks_boxes = np.array([track.tlbr for track in tracks]) --> 120 iou = box_iou_batch(tracks_boxes, tlbr_boxes) 122 # Get indices with maximum IOU values 123 track2detection = np.argmax(iou, axis=1)
File ~/anaconda3/envs/torch-yolox/lib/python3.9/site-packages/cjm_byte_track/matching.py:21, in box_iou_batch(boxes_true, boxes_detection) 17 \"\"\" 18 Compute the Intersection over Union (IoU) between two sets of bounding boxes. 19 \"\"\" 20 # Compute areas of the true boxes and detected boxes ---> 21 area_true = (boxes_true[:, 2] - boxes_true[:, 0]) (boxes_true[:, 3] - boxes_true[:, 1]) 22 area_detection = (boxes_detection[:, 2] - boxes_detection[:, 0]) (boxes_detection[:, 3] - boxes_detection[:, 1]) 24 # Find the top left and bottom right coordinates for the intersections
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed" }
Real-Time Object Tracking with YOLOX and ByteTrack – Christian Mills
Learn how to track objects across video frames with YOLOX and ByteTrack.
https://christianjmills.com/posts/pytorch-train-object-detector-yolox-tutorial/byte-track/