簡體   English   中英

我不斷收到此錯誤:TypeError: tuple indices must be integers or slices, not tuple

[英]I keep getting this error: TypeError: tuple indices must be integers or slices, not tuple

我正在嘗試做這個教程: https://colab.research.google.com/drive/1d8PEeSdVlP0JogKwkytvFeyXXPu_qfXg?usp=sharing#scrollTo=sDixMreeUS_9

這是https://github.com/mjpramirez/Volvo-DataX GitHub中的存儲庫

因此,當我嘗試運行 model 時,我不斷收到此錯誤,並且我已經找到了哪個文件有此錯誤,這就是問題所在:

unmatched_trackers = []
  for t,trk in enumerate(trackers):
    if(t not in matched_indices[:,1]):
      unmatched_trackers.append(t)

我試圖用 0 替換 1 但仍然無法正常工作。

You need to replace the sklearn.utils.linear_assignment_.linear_assignment function by the scipy.optimize.linear_sum_assignment function by importing like from scipy.optimize import linear_sum_assignment as linear_assignment .

不同之處在於返回格式: linear_assignment()返回一個 numpy 數組,而linear_sum_assignment()返回一個 numpy arrays 的元組。 通過在數組中轉換linear_sum_assignment()的 output 並轉置它,您可以獲得相同的 output。

 Example: 
  matched_indices = linear_assignment(-iou_matrix)
  matched_indices = np.asarray(matched_indices)
  matched_indices = np.transpose(matched_indices)

  OR 

matched_indices = np.array(list(zip(*matched_indices)))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM