TypeError: 'numpy.float64' object cannot be interpreted as an integer

如题,float64类型不能被安全地转换成整型。版本的numpy不支持使用浮点数作为步长,numpy1.17.0下的版本可以。

Traceback (most recent call last):
  File "/home/zmd/software/anaconda3/lib/python3.7/site-packages/numpy/core/function_base.py", line 117, in linspace
    num = operator.index(num)
TypeError: 'numpy.float64' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "coco_validation.py", line 49, in <module>
    main()
  File "coco_validation.py", line 45, in main
    coco_eval.evaluate_coco(dataset_val, retinanet)
  File "/home/zmd/project/pytorch-retinanet/retinanet/coco_eval.py", line 76, in evaluate_coco
    coco_eval = COCOeval(coco_true, coco_pred, 'bbox')
  File "/home/zmd/.local/lib/python3.7/site-packages/pycocotools/cocoeval.py", line 76, in __init__
    self.params = Params(iouType=iouType) # parameters
  File "/home/zmd/.local/lib/python3.7/site-packages/pycocotools/cocoeval.py", line 527, in __init__
    self.setDetParams()
  File "/home/zmd/.local/lib/python3.7/site-packages/pycocotools/cocoeval.py", line 507, in setDetParams
    self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)
  File "<__array_function__ internals>", line 6, in linspace
  File "/home/zmd/software/anaconda3/lib/python3.7/site-packages/numpy/core/function_base.py", line 121, in linspace
    .format(type(num)))
TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.

解决方法:
降低numpy的版本。

具体步骤如下:

查看自身numpy版本:

pip show numpy

降低numpy版本:

pip install -U numpy==1.17.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

后面加上 -i 是为了设置清华镜像源作为下载地址,速度飞快。

降低版本号后即可正常调用coco的api了。

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值