『计算机视觉』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等通用特征提取网络的附加组件,可 ...
随机推荐
- win32汇编(ASM)学习资源
网站 AoGo汇编小站(MASMPlus作者) Win32Asm教程在线版 Win32Asm教程博客园文件备份版 Masm32补充教程系列 Win32 ASM Tutorial Resource Ki ...
- 【安装】Redis4.0.10在Linux环境搭建
1.下载Redis后上传到指定目录 2.解压 tar -zxvf redis-4.0.10.tar.gz 3.进入加压后的目录并编译 cd redis-4.0.10 make 4.进入src目录安装 ...
- 记一次oracle创建一个新数据库,并导入正式环境数据库备份的dmp包过程
背景:正式环境oracle数据库定时用exp备份一个dmp包,现在打算在一台机器上创建一个新数据库,并导入这个dmp包. 1.创建数据库 开始 -> 所有程序 -> Oracle -> ...
- NOI 2011 阿狸的打字机(AC自动机+主席树)
题意 https://loj.ac/problem/2444 思路 多串匹配,考虑 \(\text{AC}\) 自动机.模拟打字的过程,先建出一棵 \(\text{Trie}\) 树,把它变成自动机 ...
- BZOJ 4399 魔法少女LJJ(线段树合并)
题意 https://www.lydsy.com/JudgeOnline/problem.php?id=4399 思路 码农题,需要一定代码功底.方法很暴力,先将权值离散,表示在线段树里储存的位置,每 ...
- final、finally、finalize的用法
final: 1.被final修饰的类,就意味着不能再派生出新的子类,不能作为父类而被子类继承 2.将变量或方法声明为final,可以保证他们在使用的过程中不被修改. 3.被final声明的方法也同样 ...
- MySQL获取指定长度的字符串的函数left(s,n)和right(s,n)
1.LEFT(s,n)函数返回字符串s开始的最左边n个字符. eg: select left(‘abcde12345‘,5); ======>‘abcde‘ 2.RIGHT(s,n)函数返回 ...
- 增强 用文本增强修改SAP标准屏幕中的字段名称 属于元素的文本增强
如果想要改变标准屏幕中的字段名称,如把物料主数据基本数据元素的名字改为我们想要的名字 . 1.首先,事务MM03进入物料主数据的基本数据2视图中,将鼠标光标放在需要更改的字段“页格式”上,然后按F1键 ...
- ngui项目花屏问题
项目用的ngui 最近在金立手机上遇到一个问题就是 启动的时候会花一下屏幕 一闪而过 由于ngui默认camera使用的是clear depth 所以按照网上的办法修改 color 跟skybo ...
- git 修改文件夹名字后如何提交
将文件夹名字从 v1.0.1 修改为 v1.0.2 git add --ignore-removal "v1.0.2/xsxsx"