COCO2017 数据集分类统计

最近用到coco2017数据集做目标检测,顺便整理一下数据集。

coco数据集用专门的python api 方便我们直接来读取图片数据,详细的可以去看 https://github.com/cocodataset/cocoapi

我们这里主要是统计数据集的类别,这样就清楚自己的训练数据是否足够,不同的类别分布是否均衡等问题。

 

我们使用以下代码来统计类别、图片数、标注框数:

from pycocotools.coco import COCO

dataDir='./COCO'
dataType='val2017'
#dataType='train2017'
annFile='{}/annotations/instances_{}.json'.format(dataDir, dataType)

# initialize COCO api for instance annotations
coco=COCO(annFile)

# display COCO categories and supercategories
cats = coco.loadCats(coco.getCatIds())
cat_nms=[cat['name'] for cat in cats]
print('number of categories: ', len(cat_nms))
print('COCO categories: \n', cat_nms)

# 统计各类的图片数量和标注框数量
for cat_name in cat_nms:
    catId = coco.getCatIds(catNms=cat_name)     # 1~90
    imgId = coco.getImgIds(catIds=catId)        # 图片的id  
    annId = coco.getAnnIds(catIds=catId)        # 标注框的id

    print("{:<15} {:<6d}     {:<10d}".format(cat_name, len(imgId), len(annId)))

 

测试集输出:

类别图片数量标注框数量
person269311004
bicycle149316
car5351932
motorcycle159371
airplane97143
bus189285
train157190
truck250415
boat121430
traffic light191637
fire hydrant86101
stop sign6975
parking meter3760
bench235413
bird125440
cat184202
dog177218
horse128273
sheep65361
cow87380
elephant89255
bear4971
zebra85268
giraffe101232
backpack228371
umbrella174413
handbag292540
tie145254
suitcase105303
frisbee84115
skis120241
snowboard4969
sports ball169263
kite91336
baseball bat97146
baseball glove100148
skateboard127179
surfboard149269
tennis racket167225
bottle3791025
wine glass110343
cup390899
fork155215
knife181326
spoon153253
bowl314626
banana103379
apple76239
sandwich98177
orange85287
broccoli71316
carrot32303
hot dog0345
pizza153285
donut62338
cake124316
chair5801791
couch195261
potted plant172343
bed149163
dining table501697
toilet149179
tv207288
laptop183231
mouse88106
remote145283
keyboard106153
cell phone214262
microwave5455
oven115143
toaster89
sink187225
refrigerator101126
book2301161
clock204267
vase137277
scissors2836
teddy bear0262
hair drier911
toothbrush3457

 

训练集输出: 

类别图片数量标注框数量
person64115262465
bicycle32527113
car1225143867
motorcycle35028725
airplane29865135
bus39526069
train35884571
truck61279973
boat302510759
traffic light413912884
fire hydrant17111865
stop sign17341983
parking meter7051285
bench55709838
bird323710806
cat41144768
dog43855508
horse29416587
sheep15299509
cow19688147
elephant21435513
bear9601294
zebra19165303
giraffe25465131
backpack55288720
umbrella396811431
handbag684112354
tie38106496
suitcase24026192
frisbee21842682
skis30826646
snowboard16542685
sports ball42626347
kite22619076
baseball bat25063276
baseball glove26293747
skateboard34765543
surfboard34866126
tennis racket33944812
bottle850124342
wine glass25337913
cup918920650
fork35555479
knife43267770
spoon35296165
bowl711114358
banana22439458
apple15865851
sandwich23654373
orange16996399
broccoli19397308
carrot2451719
hot dog118426
pizza31665821
donut15237179
cake29256353
chair1277438491
couch44235779
potted plant44528652
bed36824192
dining table1183715714
toilet33534157
tv45615805
laptop35244970
mouse18762262
remote30765703
keyboard21152855
cell phone48036434
microwave15471673
oven28773334
toaster217225
sink46785610
refrigerator23602637
book533224715
clock46596334
vase35936613
scissors9471481
teddy bear166087
hair drier189198
toothbrush10071954

 

 

 

 

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

liguiyuan112

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值