如何在Python中计数可可格式数据集中某些类的实例
我通过使用LabelME软件完成了一些数据注释工作。因此,我现在拥有可可格式的完整数据集。
但是,我正在挣扎着几件事。
在我的数据集中,我总共有10张图像和3个类别,即,苹果,芒果和香蕉。
在这10张图像中,有6张图像包含苹果,5张图像包含芒果,其中4张包含香蕉。
有了我的代码,我可以计算这件事。
在包含苹果的6张图像中,有4张图像有5个苹果 每个。所以现在我想知道每个实例的总数 我的数据集中的类别。是否可能?
例如,我正在附上一张图像。
在此图像上,有X级大象的实例数。我想从注释的数据集中计算X。我需要帮助,因为我非常陌生。
提前致谢。
I have done some data annotation work by using labelme software. So, I have now the complete dataset in COCO format.
However, I am struggling with a few things.
In my dataset, I have in total of 10 images, and 3 categories,i.e., apple, mango, and banana.
Of those 10 images, 6 images contain apple, 5 images contain mango, and 4 contain banana.
With my code, I can count this thing.
Among those 6 images which contain apples, 4 images have 5 apples
each. So now I want to know the total number of instances of each
category in my dataset. Is it possible?
for example, I am attaching one image.
On this image, there is X number of instances from Class Elephant. I want to count the X from my annotated dataset. I need help because I am very new to this.
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可能为时已晚,无法帮助您,但对其他任何人来说。
可可注释文件有5个密钥(用于对象检测)“信息”,“许可”,“图像”,“注释”,“类别”。
注释对列表的每个元素都有一个命令。
类别在类别ID及其名称之间具有映射。
首先,您必须获得该ID->类映射。
然后通过那些注释迭代,将计数添加到相关类中(字典中的增量计数器1)。
I'm probably far too late to help you, but for anyone else.
COCO annotation files have 5 keys (for object detection) “info”, “licenses”, “images”, “annotations”, “categories”.
Annotations has a dict for each element of a list.
Categories has a mapping between category IDs and their names.
First you have to get that ID -> Class Mapping.
Then iterate through those annotations adding a count to the relevant class (increment counter in dictionary by 1).