faster-rcnn中添加Mask中的RoiAlign层,使回归框更精确( roi_align_layer.cu:240] Check failed: error == cudaSuccess *)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/e01528/article/details/80265118

具体的操作为什么这样做,可参照:

1.Caffe学习之自定义创建新的Layer层

2.如何在caffe中自定义网络层

ROI pooling层

说起ROI Alignment,就要说道faster-rcnn的ROI pooling,

ROIpooling层结构是为了将原图像的rois映射固定大小的feature map上。而此方法有一些缺点,会带来边缘像素的缺失

ROI Pooling层解析

ROI Align的作用

详解 ROI Align 的基本原理和实现细节

如果roi大小为(7,6),而roipooling是分成了(6,6)的部分,(7,6)到(6,6)的转换必然带来了边缘某像素的损失。而roialign利用双线性插值,将roi(7,6)插值扩充到(12,12),此时再做(6,6)的roipooling,会提高精度,充分利用了roi的像素。

用到的文件链接: https://pan.baidu.com/s/1-f98btUdxX5h8bFTKRxLmA 密码: mypk

1.~/py-faster-rcnn/caffe-fast-rcnn/include/caffe/layers 添加roi_align_layer.hpp

2.~/py-faster-rcnn/caffe-fast-rcnn/src/caffe/layers 添加roi_align_layer.cpp roi_align_layer.cu

3.~/py-faster-rcnn/caffe-fast-rcnn/src/caffe/protocaffe.proto添加add for roi align以下的

 
  1. // Message that stores parameters used by ROIPoolingLayer

  2. message ROIPoolingParameter {

  3. // Pad, kernel size, and stride are all given as a single value for equal

  4. // dimensions in height and width or as Y, X pairs.

  5. optional uint32 pooled_h = 1 [default = 0]; // The pooled output height

  6. optional uint32 pooled_w = 2 [default = 0]; // The pooled output width

  7. // Multiplicative spatial scale factor to translate ROI coords from their

  8. // input scale to the scale used when pooling

  9. optional float spatial_scale = 3 [default = 1];

  10.  
  11. // add for roi align

  12. optional float pad_ratio = 4[default = 0];

  13. optional uint32 bi_type = 5 [default = 0];

  14. optional bool is_multi_interpolate = 6 [default = true];

4.返回caffe-fast-rcnn路径下 make clean ,make -j64,make pycaffe

5.修改model文件夹下面的prototxt模型文件,将ROIPooling换成ROIAlign

----------------------------------------      更新与2018年5月16日     --------------------------------------

如果你电脑出现下面这样的问题

roi_align_layer.cu:240] Check failed: error == cudaSuccess (7 vs. 0)  too many resources requested for launch

【解决方法】:

1. 删除 roi_align_layer.cu文件

2. 打开roi_align_layer.hpp文件注释掉需要gpu加速的语句.(如下图)

3. 重新编译 make clean ,make -j64,make pycaffe

注意:如果不注释hpp的那一段,直接删除cu文件,重新编译会报错

--------------------- 本文来自 Snoopy_Dream 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/e01528/article/details/80265118?utm_source=copy

猜你喜欢

转载自blog.csdn.net/a8039974/article/details/82910364