【发布时间】:2018-11-21 01:57:20
【问题描述】:
我正在使用 Mask RCNN 并尝试修改此示例 (https://github.com/matterport/Mask_RCNN/blob/master/samples/balloon/balloon.py),该示例识别气球以使其识别气球和蛋糕,即将类数增加到两个。
def load_mask(self, image_id):
"""Generate instance masks for an image.
Returns:
masks: A bool array of shape [height, width, instance count] with
one mask per instance.
class_ids: a 1D array of class IDs of the instance masks.
"""
# If not a balloon dataset image, delegate to parent class.
image_info = self.image_info[image_id]
if image_info["source"] != "student":
return super(self.__class__, self).load_mask(image_id)
# Convert polygons to a bitmap mask of shape
# [height, width, instance_count]
info = self.image_info[image_id]
mask = np.zeros([info["height"], info["width"], len(info["polygons"])],
dtype=np.uint8)
for i, p in enumerate(info["polygons"]):
# Get indexes of pixels inside the polygon and set them to 1
rr, cc = skimage.draw.polygon(p['all_points_y'], p['all_points_x'])
mask[rr, cc, i] = 1
**# Return mask, and array of class IDs of each instance. Since we have
# one class ID only, we return an array of 1s**
return mask.astype(np.bool), np.ones([mask.shape[-1]], dtype=np.int32)
正如我们在 load_mask 函数的最后一条注释中看到的那样,这段代码只为一个类编写。如何修改两个类?
【问题讨论】:
标签: machine-learning deep-learning computer-vision