1. 程式人生 > >faster-rcnn中新增Mask中的RoiAlign層,使迴歸框更精確( roi_align_layer.cu:240] Check failed: error == cudaSuccess *)

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