资源链接

安装

  • 参考matterport版本的GitHub的README.md中requirements
  • 另外如果要在MS COCO数据集上训练、测试,还需pycocotools

相关博客

学习Mask RCNN网络结构,并构建颜色填充器应用

该版本以ResNet101 + FPN为backbone,heads包括检测和Mask预测两部分,其中检测部分包括类别预测和bbox回归。

English Version 中文版

网络介绍

Mask R-CNN是用于实例分割和目标检测的,在目标检测网络Faster R-CNN基础上增加Mask预测分支



(图片来源:https://blog.csdn.net/linolzhang/article/details/71774168)

Mask RCNN改进

  1. Mask Scoring R-CNN: 给Mask也打个分
  2. Faster Training of Mask R-CNN by Focusing on Instance Boundaries: 利用实例边缘信息加速训练:训练过程中,对预测的Mask和GT的Mask进行边缘检测,计算两者的均方误差(Mean Square Error, MSE),将其作为损失函数的一部分(我把Paper中Edge Argument Head简单实现了)。我个人理解是:该文章更多是加速了网络训练的速度,因此精度有一定的提高(在训练过程中用边缘信息指明了一条道路,因此在梯度下降的过程中快了一些)
Code is Here: 点击查看详细内容

在mrcnn/model.py中添加edge_loss函数项

def mrcnn_edge_loss_graph(target_masks, target_class_ids, pred_masks):
"""Edge L2 loss for mask edge head
target_masks: [batch, num_rois, height, width].
A float32 tensor of Value 0 or 1(boolean?). Use zero padding to fill array
target_class_ids: [batch, num_rois]. Integer class IDs. Zeros padded.
pred_masks: [batch, proposal, height, width, num_classes] float32 tensor
with value from 0 to 1(soft mask)(more information)
"""
# Reshape for simplicity. Merge first two dimensions into one
# 即将batch 和 num_rois 合并为一项
target_class_ids = K.reshape(target_class_ids, (-1,))
mask_shape = tf.shape(target_masks)
target_masks = K.reshape(target_masks, (-1, mask_shape[2], mask_shape[3]))
pred_shape = tf.shape(pred_masks)
pred_masks = K.reshape(pred_masks,
(-1, pred_shape[2], pred_shape[3], pred_shape[4]))
#Permute predicted masks to [N, num_classes, height, width]
pred_masks = tf.transpose(pred_masks, [0, 3, 1, 2]) # Only positive ROIs contribute to the loss. (正的ROI是相对BG而言吗)
# And only the class specific mask of each ROI
# tf.where 获得索引值
# tf.gather 根据索引值从张量中获得元素构成新张量Tensor
# tf.cast 类型转换
# tf.stack
positive_ix = tf.where(target_class_ids > 0)[:, 0]
positive_class_ids = tf.cast(
tf.gather(target_class_ids, positive_ix), tf.int64)
indices = tf.stack([positive_ix, positive_class_ids], axis=1) # Gather the masks (predicted and true) that contribute to loss
y_true = tf.gather(target_masks, positive_ix)
y_pred = tf.gather_nd(pred_masks, indices) # shape: [batch * rois, height, width, 1]
y_true = tf.expand_dims(y_true, -1)
y_pred = tf.expand_dims(y_pred, -1) y_true = 255 * y_true
y_pred = 255 * y_pred # shape: [3, 3, 1, 2]
sobel_kernel = tf.constant([[[[1, 1]], [[0, 2]], [[-1, 1]]],
[[[2, 0]], [[0, 0]], [[-2, 0]]],
[[[1,-1]], [[0,-2]], [[-1,-1]]]], dtype=tf.float32) # Conv2D with kernel
edge_true = tf.nn.conv2d(y_true, sobel_kernel, strides=[1, 1, 1, 1], padding="SAME")
edge_pred = tf.nn.conv2d(y_pred, sobel_kernel, strides=[1, 1, 1, 1], padding="SAME") # abs and clip
edge_true = tf.clip_by_value(abs(edge_true), 0, 255)
edge_pred = tf.clip_by_value(abs(edge_pred), 0, 255) # Mean Square Error(MSE) Loss
return tf.reduce_mean(tf.square(edge_true/255. - edge_pred/255.))</code> </pre>

说明

  • Keras中fit函数中,每个Epoch训练的数目是 batch_size × steps per epoch,故每个Epoch不一定是把整个train_set全部训练一遍。原帖子
  • 使用conda install命令安装tensorflow-gpu教程
  • 如果用不习惯.ipynb文件,可以用Jupyter NoteBook将其保存为.py文件

    命令行输入jupyter notebook启动,打开文件后Download as Python(.py)
  • 另外,感觉有一个idea还是不够的,而且还要做充分的实验进行验证(比如说为什么边缘检测用的是Sobel,而是Laplace或是Canny)(又有点实践指导理论的意思。。。)。
  • 最后,欢迎批评指正!

Mask_RCNN学习记录(matterport版本)的更多相关文章

  1. Java 静态内部类与非静态内部类 学习记录.

    目的 为什么会有这篇文章呢,是因为我在学习各种框架的时候发现很多框架都用到了这些内部类的小技巧,虽然我平时写代码的时候基本不用,但是看别人代码的话至少要了解基本知识吧,另外到底内部类应该应用在哪些场合 ...

  2. Python学习记录day6

    title: Python学习记录day6 tags: python author: Chinge Yang date: 2016-12-03 --- Python学习记录day6 @(学习)[pyt ...

  3. AndroidStudio学习记录

    AndroidStudio学习记录 1. 插件的使用. plugins.jetbrains.com插件网站. 2. 目录介绍: 1.Studio中有Project和Module的概念,前面说到Stud ...

  4. 开源项目Material Calendar View 学习记录 (一)

    开源项目Material Calendar View 学习记录 Github: https://github.com/prolificinteractive/material-calendarview ...

  5. Vue学习记录第一篇——Vue入门基础

    前面的话 Vue中文文档写得很好,界面清爽,内容翔实.但文档毕竟不是教程,文档一上来出现了大量的新概念,对于新手而言,并不友好.个人还是比较喜欢类似于<JS高级程序设计>的风格,从浅入深, ...

  6. 我的Spring学习记录(四)

    虽然Spring管理这我们的Bean很方便,但是,我们需要使用xml配置大量的Bean信息,告诉Spring我们要干嘛,这还是挺烦的,毕竟当我们的Bean随之增多的话,xml的各种配置会让人很头疼. ...

  7. ElasticSearch 学习记录之 分布式文档存储往ES中存数据和取数据的原理

    分布式文档存储 ES分布式特性 屏蔽了分布式系统的复杂性 集群内的原理 垂直扩容和水平扩容 真正的扩容能力是来自于水平扩容–为集群添加更多的节点,并且将负载压力和稳定性分散到这些节点中 ES集群特点 ...

  8. Git学习记录--git仓库

    Git是一款强大的版本控制工具,与svn相比git的分布式提交,本地仓库等在使用时确实比较方便.当然两者之间各有优劣,我在这里不多做比较.由于之前少有接触git,只是零星大致地了解一点,所以找时间系统 ...

  9. java开源项目之IQQ学习记录之项目环境搭建与启动

    本文链接地址:http://blog.csdn.net/sushengmiyan/article/details/18779727 作者:sushengmiyan 现在就码字说说今天晚上搞定的一个项目 ...

随机推荐

  1. vue nextTick使用

    Vue nextTick使用 vue生命周期 原因是在created()钩子函数执行的时候DOM 其实并未进行任何渲染,而此时进行DOM操作无异于徒劳,所以此处一定要将DOM操作的js代码放进Vue. ...

  2. ansible-playbook(nginx例)

    一.创建目录结构 cd /etc/ansible/roles/ mkdir nginx/{files,templates,vars,handlers,meta,default,tasks} -pv 二 ...

  3. 搭建一个MP-demo(mybatis_plus)

    MyBatis-Plus(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发.提高效率而生. 搭建一个简单的MP-demo 1.配置pom.xml ...

  4. windows编程 进程的创建销毁和分析

    Windows程序设计:进程 进程是一个具有一定独立功能的程序关于某个数据集合的一次运行活动,在Windows编程环境下,主要由两大元素组成: • 一个是操作系统用来管理进程的内核对象.操作系统使用内 ...

  5. git 学习(4) ----- git rebase

    使用git rebase 的前提是多人协作下的分支开发,如果是单人开发,那就没有必要使用它了,这是由git rebase 的作用所决定的,git rebase 有两大作用:一个是与主分支保持同步,一个 ...

  6. codeforces476D

    Dreamoon and Sets CodeForces - 476D Dreamoon likes to play with sets, integers and .  is defined as ...

  7. miui 系统铃声

    MIUI7-8系统铃声和通知铃声等,从miui system.img中提取出来的: 链接:http://pan.baidu.com/s/1bpH5N5P 密码:tz7p

  8. TOP按钮

    TOP按钮 博客园页面添加返回顶部TOP按钮 进入网页管理->设置 在"页面定制CSS代码"中添加如下css样式,当然你可以改为自己喜欢的样式 此处可以将背景色backgro ...

  9. Docke--利用 commit 理解构建镜像

    Docker 利用commit理解构建镜像 镜像是容器的基础,每次执行 docker run 的时候都会指定哪个镜像作为容器运行的基础.当我们使用Docker Hub的镜像无法满足我们的需求时,我们就 ...

  10. 微信小程序onLaunch、onLoad执行生命周期

    原文转载自:微信小程序onLaunch.onLoad执行生命周期 1.需求:先执行App的onLaunch添加验证权限等,再执行Page里的onLoad. 2.问题:还没有等onLaunch执行完成, ...