Hello,
I have several datasets, made of pairs of images (greyscaled, groundtruth) looking like this:
where the groundtruth labels can decomposed into three binary masks.
These datasets (for example) are available as a numpy array of shape (N, width, height, comp), or as pairs of png images also available on github.
The project would be to train different semantic/ instance segmentation models available in Detectron2 on these datasets. I understand that detectron 2 needs a COCO formatted dataset to work on.
I would like to build a minimalist coco dataset from a pair of grey+groundtruth (or masks) images.
Is there a tool available in PyTorch for that purpose?
I know there are two libraries (pycococreator, imantics) for this. I haven’t been successful up to now with pycococreator (A draft colab notebook is available).
For example, the following snippet fails:
from pycococreatortools import pycococreatortools
N = 1
grey = data[N,:,:,0]
labels = data[N,:,:,1]
mask1 = labels == 1
mask2 = labels == 2
mask3 = labels == 3
segmentation_id = "chromosome1_1"
image_id = "0001"
category_info = "chromosome1"
binary_mask = mask1
image = grey
print(image.size, image.shape)
annotation_info_mask1 = pycococreatortools.create_annotation_info(segmentation_id, image_id,
category_info,
binary_mask,
image.size, tolerance=2)