东方耀AI技术分享

标题: TypeError: slice indices must be integers or None or have an __index__ method [打印本页]

作者: 东方耀    时间: 2019-8-10 17:17
标题: TypeError: slice indices must be integers or None or have an __index__ method


bbox_targets[ind, start:end] = bbox_target_data[ind, 1:]
TypeError: slice indices must be integers or None or have an __index__ method



出错原因:
可能是源代码发布的时候,numpy 是支持浮点数作为索引的,但是在 numpy1.12.0 之后,numpy 只能用整数作为索引。所以,解决办法有两种:
第一种是卸载当前的 numpy,安装回以前的 1.11.2 版本,但是同时安装的 opencv 版本也得退回老版本,因为新版本的 opencv3.1 依赖于新版本的 numpy,相同的依赖问题还有matplotlib。因此的重装回 openCV2.4.13, matplotlib1.5.1,当然这种办法比较麻烦;
第二种办法是找到使用浮点数作为 numpy 索引的相关代码,将其强制转换为 int 型:


修改
py-faster-rcnn/lib/rpn/proposal_target_layer.py 第124行
强转为int类型   cls = int(clss[ind])











欢迎光临 东方耀AI技术分享 (http://www.ai111.vip/) Powered by Discuz! X3.4