mikel-brostrom / boxmot

BoxMOT: pluggable SOTA tracking modules for segmentation, object detection and pose estimation models
GNU Affero General Public License v3.0
6.65k stars 1.7k forks source link

OCSort non-default max_age error #1414

Closed MABatin closed 4 months ago

MABatin commented 5 months ago

Search before asking

Yolo Tracking Component

Tracking

Bug

When increasing the value of max_age parameter of OCSort class, I get the following error:

Traceback (most recent call last):
  File "/home/ml-machine/batin/easy-security_onprem/unused/tracker-tests/ocsort.py", line 66, in <module>
    main(parse_args())
  File "/home/ml-machine/batin/easy-security_onprem/unused/tracker-tests/ocsort.py", line 52, in main
    tracks = tracker.update(dets, im) # --> M X (x, y, x, y, id, conf, cls, ind)
  File "/home/ml-machine/miniconda3/envs/ublenv/lib/python3.10/site-packages/boxmot/utils/__init__.py", line 79, in wrapper
    tracks = self.update(instance, dets, im)
  File "/home/ml-machine/miniconda3/envs/ublenv/lib/python3.10/site-packages/boxmot/trackers/ocsort/ocsort.py", line 292, in update
    self.active_tracks[m[1]].update(dets[m[0], :5], dets[m[0], 5], dets[m[0], 6])
  File "/home/ml-machine/miniconda3/envs/ublenv/lib/python3.10/site-packages/boxmot/trackers/ocsort/ocsort.py", line 167, in update
    self.kf.update(convert_bbox_to_z(bbox))
  File "/home/ml-machine/miniconda3/envs/ublenv/lib/python3.10/site-packages/boxmot/motion/kalman_filters/ocsort_kf.py", line 485, in update
    self.unfreeze()
  File "/home/ml-machine/miniconda3/envs/ublenv/lib/python3.10/site-packages/boxmot/motion/kalman_filters/ocsort_kf.py", line 399, in unfreeze
    index1 = indices[-2]
IndexError: index -2 is out of bounds for axis 0 with size 1

Environment

Boxmot - 10.0.65 Python - 3.10.13 torch 2.1.2+cu118 CUDA:0 (RTX 3090 24GB)

Minimal Reproducible Example

    detector = YOLO(
        model="path/to/yolov8m.pt"
    ).to(device)
    tracker = OCSORT(
        max_age=60
    )
    kwargs = {'classes': 0}
    results = detector(input_filename, stream=True, **kwargs)

    for r in results:
        try:
            im = deepcopy(r.orig_img)
            annotator = Annotator(im)
            dets = r.boxes.data.cpu().numpy()
            tracks = tracker.update(dets, im) # --> M X (x, y, x, y, id, conf, cls, ind)
            for track in tracks:
                ...
mikel-brostrom commented 5 months ago

So it works with 30?

J4BEZ commented 5 months ago

I got same error while using HybridSORT.

in my case, it works very well with 30 and 40. but if I increase max_age to 120, I got the same error occured😥

mikel-brostrom commented 5 months ago

I see. The max deque length for observation history is 50 so it makes sense that it works with 30 and 40, but not over 50

MABatin commented 5 months ago

I see. The max deque length for observation history is 50 so it makes sense that it works with 30 and 40, but not over 50

Are you planning on making the max deque length dynamic as the max_age or could there be any downside to it?

github-actions[bot] commented 5 months ago

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

mikel-brostrom commented 5 months ago

I see. The max deque length for observation history is 50 so it makes sense that it works with 30 and 40, but not over 50

Are you planning on making the max deque length dynamic as the max_age or could there be any downside to it?

Yup, I have it in my backlog 😄

github-actions[bot] commented 4 months ago

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!