对Coco型数据集的评估返回错误

我正在使用https://github.com/facebookresearch/maskrcnn-benchmark中提供的Faster R-cnn模型。将KITTI数据集转换为Coco格式(2D对象检测)后,我正在尝试评估经过训练的模型的结果。

结果为0或-1,有时会在CocoApi工具箱中的g [“ area”]处引发错误。

  

pycoco,如果g ['ignore']或(g ['area'] aRng [1]):   “ KeyError:'区域'”

根据我在研究问题时发现的信息,“区域”用于细分,而我的数据集中没有这种注释。

有关转换后的注释文件外观的一个小示例:

{
    "images": [
        {
            "file_name": "007292.png","id": 1,"width": 1392,"height": 512
        },{
            "file_name": "000603.png","id": 2,{
            "file_name": "004313.png","id": 3,{
            "file_name": "006401.png","id": 4,{
            "file_name": "005442.png","id": 5,"height": 512
        }
    ],"annotations": [
        {
            "image_id": 1,"category_id": 1,"bbox": [
                589.08,176.53,26.719999999999914,26.409999999999997
            ],"iscrowd": 0
        },{
            "image_id": 1,"bbox": [
                235.9,190.63,115.16,57.78
            ],"bbox": [
                426.57,184.2,42.0,26.700000000000017
            ],{
            "image_id": 2,"bbox": [
                1211.2,182.65,11.799999999999955,186.35
            ],"bbox": [
                386.94,180.98,57.80000000000001,30.55000000000001
            ],"id": 6,"bbox": [
                736.21,173.49,113.90999999999997,96.44999999999999
            ],"id": 7,"bbox": [
                701.98,174.7,91.55999999999995,66.01000000000002
            ],"id": 8,"bbox": [
                682.42,176.25,58.200000000000045,47.53
            ],"id": 9,"bbox": [
                667.8,175.85,51.190000000000055,39.24000000000001
            ],"id": 10,"bbox": [
                654.6,176.88,31.110000000000014,26.49000000000001
            ],{
            "image_id": 3,"id": 11,"bbox": [
                267.69,179.7,101.13,33.120000000000005
            ],"id": 12,"bbox": [
                461.31,176.05,72.38000000000005,28.73999999999998
            ],"id": 13,"bbox": [
                600.36,177.08,52.360000000000014,23.299999999999983
            ],{
            "image_id": 4,"id": 14,"bbox": [
                1061.94,96.68,179.05999999999995,277.32
            ],"id": 15,"bbox": [
                280.52,184.02,148.01,96.92999999999998
            ],"id": 16,"bbox": [
                143.54,179.75,350.11,194.25
            ],"id": 17,"bbox": [
                861.45,139.2,178.20000000000005,64.58000000000001
            ],"id": 18,"bbox": [
                1018.27,144.44,88.04999999999995,43.25
            ],"id": 19,"bbox": [
                1061.23,147.01,100.31999999999994,39.27000000000001
            ],"id": 20,"bbox": [
                439.12,184.57,66.10000000000002,43.43000000000001
            ],"id": 21,"bbox": [
                381.68,184.81,98.5,63.59
            ],"id": 22,"bbox": [
                673.9,172.28,52.389999999999986,36.53999999999999
            ],"id": 23,"bbox": [
                473.3,180.94,49.079999999999984,36.900000000000006
            ],"id": 24,"bbox": [
                609.73,179.26,35.860000000000014,27.670000000000016
            ],"id": 25,"bbox": [
                668.0,173.81,88.37,31.150000000000006
            ],"id": 26,"bbox": [
                585.17,172.42,40.520000000000095,15.630000000000024
            ],{
            "image_id": 5,"id": 27,"bbox": [
                192.88,178.88,74.23000000000002,33.49000000000001
            ],"id": 28,"bbox": [
                250.68,179.92,65.70999999999998,26.27000000000001
            ],"id": 29,"bbox": [
                306.54,178.95,55.48999999999995,22.670000000000016
            ],"iscrowd": 0
        }
    ],"categories": [
        {
            "name": "Car","id": 1
        }
    ]
}

编辑:我已经将area属性添加到标签中,计算为bbox [2] * bbox [3],现在不再有错误,但结果为0。

任何帮助将不胜感激!

zhoufengao 回答:对Coco型数据集的评估返回错误

根据COCO官方文件的1. Detection Evaluation,还将评估area的AP。

Metrics

因此,如果您自己的自定义数据集中没有area,则site-packages/pycocotools/cocoeval.py的代码的以下部分将发生错误。

if g['ignore'] or (g['area']<aRng[0] or g['area']>aRng[1]):

此代码意味着,如果area超出上限aRng[1]或小于下限aRng[0],则会将其从评估目标中忽略。

如果您正在使用自己的自定义数据集,则基本事实中可能没有area。在这种情况下,您可以根据边界框的宽度和高度创建一个area

如果您不需要评估每个区域,则可以像下面的代码一样注释掉。

# It does not evaluate for each area
# if g['ignore'] or (g['area']<aRng[0] or g['area']>aRng[1]):
if g['ignore']:
本文链接:https://www.f2er.com/3110212.html

大家都在问