I am trying to convert my COCO annotations to a mask. Each instance in the COCO annotations need to be represented as an unique instance in the mask. I found this question which does convert the annotations to a mask but there are only two unique instances of objects within the mask.
Here is an image of a mask. One can see that there are only two distinct instances (colors). I need every object to be a unique instance (color)
Is there another technique I can use to preserve ALL individual instances?
Many thanks.
Referring to the question you linked, you should be able to achieve the desired result by simply avoiding the following loop where the individual masks are combined:
For example, the following code creates subfolders by appropriate annotation categories and saves black and white masks in the corresponding folders with the name of the images to which the masks belong:
If I understand correctly, you have multiple masks of one category for individual images. In this case, the masks would have to be assigned to lists, for instance, and processed accordingly. Or in the above example, the individual image files would have to be uniquely named for saving (see, e.g, here). Creating different colors is then just a matter of further processing, e.g., with numpy.
All this under the condition that the desired object masks are really defined as individual instances in your COCO data set.