The aim is to convert a numpy array (2164, 190, 189, 2) containing pairs of grayscaled+groundtruth images to COCO format:
I tried to generate a minimalist annotation in coco format as follow:
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)
and I get the following error:
TypeError Traceback (most recent call last)
in () 2 category_info, 3 binary_mask, ----> 4 image.size, tolerance=2)
2 frames
/usr/local/lib/python3.6/dist-packages/PIL/Image.py in resize(self, size, resample, box) 1866 ) 1867 -> 1868 size = tuple(size) 1869 1870 if box is None:
TypeError: 'int' object is not iterable
Here image.size is equal to 35910 and image.shape is (190, 189).
It seems that create_annotation_info() is waiting a tuple or a list. Is it correct? What would be the right way to do it?
A draft colab notebook is here to get the whole dataset.