xxwan1120 2019-07-16 10:20 采纳率: 0%
浏览 3563
已结题

Mask RCNN中mask的提取问题

关于mask RCNN在测试时,生成的mask是与原图片在一起的,现在想单独将mask提取出来,但是当图中有多类目标时,无法同时提取所有mask,应该是代码的for循环出了问题,但我是新手小白,不知道该如何解决,求教

def display_masks(count,image, boxes, masks, class_ids,
title="",
figsize=(6.4, 4.8), ax=None,
show_mask=True,
colors=None):
# Number of instances
N = boxes.shape[0]
if not N:
print("\n*** No instances to display *** \n")
else:
assert boxes.shape[0] == masks.shape[-1] == class_ids.shape[0]

# If no axis is passed, create one and automatically call show()
auto_show = False
if not ax:
    _, ax = plt.subplots(1, figsize=figsize)
    auto_show = True
# Generate random colors
colors = colors or random_colors(N)
# Show area outside image boundaries.
height, width = image.shape[:2]
#ax.set_ylim(height + 10, -10)
#ax.set_xlim(-10, width + 10)
ax.axis('off')
ax.set_title(title)
masked_image = image.astype(np.uint32).copy()
for i in range(N):
    color = colors[i]
    # Mask
    mask = masks[:, :, i]
    if show_mask:
        masked_image = apply_mask(masked_image, mask, color)

    # Mask Polygon
    # Pad to ensure proper polygons for masks that touch image edges.
    padded_mask = np.zeros(
        (mask.shape[0] + 2, mask.shape[1] + 2), dtype=np.uint8)
    padded_mask[1:-1, 1:-1] = mask


ax.imshow(mask.astype(np.uint8))
if auto_show:
    plt.show()

  • 写回答

1条回答 默认 最新

  • hjdhdgfh 2019-07-16 10:21
    关注

    对应matterport/Mask_RCNNKeras开源代码nnn

    评论

报告相同问题?

悬赏问题

  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