mikel-brostrom / boxmot

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

`KalmanBoxTracker.observations` grows infinitely, causing out of memory #1542

Closed didrikmunther closed 3 months ago

didrikmunther commented 4 months ago

Search before asking

Yolo Tracking Component

Tracking

Bug

Problem

Here, we see self.observations = dict().

For every loop an object stays in the picture, we are adding a new element to this dict

The memory will eventually run out.

Suggested improvement:

We are already storing previous observations in a dequeue. I suggest using this dequeue instead of the observations dict here, here, and here.

We need to ensure max_obs > delta_t for this to work.

Environment

Boxmot commit b54b584

2024-07-26 16:42:31.711 | INFO     | boxmot.utils.torch_utils:select_device:52 - Yolo Tracking v10.0.75 πŸš€ Python-3.10.12 torch-2.2.2CPU
2024-07-26 16:42:31.775 | INFO     | boxmot.appearance.backends.openvino_backend:load_model:18 - Loading osnet_x0_25_msmt17_openvino_model for OpenVINO inference...

Minimal Reproducible Example

from pathlib import Path
from boxmot import DeepOCSORT
import numpy as np

tracker = DeepOCSORT(
    model_weights=Path("models/mobilenetv2_x1_4_msmt17.pt"),
    device="mps",
    fp16=False
)

# Create white image with black square in the middle
image = np.ones((100, 100, 3), dtype=np.uint8) * 255
image[25:75, 25:75] = 0

while True:
    dets = np.array([[25, 25, 75, 75, 1.0, 0.0]], dtype=np.float32)
    tracker.update(dets, image)

    observations = tracker.active_tracks[0].observations

    # Size of observations dict grows infinitely
    print(len(observations))
github-actions[bot] commented 3 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!

github-actions[bot] commented 3 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!