我不太明白这个指南:https : //github.com/tensorflow/models/blob/master/research/object_detection/g3doc/instance_segmentation.md
我有很多三个类的对象。根据指南,我必须制作尺寸为 [N, H, W] 的面具,其中:
我有这个功能来创建一个面具
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
Run Code Online (Sandbox Code Playgroud)
我使用本指南来创建我的数据集:https : //github.com/tensorflow/models/blob/master/research/object_detection/g3doc/using_your_own_dataset.md
我在 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))),
}))
Run Code Online (Sandbox Code Playgroud)
由于reshape …
python mask object-detection tensorflow object-detection-api