facebookresearch / maskrcnn-benchmark

Fast, modular reference implementation of Instance Segmentation and Object Detection algorithms in PyTorch.
MIT License
9.3k stars 2.49k forks source link

Cityscapes to COCO inefficiency #466

Open botcs opened 5 years ago

botcs commented 5 years ago

I was looking into tools/cityscapes/convert_cityscapes_to_coco.py implementation, and found out that in L167 it is loading a json of already computed polygons to read the metadata and find the binary mask of the corresponding entry to convert them to polygons AGAIN, in tools/cityscapes/instances2dict_with_polygons.py.

Why is it necessary to recompute the polygons?

fmassa commented 5 years ago

To be frank, I don't know.

That file was taken as is from Detectron in https://github.com/facebookresearch/maskrcnn-benchmark/pull/232 by @henrywang1 , and I didn't actually reviewed that part of the PR, given that it was taken from Detectron.

If you see optimization opportunities there, feel free to send a PR!

akshitac8 commented 5 years ago

Hello @botcs as I understood from the code it is used to read the height and width of the image. You can replace that step by cv2.imread or lycon.load to get the height and width of the desired image. Hope this helps :slightly_smiling_face:

botcs commented 5 years ago

I am currently refactoring the structures/segmentation_mask.py and once it is done, it should be a choice whether the user wants to use the binary masks or the polygons from CityScapes.

If you see optimization opportunities there, feel free to send a PR!

Let me clarify: we download the masks and polygons both with the original dataset - and then we take the masks to generate polygons again. One possibility for this could be that this was some legacy code, maybe the polygon annotation feature was just added later. But that would contradict that the author of this piece of code already knew about the polygon annotation since it reads in the whole file just to check the width and height of the image. Thankfully this stuff goes offline but still its existence is intimidating