TypeError: object of type

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError: object of type相关的知识,希望对你有一定的参考价值。

执行python3 coco_eval.py 报错:
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_eval.py", line 146, in <module>
eval(coco_gt, image_ids, f‘{SET_NAME}_bbox_results.json‘)
File "coco_eval.py", line 118, in eval
coco_eval = COCOeval(coco_gt, coco_pred, ‘bbox‘)
...
.format(type(num)))
TypeError: object of type <class ‘numpy.float64‘> cannot be safely interpreted as an integer.

原因是numpy1.18.2版本与其他软件的兼容性的问题导致。
解决办法:将numpy1.18.2的版本降为1.17,测试可以正常运行。其他可行办法尚未测试。
结果如下:
loading annotations into memory...
Done (t=0.77s)
creating index...
index created!
Loading and preparing results...
DONE (t=5.35s)
creating index...
index created!
BBox
Running per image evaluation...
Evaluate annotation type bbox
DONE (t=129.90s).
Accumulating evaluation results...
DONE (t=12.08s).
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.326
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.502
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.342
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.118
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.376
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.509
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.268
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.402
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.430
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.172
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.502
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.624

以上是关于TypeError: object of type的主要内容,如果未能解决你的问题,请参考以下文章

TypeError:object of type ‘WebElement’ has no len()

TypeError: Object of type datetime is not JSON serializable问题解决

TypeError: Object of type datetime is not JSON serializable问题解决

TypeError: Object of type 'int32' is not JSON serializable ——已解决

将 pandas 数据附加到 hdf 存储,得到 'TypeError: object of type 'int' has no len()' 错误

python报"TypeError: object of type 'Greenlet' has no len()"