【问题标题】:I keep getting this error: TypeError: tuple indices must be integers or slices, not tuple我不断收到此错误:TypeError: tuple indices must be integers or slices, not tuple
【发布时间】:2022-08-17 07:29:01
【问题描述】:

我正在尝试做这个教程:https://colab.research.google.com/drive/1d8PEeSdVlP0JogKwkytvFeyXXPu_qfXg?usp=sharing#scrollTo=sDixMreeUS_9

这是https://github.com/mjpramirez/Volvo-DataX GitHub 中的存储库

因此,当我尝试运行模型时,我不断收到此错误,并且我已经找到了哪个文件有此错误,这就是问题所在:

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

我试图用 0 替换 1 但仍然无法正常工作。

  • 欢迎来到堆栈溢出!请为您的问题创建一个minimal, reproducible example。例如,您能否分享有关错误的更多信息以及trackersmatched_indices 是什么?

标签: python object-detection


【解决方案1】:

您需要替换 sklearn.utils.linear_assignment_.linear_assignment 函数 通过scipy.optimize.linear_sum_assignment 函数。

不同之处在于返回格式:linear_assignment() 是 返回一个 numpy 数组和 linear_sum_assignment() 一个 numpy 数组的元组。 您可以通过将linear_sum_assignment() 的输出转换为数组并转置它来获得相同的输出。

 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)))

【讨论】:

    猜你喜欢
    • 2019-09-28
    • 1970-01-01
    • 2022-11-16
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 1970-01-01
    • 2023-02-07
    • 2019-07-23
    相关资源
    最近更新 更多