Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
3cf01b5d
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3cf01b5d
编写于
8月 16, 2017
作者:
G
guosheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine ROIPoolLayer
上级
c07cbf7d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
82 addition
and
12 deletion
+82
-12
doc/api/v2/config/layer.rst
doc/api/v2/config/layer.rst
+5
-0
paddle/gserver/layers/ROIPoolLayer.cpp
paddle/gserver/layers/ROIPoolLayer.cpp
+7
-10
paddle/gserver/layers/ROIPoolLayer.h
paddle/gserver/layers/ROIPoolLayer.h
+1
-0
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+9
-1
python/paddle/trainer_config_helpers/tests/configs/file_list.sh
.../paddle/trainer_config_helpers/tests/configs/file_list.sh
+1
-1
python/paddle/trainer_config_helpers/tests/configs/protostr/test_roi_pool_layer.protostr
...lpers/tests/configs/protostr/test_roi_pool_layer.protostr
+45
-0
python/paddle/trainer_config_helpers/tests/configs/test_roi_pool_layer.py
...ainer_config_helpers/tests/configs/test_roi_pool_layer.py
+14
-0
未找到文件。
doc/api/v2/config/layer.rst
浏览文件 @
3cf01b5d
...
...
@@ -82,6 +82,11 @@ maxout
.. autoclass:: paddle.v2.layer.maxout
:noindex:
roi_pool
--------
.. autoclass:: paddle.v2.layer.roi_pool
:noindex:
Norm Layer
==========
...
...
paddle/gserver/layers/ROIPoolLayer.cpp
浏览文件 @
3cf01b5d
...
...
@@ -48,7 +48,7 @@ void ROIPoolLayer::forward(PassType passType) {
resetOutput
(
numROIs
,
channels_
*
pooledHeight_
*
pooledWidth_
);
MatrixPtr
outputValue
=
getOutputValue
();
if
(
useGpu_
)
{
if
(
useGpu_
)
{
// TODO(guosheng): implement on GPU later
MatrixPtr
dataCpuBuffer
;
Matrix
::
resizeOrCreate
(
dataCpuBuffer
,
dataValue
->
getHeight
(),
...
...
@@ -90,9 +90,6 @@ void ROIPoolLayer::forward(PassType passType) {
false
);
real
*
argmaxData
=
maxIdxs_
->
getData
();
size_t
uZero
=
0
;
size_t
uOne
=
1
;
for
(
size_t
n
=
0
;
n
<
numROIs
;
++
n
)
{
size_t
roiBatchIdx
=
bottomROIs
[
0
];
size_t
roiStartW
=
round
(
bottomROIs
[
1
]
*
spatialScale_
);
...
...
@@ -101,8 +98,8 @@ void ROIPoolLayer::forward(PassType passType) {
size_t
roiEndH
=
round
(
bottomROIs
[
4
]
*
spatialScale_
);
CHECK_GE
(
roiBatchIdx
,
0
);
CHECK_LT
(
roiBatchIdx
,
batchSize
);
size_t
roiHeight
=
std
::
max
(
roiEndH
-
roiStartH
+
1
,
uOne
);
size_t
roiWidth
=
std
::
max
(
roiEndW
-
roiStartW
+
1
,
uOne
);
size_t
roiHeight
=
std
::
max
(
roiEndH
-
roiStartH
+
1
,
1UL
);
size_t
roiWidth
=
std
::
max
(
roiEndW
-
roiStartW
+
1
,
1UL
);
real
binSizeH
=
static_cast
<
real
>
(
roiHeight
)
/
static_cast
<
real
>
(
pooledHeight_
);
real
binSizeW
=
...
...
@@ -115,10 +112,10 @@ void ROIPoolLayer::forward(PassType passType) {
size_t
wstart
=
static_cast
<
size_t
>
(
std
::
floor
(
pw
*
binSizeW
));
size_t
hend
=
static_cast
<
size_t
>
(
std
::
ceil
((
ph
+
1
)
*
binSizeH
));
size_t
wend
=
static_cast
<
size_t
>
(
std
::
ceil
((
pw
+
1
)
*
binSizeW
));
hstart
=
std
::
min
(
std
::
max
(
hstart
+
roiStartH
,
uZero
),
height_
);
wstart
=
std
::
min
(
std
::
max
(
wstart
+
roiStartW
,
uZero
),
width_
);
hend
=
std
::
min
(
std
::
max
(
hend
+
roiStartH
,
uZero
),
height_
);
wend
=
std
::
min
(
std
::
max
(
wend
+
roiStartW
,
uZero
),
width_
);
hstart
=
std
::
min
(
std
::
max
(
hstart
+
roiStartH
,
0UL
),
height_
);
wstart
=
std
::
min
(
std
::
max
(
wstart
+
roiStartW
,
0UL
),
width_
);
hend
=
std
::
min
(
std
::
max
(
hend
+
roiStartH
,
0UL
),
height_
);
wend
=
std
::
min
(
std
::
max
(
wend
+
roiStartW
,
0UL
),
width_
);
bool
isEmpty
=
(
hend
<=
hstart
)
||
(
wend
<=
wstart
);
size_t
poolIndex
=
ph
*
pooledWidth_
+
pw
;
...
...
paddle/gserver/layers/ROIPoolLayer.h
浏览文件 @
3cf01b5d
...
...
@@ -29,6 +29,7 @@ namespace paddle {
* Reference:
* Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun.
* Faster R-CNN: Towards Real-Time Object Detection with Region Proposal
* Networks
*/
class
ROIPoolLayer
:
public
Layer
{
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
3cf01b5d
...
...
@@ -1257,6 +1257,7 @@ def roi_pool_layer(input,
pooled_width
,
pooled_height
,
spatial_scale
,
num_channels
=
None
,
name
=
None
):
"""
A layer used by Fast R-CNN to extract feature maps of ROIs from the last
...
...
@@ -1274,8 +1275,14 @@ def roi_pool_layer(input,
:type pooled_height: int
:param spatial_scale: The spatial scale between the image and feature map.
:type spatial_scale: float
:param num_channels: number of input channel.
:type num_channels: int
:return: LayerOutput
"""
if
num_channels
is
None
:
assert
input
.
num_filters
is
not
None
num_channels
=
input
.
num_filters
size
=
num_channels
*
pooled_width
*
pooled_height
Layer
(
name
=
name
,
type
=
LayerType
.
ROI_POOL_LAYER
,
...
...
@@ -1283,7 +1290,8 @@ def roi_pool_layer(input,
pooled_width
=
pooled_width
,
pooled_height
=
pooled_height
,
spatial_scale
=
spatial_scale
)
return
LayerOutput
(
name
,
LayerType
.
ROI_POOL_LAYER
,
parents
=
[
input
,
rois
])
return
LayerOutput
(
name
,
LayerType
.
ROI_POOL_LAYER
,
parents
=
[
input
,
rois
],
size
=
size
)
@
wrap_name_default
(
"cross_channel_norm"
)
...
...
python/paddle/trainer_config_helpers/tests/configs/file_list.sh
浏览文件 @
3cf01b5d
...
...
@@ -8,6 +8,6 @@ test_spp_layer test_bilinear_interp test_maxout test_bi_grumemory math_ops
test_seq_concat_reshape test_pad test_smooth_l1 test_multiplex_layer
test_prelu_layer test_row_conv test_detection_output_layer test_multibox_loss_layer
test_recursive_topology test_gated_unit_layer test_clip_layer test_row_l2_norm_layer
test_kmax_seq_socre_layer test_seq_select_layers
)
test_kmax_seq_socre_layer test_seq_select_layers
test_roi_pool_layer
)
export
whole_configs
=(
test_split_datasource
)
python/paddle/trainer_config_helpers/tests/configs/protostr/test_roi_pool_layer.protostr
0 → 100644
浏览文件 @
3cf01b5d
type: "nn"
layers {
name: "data"
type: "data"
size: 588
active_type: ""
height: 14
width: 14
}
layers {
name: "rois"
type: "data"
size: 10
active_type: ""
}
layers {
name: "__roi_pool_0__"
type: "roi_pool"
active_type: ""
inputs {
input_layer_name: "data"
roi_pool_conf {
pooled_width: 7
pooled_height: 7
spatial_scale: 0.0625
}
}
inputs {
input_layer_name: "rois"
}
}
input_layer_names: "data"
input_layer_names: "rois"
output_layer_names: "__roi_pool_0__"
sub_models {
name: "root"
layer_names: "data"
layer_names: "rois"
layer_names: "__roi_pool_0__"
input_layer_names: "data"
input_layer_names: "rois"
output_layer_names: "__roi_pool_0__"
is_recurrent_layer_group: false
}
python/paddle/trainer_config_helpers/tests/configs/test_roi_pool_layer.py
0 → 100644
浏览文件 @
3cf01b5d
from
paddle.trainer_config_helpers
import
*
data
=
data_layer
(
name
=
'data'
,
size
=
3
*
14
*
14
,
height
=
14
,
width
=
14
)
rois
=
data_layer
(
name
=
'rois'
,
size
=
10
)
roi_pool
=
roi_pool_layer
(
input
=
data
,
rois
=
rois
,
pooled_width
=
7
,
pooled_height
=
7
,
spatial_scale
=
1.
/
16
)
outputs
(
roi_pool
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录