『计算机视觉』Mask-RCNN_项目文档翻译
基础介绍
项目地址:Mask_RCNN
语言框架:Python 3, Keras, and TensorFlow
Python 3.4, TensorFlow 1.3, Keras 2.0.8 其他依赖见:requirements.txt
基础网络:Feature Pyramid Network (FPN) and a ResNet101 backbone
文件介绍
以下是模型主体文件,
demo.ipynb Is the easiest way to start. It shows an example of using a model pre-trained on MS COCO to segment objects in your own images. It includes code to run object detection and instance segmentation on arbitrary images.
train_shapes.ipynb shows how to train Mask R-CNN on your own dataset. This notebook introduces a toy dataset (Shapes) to demonstrate training on a new dataset.
(model.py, utils.py, config.py): These files contain the main Mask RCNN implementation.
下面的几个文件是观察理解模型所用,
inspect_data.ipynb. This notebook visualizes the different pre-processing steps to prepare the training data.
inspect_model.ipynb This notebook goes in depth into the steps performed to detect and segment objects. It provides visualizations of every step of the pipeline.
inspect_weights.ipynb This notebooks inspects the weights of a trained model and looks for anomalies and odd patterns.
可视化展示:
下面图片展示了RPN网络的输出,即同时包含了积极锚框和消极锚框的proposal们:

下面展示了送入回归器之前的(第一步中的proposal)和最终输出的定位框坐标:

mask展示,

查看不同层的激活特征,

权重分布直方图,

