cocoAPI问题

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

Traceback (most recent call last):
  File "D:\ProgramData\Anaconda3\envs\torch\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "D:\ProgramData\Anaconda3\envs\torch\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\Users\10172979\.vscode\extensions\ms-python.python-2021.2.582707922\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "c:\Users\10172979\.vscode\extensions\ms-python.python-2021.2.582707922\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
    run()
  File "c:\Users\10172979\.vscode\extensions\ms-python.python-2021.2.582707922\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
    runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
  File "D:\ProgramData\Anaconda3\envs\torch\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "D:\ProgramData\Anaconda3\envs\torch\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "D:\ProgramData\Anaconda3\envs\torch\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "d:\project\project5\code\python\yolov4\train.py", line 630, in <module>
    device=device, )
  File "d:\project\project5\code\python\yolov4\train.py", line 314, in train
    evaluator = evaluate(eval_model, val_loader, config, device)
  File "D:\ProgramData\Anaconda3\envs\torch\lib\site-packages\torch\autograd\grad_mode.py", line 26, in decorate_context
    return func(*args, **kwargs)
  File "d:\project\project5\code\python\yolov4\train.py", line 485, in evaluate
    coco_evaluator = CocoEvaluator(coco, iou_types = ["bbox"], bbox_fmt='coco')
  File "d:\project\project5\code\python\yolov4\tool\tv_reference\coco_eval.py", line 30, in __init__
    self.coco_eval[iou_type] = COCOeval(coco_gt, iouType=iou_type)
  File "D:\ProgramData\Anaconda3\envs\torch\lib\site-packages\pycocotools\cocoeval.py", line 76, in __init__
    self.params = Params(iouType=iouType) # parameters
  File "D:\ProgramData\Anaconda3\envs\torch\lib\site-packages\pycocotools\cocoeval.py", line 527, in __init__
    self.setDetParams()
  File "D:\ProgramData\Anaconda3\envs\torch\lib\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 "D:\ProgramData\Anaconda3\envs\torch\lib\site-packages\numpy\core\function_base.py", line 113, in linspace
    num = operator.index(num)
TypeError: 'numpy.float64' object cannot be interpreted as an integer

原因:cocoeval.py文件中调用的了np.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)函数。新版本的numpy要求num为整数。
修改:修改Lib\site-packages\pycocotools文件下cocoeval.py文件,修改507等行如下:

self.iouThrs = np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True)
self.recThrs = np.linspace(.0, 1.00, int(np.round((1.00 - .0) / .01)) + 1, endpoint=True)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值