Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
bbff442e
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bbff442e
编写于
2月 11, 2018
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
follow comments of qingqing
上级
d641d5ac
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
34 deletion
+35
-34
python/paddle/v2/fluid/layers/detection.py
python/paddle/v2/fluid/layers/detection.py
+23
-24
python/paddle/v2/fluid/tests/test_prior_boxes.py
python/paddle/v2/fluid/tests/test_prior_boxes.py
+12
-10
未找到文件。
python/paddle/v2/fluid/layers/detection.py
浏览文件 @
bbff442e
...
@@ -19,30 +19,28 @@ from ..layer_helper import LayerHelper
...
@@ -19,30 +19,28 @@ from ..layer_helper import LayerHelper
from
..framework
import
Variable
from
..framework
import
Variable
from
tensor
import
concat
from
tensor
import
concat
from
ops
import
reshape
from
ops
import
reshape
from
operator
import
mul
import
math
import
math
__all__
=
[
__all__
=
[
'prior_box'
,
]
'prior_box'
,
'prior_boxes'
,
]
def
prior_box
(
inputs
,
image
,
min_ratio
,
def
prior_boxes
(
inputs
,
max_ratio
,
image
,
aspect_ratios
,
min_ratio
,
base_size
,
max_ratio
,
steps
=
None
,
aspect_ratios
,
step_w
=
None
,
base_size
,
step_h
=
None
,
steps
=
None
,
offset
=
0.5
,
step_w
=
None
,
variance
=
[
0.1
,
0.1
,
0.1
,
0.1
],
step_h
=
None
,
flip
=
False
,
offset
=
0.5
,
clip
=
False
,
variance
=
[
0.1
,
0.1
,
0.1
,
0.1
],
min_sizes
=
None
,
flip
=
False
,
max_sizes
=
None
,
clip
=
False
,
name
=
None
):
min_sizes
=
None
,
max_sizes
=
None
,
name
=
None
):
"""
"""
**Prior_boxes**
**Prior_boxes**
...
@@ -140,9 +138,10 @@ def prior_boxes(inputs,
...
@@ -140,9 +138,10 @@ def prior_boxes(inputs,
def
_reshape_with_axis_
(
input
,
axis
=
1
):
def
_reshape_with_axis_
(
input
,
axis
=
1
):
if
not
(
axis
>
0
and
axis
<
len
(
input
.
shape
)):
if
not
(
axis
>
0
and
axis
<
len
(
input
.
shape
)):
raise
ValueError
(
raise
ValueError
(
"The axis should be smaller than the arity of input's shape."
)
"The axis should be smaller than the arity of input and bigger than 0."
)
new_shape
=
[
-
1
,
reduce
(
mul
,
input
.
shape
[
axis
:
len
(
input
.
shape
)],
1
)]
new_shape
=
[
-
1
,
reduce
(
mul
,
input
.
shape
[
axis
:
len
(
input
.
shape
)],
1
)]
out
=
reshape
(
[
input
]
,
shape
=
new_shape
)
out
=
reshape
(
x
=
input
,
shape
=
new_shape
)
return
out
return
out
assert
isinstance
(
inputs
,
list
),
'inputs should be a list.'
assert
isinstance
(
inputs
,
list
),
'inputs should be a list.'
...
...
python/paddle/v2/fluid/tests/
object_detection/
test_prior_boxes.py
→
python/paddle/v2/fluid/tests/test_prior_boxes.py
浏览文件 @
bbff442e
...
@@ -33,7 +33,7 @@ def prior_box_output(data_shape):
...
@@ -33,7 +33,7 @@ def prior_box_output(data_shape):
conv5
=
fluid
.
layers
.
conv2d
(
conv5
=
fluid
.
layers
.
conv2d
(
input
=
conv4
,
num_filters
=
3
,
filter_size
=
3
,
stride
=
2
,
use_cudnn
=
False
)
input
=
conv4
,
num_filters
=
3
,
filter_size
=
3
,
stride
=
2
,
use_cudnn
=
False
)
box
,
var
=
detection
.
prior_box
es
(
box
,
var
=
detection
.
prior_box
(
inputs
=
[
conv1
,
conv2
,
conv3
,
conv4
,
conv5
,
conv5
],
inputs
=
[
conv1
,
conv2
,
conv3
,
conv4
,
conv5
,
conv5
],
image
=
images
,
image
=
images
,
min_ratio
=
20
,
min_ratio
=
20
,
...
@@ -57,20 +57,22 @@ def main(use_cuda):
...
@@ -57,20 +57,22 @@ def main(use_cuda):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
exe
.
run
(
fluid
.
default_startup_program
())
batch
=
[
128
]
batch
=
[
4
]
# batch is not used in the prior_box.
assert
box
.
shape
[
1
]
==
4
assert
var
.
shape
[
1
]
==
4
assert
box
.
shape
==
var
.
shape
assert
len
(
box
.
shape
)
==
2
for
_
in
range
(
1
):
for
_
in
range
(
1
):
x
=
np
.
random
.
random
(
batch
+
data_shape
).
astype
(
"float32"
)
x
=
np
.
random
.
random
(
batch
+
data_shape
).
astype
(
"float32"
)
tensor_x
=
core
.
LoDTensor
()
tensor_x
=
core
.
LoDTensor
()
tensor_x
.
set
(
x
,
place
)
tensor_x
.
set
(
x
,
place
)
box
,
var
=
exe
.
run
(
fluid
.
default_main_program
(),
boxes
,
vars
=
exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{
'pixel'
:
tensor_x
},
feed
=
{
'pixel'
:
tensor_x
},
fetch_list
=
[
box
,
var
])
fetch_list
=
[
box
,
var
])
box_arr
=
np
.
array
(
box
)
assert
vars
.
shape
==
var
.
shape
var_arr
=
np
.
array
(
var
)
assert
boxes
.
shape
==
box
.
shape
assert
box_arr
.
shape
[
1
]
==
4
assert
var_arr
.
shape
[
1
]
==
4
assert
box_arr
.
shape
[
0
]
==
var_arr
.
shape
[
0
]
class
TestFitALine
(
unittest
.
TestCase
):
class
TestFitALine
(
unittest
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录