首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cocoEval summarize()返回所有mAP -1

cocoEval summarize()返回所有mAP -1
EN

Stack Overflow用户
提问于 2021-02-05 02:07:06
回答 1查看 190关注 0票数 0

我创建了一个带有注释的json,并执行以下代码:

代码语言:javascript
复制
import matplotlib.pyplot as plt
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
import numpy as np
import skimage.io as io
import pylab
import json 

pylab.rcParams['figure.figsize'] = (10.0, 8.0)


annType = ['segm','bbox','keypoints']
annType = annType[1]      #specify type here
prefix = 'person_keypoints' if annType=='keypoints' else 'instances'
print ('Running demo for *%s* results.'%(annType))

# use the valadation labelme file
annFile = '/content/json_moded.json'
cocoGt=COCO(annFile)
#initialize COCO detections api
# use the generated results
resFile = '/content/test_data_normal.json'
cocoDt=cocoGt.loadRes(resFile)

'''
dts = json.load(open(resFile,'r'))
imgIds = [imid['image_id'] for imid in dts]
imgIds = sorted(list(set(imgIds)))
'''
imgIds=sorted(cocoGt.getImgIds())

'''
imgIds=sorted(cocoGt.getImgIds())
imgIds=imgIds[0:24]
imgId = imgIds[np.random.randint(24)]
'''

# running box evaluation
cocoEval = COCOeval(cocoGt,cocoDt,annType)


cocoEval.params.imgIds  = imgIds
'''
cocoEval.params.catIds = [3] # 1 stands for the 'person' class, you can increase or decrease the category as needed
'''
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()

但结果如下:

代码语言:javascript
复制
Running demo for *bbox* results.
loading annotations into memory...
Done (t=0.01s)
creating index...
index created!
Loading and preparing results...
DONE (t=0.00s)
creating index...
index created!
Running per image evaluation...
Evaluate annotation type *bbox*
DONE (t=0.11s).
Accumulating evaluation results...
DONE (t=0.04s).
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = -1.000
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = -1.000
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = -1.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = -1.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000

为什么每个mAP都返回-1?

我不知道为什么返回这些结果,我认为两个json都是正确的。

我不知道为什么返回这些结果,我认为两个json都是正确的。

我不知道为什么返回这些结果,我认为两个json都是正确的。

EN

回答 1

Stack Overflow用户

发布于 2021-10-13 13:11:32

你必须注意不同的事情:

  • 来自ground truth json的images->id和类别映射中的image_id之间的映射

之间的映射

基本事实json示例

代码语言:javascript
复制
{
    "info": {
        "year": "2021",
        "version": "2",
        "description": "",
        "contributor": "",
        "url": "",
        "date_created": ""
    },
    "licenses": [
        {
            "id": 1,
            "url": "https://creativecommons.org/licenses/by/4.0/",
            "name": "CC BY 4.0"
        }
    ],
    "categories": [
        {
            "id": 1,
            "name": "cat",
            "supercategory": "none"
        }
    ],
    "images": [
        {
            "id": 0,
            "license": 1,
            "file_name": "1.jpg",
            "height": 512,
            "width": 512,
            "date_captured": ""
        },
        {
            "id": 1,
            "license": 1,
            "file_name": "e.jpg",
            "height": 512,
            "width": 512,
            "date_captured": ""
        }
    ],
    "annotations": [
        {
            "id": 0,
            "image_id": 0,
            "category_id": 1,
            "bbox": [
                261,
                358,
                16,
                26
            ],
            "area": 416,
            "segmentation": [],
            "iscrowd": 0
        }
    ]
}

prediction.json

代码语言:javascript
复制
[{"image_id": 0, "category_id": 1, "bbox": [84.116, 442.13, 43.356, 25.849], "score": 0.87929}]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66051351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档