在使用pycocotools的时候报TypeError: object of type
File "/home/disk0/zw/workspace/models/research/object_detection/metrics/coco_evaluation.py", line 415, in first_value_func
self._metrics = self.evaluate()
File "/home/disk0/zw/workspace/models/research/object_detection/metrics/coco_evaluation.py", line 246, in evaluate
coco_wrapped_groundtruth, coco_wrapped_detections, agnostic_mode=False)
File "/home/disk0/zw/workspace/models/research/object_detection/metrics/coco_tools.py", line 177, in __init__
cocoeval.COCOeval.__init__(self, groundtruth, detections, iouType=iou_type)
File "/home/zw/anaconda3/envs/competition/lib/python3.6/site-packages/pycocotools/cocoeval.py", line 76, in __init__
self.params = Params(iouType=iouType) # parameters
File "/home/zw/anaconda3/envs/competition/lib/python3.6/site-packages/pycocotools/cocoeval.py", line 527, in __init__
self.setDetParams()
File "/home/zw/anaconda3/envs/competition/lib/python3.6/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/zw/anaconda3/envs/competition/lib/python3.6/site-packages/numpy/core/function_base.py", line 121, in linspace
.format(type(num)))
通过上面的信息可以看到,错误原因是cocoeval.py中的np.linspace函数导致的,发生这个原因是因为np.linspace函数的num参数不支持float类型导致的,找到lib/python3.6/site-packages/pycocotools下的cocoeval.py文件,将507行改成如下
self.iouThrs = np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True)
或者安装numpy的1.11.0的版本,可能无法兼容TensorFlow的版本,导致无法使用TensorFlow,最好还是修改coceval.py文件