I do not quite understand this guide: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/instance_segmentation.md
I have many objects of three classes. According to the guide I have to make mask with dimension [N, H, W], where:
- N - count of objects
- H - image height
- W - image width
I have this function to create a mask
def image_mask(img, polygons):
w, h = img.size
n = len(polygons)
mask = np.zeros([n, h, w], dtype=np.float32)
for i in range(0, n):
polygon = polygons[i].reshape((-1, 1, 2))
tmp_mask = np.zeros([h, w], dtype=np.float32)
cv2.fillPoly(tmp_mask, [polygon], (1, 1, 1))
mask[i, :, :] = tmp_mask
return mask
I use this guide for creating my dataset: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/using_your_own_dataset.md
I add a mask to the end of tf_example
tf_example = tf.train.Example(features=tf.train.Features(feature={
...
'image/object/class/label': dataset_util.int64_list_feature(classes),
'image/object/mask': dataset_util.bytes_list_feature(mask.reshape((-1))),
}))
Because of reshape (I suppose), RAM quickly runs out and I get a memory error. What am I doing wrong? Maybe somewhere there is a detailed guide, how to create a mask for using Mask-RCNN and Tensorflow Object Detection API? I did not find this.