cocodataset / cocoapi

COCO API - Dataset @ http://cocodataset.org/
Other
6.08k stars 3.75k forks source link

Formatting a dataset in COCO-style #287

Open domarps opened 5 years ago

domarps commented 5 years ago

I am probably missing something obvious, but I am curious to know how a custom dataset can be formatted for an object detection task. I already have a dataset with 6 classes (none of them are COCO classes). Each class also has the bounding box co-ordinates x,y,w,h. Now, I am trying to figure out how we can prepare a dataset for Faster RCNN/MaskRCNN.

annotation{
"id" : int, 
"image_id" : int, 
"category_id" : int,
"segmentation" : RLE or [polygon], 
"area" : float, "bbox" : [x,y,width,height], 
"iscrowd" : 0 or 1,
}

categories[{
"id" : int, 
"name" : str, 
"supercategory" : str,
}]

As shown here, there are several fields which might not be necessary such as segmentation, iscrowd, supercategory etc. How exactly does one go about formatting the dataset COCO-style in order to be supported by MaskRCNN benchmark.

Some relevant issues which talk about this are https://github.com/facebookresearch/maskrcnn-benchmark/issues/297 and https://github.com/facebookresearch/maskrcnn-benchmark/issues/521

harrisonford commented 5 years ago

Hi! I had a similar problem when trying to conver VIA-VGG annotations to MSCOCO format, I created a gist that may help you solve it.

https://gist.github.com/harrisonford/6e2523bcc8778e6050ad188ee161975a

The only doubt I have is how you need to save "bbox" parameter, it seems it's not [x, y, w, h] which is super weird but oh well.

harrisonford commented 5 years ago

A small update of a problem I found:

The "area" parameter is not width x height of the bounding box (bbox), it's the area calculated from segmentation, therefore it generates problems when calculating IoU's with OKS as "area" of bbox can be way bigger than area of segmentation.

cucdengjunli commented 1 year ago

good

doem97 commented 1 year ago

A small update of a problem I found:

The "area" parameter is not width x height of the bounding box (bbox), it's the area calculated from segmentation, therefore it generates problems when calculating IoU's with OKS as "area" of bbox can be way bigger than area of segmentation.

HI I met the same problem. How you fix it?