每个类别的COCO数据集图像数

时间:2020-03-26 07:11:27

标签: neural-network coco

我看到COCO2017有80个班级118k训练和5k验证数据集(122k图像)。 我在这里有一个问题。每类的图像数量(每类1525张图像)约为122k / 80吗?

1 个答案:

答案 0 :(得分:0)

COCO数据集不是均匀分布的数据集,也就是说,所有都不具有相同数量的图像。因此,让我向您展示一种找出所需类别中图像数量的方法。

我正在使用PyCoco API处理COCO数据集。让我们找出COCO数据集的“人”类中的图像数量。这是一个代码要点,可以从COCO数据集中过滤掉任何类:

# Define the class (out of the 80 COCO classes)
filterClasses = ['person']

# Fetch class IDs only corresponding to the filterClasses
catIds = coco.getCatIds(catNms=filterClasses) 

# Get all images containing the above Category IDs
imgIds = coco.getImgIds(catIds=catIds)
print("Number of images containing the class:", len(imgIds))

在那里,我们获得了数据集中与“人”相对应的图像数量!

我最近在exploring and manipulating the COCO dataset上写了整篇文章。请看一下以获得更多细节和整个代码。

相关问题