-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: tuple indices must be integers or slices, not tuple #92
Comments
This happened to me when I changed:
Because sklearn's Thus, to get the equivalent result as if we were using sklearn's implementation I modified import sklearn
skver = int(sklearn.__version__[2:4]) # extract middle number of version with format \d.\d\d.\d\d
if skver >= 23:
from scipy.optimize import linear_sum_assignment as linear_assignment
sk = False # we will not use sklearn implementation
else:
from sklearn.utils.linear_assignment_ import linear_assignment
sk = True # we will use sklearn implementation
# Below code was written after the `matched_indices` object had been created under the `associate_detections_to_trackers` function
matched_indices = linear_assignment(-iou_matrix)
# standardize output to match sklearn implementation if using scipy
if sk == False:
row, col = matched_indices
matched_indices = np.concatenate((row.reshape(-1,1), col.reshape(-1,1)), axis = 1) Below code highlights the differences between the two implementations: # sklearn implementation
from sklearn.utils.linear_assignment_ import linear_assignment
import numpy as np
cost = np.array([[4, 1, 3], [2, 0, 5], [3, 2, 2]])
result = linear_assignment(cost)
result # array([[0, 1],
# [1, 0],
# [2, 2]])
# scipy implementation
import numpy as np
from scipy.optimize import linear_sum_assignment as linear_assignment
cost = np.array([[4, 1, 3], [2, 0, 5], [3, 2, 2]])
result = linear_assignment(cost)
result # (array([0, 1, 2]), array([1, 0, 2], dtype=int64))
row, col = result
result = np.concatenate((row.reshape(-1,1), col.reshape(-1,1)), axis = 1)
result # array([[0, 1],
# [1, 0],
# [2, 2]], dtype=int64) |
Sorry,I met the same problem. But I'm not quite understand where's |
I got to know that we were talking about the different project, so i opened a new issue #98 (comment). could you please give me a hand? |
this worked for me,thank you |
If you encountered a problem in the linear_assignment.py Mine is for a different project, but the error was same for me. indices = linear_assignment(cost_matrix) hope it helps :) |
if(d not in matched_indices[:,0]):
TypeError: tuple indices must be integers or slices, not tuple
The text was updated successfully, but these errors were encountered: