sort
sort copied to clipboard
linear_assignment is deprecated
In line 147 of sort.py is a call to sklearn 'linear_assignment'
This throws this message DeprecationWarning: The linear_assignment function is deprecated in 0.21 and will be removed from 0.23. Use scipy.optimize.linear_sum_assignment instead.
i fixed it with the following code:
from scipy.optimize import linear_sum_assignment ... matched_indices = linear_sum_assignment(-iou_matrix) matched_indices = np.array(list(zip(*matched_indices)))
I try the method mentioned by @kbaxx, it works fine in most cases but fails when the matched_indices
is an empty list.
194 unmatched_trackers = []
195 for t, trk in enumerate(trackers):
--> 196 if t not in matched_indices[:, 1]:
197 unmatched_trackers.append(t)
198
IndexError: too many indices for array
I found the solution in the source code of linear_assignment
function, all you need to do is reshape the matched_indices
matched_indices = linear_sum_assignment(-iou_matrix)
matched_indices = np.array(list(zip(*matched_indices)))
matched_indices.shape = (-1, 2)
I used https://github.come/gatagat/lap and it works fine.