deep_sort
deep_sort copied to clipboard
self.samples KeyError
Hello, I am using YOLOv7 and DeepSORT for vehicle detection and tracking. In the image, the YOLO model successfully detected five cars, and now the tracker is updating and it throws this error:
Exception has occurred: KeyError
1
File "/home/spotparking/SpotBackend/deep_sort/nn_matching.py", line 177, in distance
cost_matrix[i, :] = self._metric(self.samples[target], features)
File "/home/spotparking/SpotBackend/deep_sort/tracker.py", line 98, in gated_metric
cost_matrix = self.metric.distance(features, targets)
File "/home/spotparking/SpotBackend/deep_sort/linear_assignment.py", line 55, in min_cost_matching
cost_matrix = distance_metric(
File "/home/spotparking/SpotBackend/deep_sort/linear_assignment.py", line 137, in matching_cascade
min_cost_matching(
File "/home/spotparking/SpotBackend/deep_sort/tracker.py", line 113, in _match
linear_assignment.matching_cascade(
File "/home/spotparking/SpotBackend/deep_sort/tracker.py", line 69, in update
self._match(detections)
File "/home/spotparking/SpotBackend/scripts/run_doterra_small_lot.py", line 153, in <module>
tracker.update(detections)
KeyError: 1
where this is the current state of the variables:
features.shape
(5, 128)
self.samples
{}
targets
array([1, 2, 3, 4, 5])
at this point the tracker.predict() tracker.update() functions have been called twice, and these cars are stationary.
Any help as to how to fix this problem would be much appreciated!