调用训练
Training on MS COCO
作者已经提供了一个预训练好的基于COCO数据的权重以便我们快速启动训练任务,相关代码位于samples/coco/coco.py,我们既可以将之作为包导入到自己的代码中,也可以如下在命令行直接调用该部分代码,
# Train a new model starting from pre-trained COCO weights
python3 samples/coco/coco.py train --dataset=/path/to/coco/ --model=coco # Train a new model starting from ImageNet weights
python3 samples/coco/coco.py train --dataset=/path/to/coco/ --model=imagenet # Continue training a model that you had trained earlier
python3 samples/coco/coco.py train --dataset=/path/to/coco/ --model=/path/to/weights.h5 # Continue training the last model you trained. This will find
# the last trained weights in the model directory.
python3 samples/coco/coco.py train --dataset=/path/to/coco/ --model=last
如果我们希望验证COCO数据于最后保存的模型之上,
# Run COCO evaluation on the last trained model
python3 samples/coco/coco.py evaluate --dataset=/path/to/coco/ --model=last
相关参数仍然位于samples/coco/coco.py。
Training on Your Own Dataset
作者推荐了一篇博客blog post about the balloon color splash sample,介绍了从标注图片到训练它们再到将结果应用于一个小例子中的流程,其源码也位于本项目内,见samples/coco/balloon。
为了训练自己的数据,我们需要修改继承两个类,
ConfigThis class contains the default configuration.Subclass it and modify the attributes you need to change.
DatasetThis class provides a consistent way to work with any dataset. // 一个class可以处理不同数据集It allows you to use new datasets for training without having to change the code of the model. // 通过这个class我们可以最大程度避免修改model文件本身
It also supports loading multiple datasets at the same time, which is useful if the objects you want to detect are not all available in one dataset. // 可以同时处理不同数据集用于一次训练,满足特殊需求
有关使用示例见这四个文件:
samples/shapes/train_shapes.ipynb,
samples/coco/coco.py,
samples/balloon/balloon.py,
samples/nucleus/nucleus.py。
不同于论文之处
为了代码的简单和可扩展性,作者对工程进行了小幅度调整,其统计如下:
Image Resizing:本工程的图像尺寸预调整不同于原论文中的,以COCO数据集为例,作者将数据调整为1024*1024的大小,为了保证长宽比不变(语义不受影响),作者采取了填充0将图片变为1:1长宽比的方式,而非直接裁剪插值。
Bounding Boxes:数据集中的数据标签,除了带有mask标签之外,还有gt box标签,作者为了统一并简化操作,舍弃了box标签,完全使用mask图,使用它们生成一个完全覆盖全部标记像素的框作为gt box,这一步骤很大程度上简化了图像增强操作,很多例如旋转处理一样的预处理操一旦涉及gt box就会变得很麻烦,采用mash生成方式可以使得预处理操作更为方便。
为了验证计算出来的gt box和原数据gt box的差异,作者进行了比较,效果如下:
We found that ~2% of bounding boxes differed by 1px or more, ~0.05% differed by 5px or more, and only 0.01% differed by 10px or more.
Learning Rate:原论文使用0.02的学习率,作者实验觉得该学习率偏大,经常性造成梯度爆炸,特别是当batch很小时,作者有两点猜测:这可能是因为caffe与TensorFlow在多GPU上传播更新梯度的策略不同所致(sum vs mean across batches and GPUs);或者这是由于paper团队使用了clip梯度的方式规避了梯度爆照的发生,但是作者提到他采用的clipping操作效果并不显著。
安装工程
1、Install dependencies
pip3 install -r requirements.txt
2、Clone this repository
3、Run setup from the repository root directory
python3 setup.py install
4、Download pre-trained COCO weights (mask_rcnn_coco.h5) from the releases page.
5、(Optional) To train or test on MS COCO install pycocotools from one of these repos. They are forks of the original pycocotools with fixes for Python3 and Windows (the official repo doesn't seem to be active anymore).
- Linux: https://github.com/waleedka/coco
- Windows: https://github.com/philferriere/cocoapi. You must have the Visual C++ 2015 build tools on your path (see the repo for additional details)
最后,作者展示了几个使用了本框架的工程,这里不再引用。
『计算机视觉』Mask-RCNN_项目文档翻译的更多相关文章
- 『计算机视觉』经典RCNN_其二:Faster-RCNN
项目源码 一.Faster-RCNN简介 『cs231n』Faster_RCNN 『计算机视觉』Faster-RCNN学习_其一:目标检测及RCNN谱系 一篇讲的非常明白的文章:一文读懂Faster ...
- 『计算机视觉』经典RCNN_其一:从RCNN到Faster-RCNN
RCNN介绍 目标检测-RCNN系列 一文读懂Faster RCNN 一.目标检测 1.两个任务 目标检测可以拆分成两个任务:识别和定位 图像识别(classification)输入:图片输出:物体的 ...
- 『计算机视觉』Mask-RCNN
一.Mask-RCNN流程 Mask R-CNN是一个实例分割(Instance segmentation)算法,通过增加不同的分支,可以完成目标分类.目标检测.语义分割.实例分割.人体姿势识别等多种 ...
- 『计算机视觉』Mask-RCNN_推断网络其六:Mask生成
一.Mask生成概览 上一节的末尾,我们已经获取了待检测图片的分类回归信息,我们将回归信息(即待检测目标的边框信息)单独提取出来,结合金字塔特征mrcnn_feature_maps,进行Mask生成工 ...
- 『计算机视觉』Mask-RCNN_从服装关键点检测看KeyPoints分支
下图Github地址:Mask_RCNN Mask_RCNN_KeyPoints『计算机视觉』Mask-RCNN_论文学习『计算机视觉』Mask-RCNN_项目文档翻译『计算机视觉』Mas ...
- 『计算机视觉』Mask-RCNN_训练网络其三:训练Model
Github地址:Mask_RCNN 『计算机视觉』Mask-RCNN_论文学习 『计算机视觉』Mask-RCNN_项目文档翻译 『计算机视觉』Mask-RCNN_推断网络其一:总览 『计算机视觉』M ...
- 『计算机视觉』Mask-RCNN_训练网络其二:train网络结构&损失函数
Github地址:Mask_RCNN 『计算机视觉』Mask-RCNN_论文学习 『计算机视觉』Mask-RCNN_项目文档翻译 『计算机视觉』Mask-RCNN_推断网络其一:总览 『计算机视觉』M ...
- 『计算机视觉』Mask-RCNN_训练网络其一:数据集与Dataset类
Github地址:Mask_RCNN 『计算机视觉』Mask-RCNN_论文学习 『计算机视觉』Mask-RCNN_项目文档翻译 『计算机视觉』Mask-RCNN_推断网络其一:总览 『计算机视觉』M ...
- 『计算机视觉』Mask-RCNN_锚框生成
Github地址:Mask_RCNN 『计算机视觉』Mask-RCNN_论文学习 『计算机视觉』Mask-RCNN_项目文档翻译 『计算机视觉』Mask-RCNN_推断网络其一:总览 『计算机视觉』M ...
- 『计算机视觉』FPN:feature pyramid networks for object detection
对用卷积神经网络进行目标检测方法的一种改进,通过提取多尺度的特征信息进行融合,进而提高目标检测的精度,特别是在小物体检测上的精度.FPN是ResNet或DenseNet等通用特征提取网络的附加组件,可 ...
随机推荐
- iis6-0 cve-2017-7269 批量验证脚本
代码地址 import subprocess f = open('ips.txt', 'r') flines = f.readlines() vulnsrvs = 0 i = 1 for line i ...
- P2257 YY的GCD(莫比乌斯反演)
第一次做莫比乌斯反演,推式子真是快乐的很啊(棒读) 前置 若函数\(F(n)\)和\(f(d)\)存在以下关系 \[ F(n)=\sum_{n|d}f(d) \] 则可以推出 \[ f(n)=\sum ...
- 题解——洛谷P2781 传教(线段树)
可以说是数据结构学傻了的典型案例了 昨天跳到这题上 然后思考了一下 噫!好!线段树裸题 然后打完板子,发现\( n \le 10^9 \) 显然线段树直接做不太行 然后这题又只有普及的难度 然后我就 ...
- Hierarchical Question-Image Co-Attention for Visual Question Answering
Hierarchical Question-Image Co-Attention for Visual Question Answering NIPS 2016 Paper: https://arxi ...
- BZOJ 4771 七彩树(可持久化线段树合并)
题意 https://www.lydsy.com/JudgeOnline/problem.php?id=4771 思路 和 HDU 3333 其实有点像,不过是把序列的问题放在了树上,多维护一个深度即 ...
- VirtuablBox 出错: VERR_SUPLIB_OWNER_NOT_ROOT 解决方法
刚刚把 VirtualBox 升级, 从 3.2 到 4.0.4 后,虚拟机上的系统无法运行, 提示: VERR_SUPLIB_OWNER_NOT_ROOT 查了一下,发现是因为 /opt 的 own ...
- Jenkins参数化构建(三)之 Jenkins从文件中读取运行参数
安装Extended Choice Parameter插件 选择‘参数化构建过程’ maven command line中进行引用 clean test -DsuiteXmlFile=src/main ...
- 【五】php 面向对象
面向对象 概念:按类进行分类,类是表示彼此之间可能互不相同,但是具有一些共同点的对象集合 多态性:不同的类对同一操作可以有不同的行为 继承:允许我们使用子类在类之间创建层次关系 类 关键字:class ...
- 一:requests爬虫基础
一,什么是爬虫? 描述: 本质是一个自动化程序,一个模拟浏览器向某一个服务器发送请求获取响应资源的过程. 爬虫的基本流程 robots.txt协议 编写一个robots.txt的协议文件来约束爬虫程序 ...
- module.exports小程序模块化,require
小程序模块化 可以将一些公共的代码抽离成为一个单独的 js 文件,作为一个模块.模块只有通过 module.exports 或者 exports 才能对外暴露接口. tips:exports 是 mo ...