Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
6e79d01b
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e79d01b
编写于
2月 12, 2018
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merge prior_box and multi_box
上级
8ea2288e
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
189 addition
and
341 deletion
+189
-341
python/paddle/v2/fluid/layers/detection.py
python/paddle/v2/fluid/layers/detection.py
+179
-307
python/paddle/v2/fluid/tests/test_detection.py
python/paddle/v2/fluid/tests/test_detection.py
+10
-34
未找到文件。
python/paddle/v2/fluid/layers/detection.py
浏览文件 @
6e79d01b
此差异已折叠。
点击以展开。
python/paddle/v2/fluid/tests/test_detection.py
浏览文件 @
6e79d01b
...
...
@@ -109,16 +109,19 @@ class TestDetection(unittest.TestCase):
print
(
str
(
program
))
class
Test
PriorBox
(
unittest
.
TestCase
):
def
test_
prior_box
(
self
):
class
Test
MultiBoxHead
(
unittest
.
TestCase
):
def
test_
multi_box_head
(
self
):
data_shape
=
[
3
,
224
,
224
]
box
,
var
=
self
.
prior_box
_output
(
data_shape
)
mbox_locs
,
mbox_confs
,
box
,
var
=
self
.
multi_box_head
_output
(
data_shape
)
assert
len
(
box
.
shape
)
==
2
assert
box
.
shape
==
var
.
shape
assert
box
.
shape
[
1
]
==
4
def
prior_box_output
(
self
,
data_shape
):
for
loc
,
conf
in
zip
(
mbox_locs
,
mbox_confs
):
assert
loc
.
shape
[
1
:
3
]
==
conf
.
shape
[
1
:
3
]
def
multi_box_head_output
(
self
,
data_shape
):
images
=
fluid
.
layers
.
data
(
name
=
'pixel'
,
shape
=
data_shape
,
dtype
=
'float32'
)
conv1
=
fluid
.
layers
.
conv2d
(
images
,
3
,
3
,
2
)
...
...
@@ -127,46 +130,19 @@ class TestPriorBox(unittest.TestCase):
conv4
=
fluid
.
layers
.
conv2d
(
conv3
,
3
,
3
,
2
)
conv5
=
fluid
.
layers
.
conv2d
(
conv4
,
3
,
3
,
2
)
box
,
var
=
layers
.
prior_box
(
mbox_locs
,
mbox_confs
,
box
,
var
=
layers
.
multi_box_head
(
inputs
=
[
conv1
,
conv2
,
conv3
,
conv4
,
conv5
,
conv5
],
image
=
images
,
num_classes
=
21
,
min_ratio
=
20
,
max_ratio
=
90
,
# steps=[8, 16, 32, 64, 100, 300],
aspect_ratios
=
[[
2.
],
[
2.
,
3.
],
[
2.
,
3.
],
[
2.
,
3.
],
[
2.
],
[
2.
]],
base_size
=
300
,
offset
=
0.5
,
flip
=
True
,
clip
=
True
)
return
box
,
var
class
TestMultiBoxHead
(
unittest
.
TestCase
):
def
test_prior_box
(
self
):
data_shape
=
[
3
,
224
,
224
]
mbox_locs
,
mbox_confs
=
self
.
multi_box_output
(
data_shape
)
for
loc
,
conf
in
zip
(
mbox_locs
,
mbox_confs
):
assert
loc
.
shape
[
1
:
3
]
==
conf
.
shape
[
1
:
3
]
def
multi_box_output
(
self
,
data_shape
):
images
=
fluid
.
layers
.
data
(
name
=
'pixel'
,
shape
=
data_shape
,
dtype
=
'float32'
)
conv1
=
fluid
.
layers
.
conv2d
(
images
,
3
,
3
,
2
)
conv2
=
fluid
.
layers
.
conv2d
(
conv1
,
3
,
3
,
2
)
conv3
=
fluid
.
layers
.
conv2d
(
conv2
,
3
,
3
,
2
)
conv4
=
fluid
.
layers
.
conv2d
(
conv3
,
3
,
3
,
2
)
conv5
=
fluid
.
layers
.
conv2d
(
conv4
,
3
,
3
,
2
)
mbox_locs
,
mbox_confs
=
detection
.
multi_box_head
(
inputs
=
[
conv1
,
conv2
,
conv3
,
conv4
,
conv5
,
conv5
],
num_classes
=
21
,
min_ratio
=
20
,
max_ratio
=
90
,
aspect_ratios
=
[[
2.
],
[
2.
,
3.
],
[
2.
,
3.
],
[
2.
,
3.
],
[
2.
],
[
2.
]],
base_size
=
300
,
flip
=
True
)
return
mbox_locs
,
mbox_confs
return
mbox_locs
,
mbox_confs
,
box
,
var
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录