Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
11c1efff
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
11c1efff
编写于
3月 09, 2022
作者:
S
shangliang Xu
提交者:
GitHub
3月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[SSD] add use_fuse_decode to SSDBox (#5336)
上级
7cb9fc59
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
42 addition
and
35 deletion
+42
-35
ppdet/modeling/layers.py
ppdet/modeling/layers.py
+42
-35
未找到文件。
ppdet/modeling/layers.py
浏览文件 @
11c1efff
...
...
@@ -553,9 +553,14 @@ class YOLOBox(object):
@
register
@
serializable
class
SSDBox
(
object
):
def
__init__
(
self
,
is_normalized
=
True
):
def
__init__
(
self
,
is_normalized
=
True
,
prior_box_var
=
[
0.1
,
0.1
,
0.2
,
0.2
],
use_fuse_decode
=
False
):
self
.
is_normalized
=
is_normalized
self
.
norm_delta
=
float
(
not
self
.
is_normalized
)
self
.
prior_box_var
=
prior_box_var
self
.
use_fuse_decode
=
use_fuse_decode
def
__call__
(
self
,
preds
,
...
...
@@ -564,40 +569,42 @@ class SSDBox(object):
scale_factor
,
var_weight
=
None
):
boxes
,
scores
=
preds
outputs
=
[]
for
box
,
score
,
prior_box
in
zip
(
boxes
,
scores
,
prior_boxes
):
pb_w
=
prior_box
[:,
2
]
-
prior_box
[:,
0
]
+
self
.
norm_delta
pb_h
=
prior_box
[:,
3
]
-
prior_box
[:,
1
]
+
self
.
norm_delta
pb_x
=
prior_box
[:,
0
]
+
pb_w
*
0.5
pb_y
=
prior_box
[:,
1
]
+
pb_h
*
0.5
out_x
=
pb_x
+
box
[:,
:,
0
]
*
pb_w
*
0.1
out_y
=
pb_y
+
box
[:,
:,
1
]
*
pb_h
*
0.1
out_w
=
paddle
.
exp
(
box
[:,
:,
2
]
*
0.2
)
*
pb_w
out_h
=
paddle
.
exp
(
box
[:,
:,
3
]
*
0.2
)
*
pb_h
if
self
.
is_normalized
:
h
=
paddle
.
unsqueeze
(
im_shape
[:,
0
]
/
scale_factor
[:,
0
],
axis
=-
1
)
w
=
paddle
.
unsqueeze
(
im_shape
[:,
1
]
/
scale_factor
[:,
1
],
axis
=-
1
)
output
=
paddle
.
stack
(
[(
out_x
-
out_w
/
2.
)
*
w
,
(
out_y
-
out_h
/
2.
)
*
h
,
(
out_x
+
out_w
/
2.
)
*
w
,
(
out_y
+
out_h
/
2.
)
*
h
],
axis
=-
1
)
boxes
=
paddle
.
concat
(
boxes
,
axis
=
1
)
prior_boxes
=
paddle
.
concat
(
prior_boxes
)
if
self
.
use_fuse_decode
:
output_boxes
=
ops
.
box_coder
(
prior_boxes
,
self
.
prior_box_var
,
boxes
,
code_type
=
"decode_center_size"
,
box_normalized
=
self
.
is_normalized
)
else
:
output
=
paddle
.
stack
(
pb_w
=
prior_boxes
[:,
2
]
-
prior_boxes
[:,
0
]
+
self
.
norm_delta
pb_h
=
prior_boxes
[:,
3
]
-
prior_boxes
[:,
1
]
+
self
.
norm_delta
pb_x
=
prior_boxes
[:,
0
]
+
pb_w
*
0.5
pb_y
=
prior_boxes
[:,
1
]
+
pb_h
*
0.5
out_x
=
pb_x
+
boxes
[:,
:,
0
]
*
pb_w
*
self
.
prior_box_var
[
0
]
out_y
=
pb_y
+
boxes
[:,
:,
1
]
*
pb_h
*
self
.
prior_box_var
[
1
]
out_w
=
paddle
.
exp
(
boxes
[:,
:,
2
]
*
self
.
prior_box_var
[
2
])
*
pb_w
out_h
=
paddle
.
exp
(
boxes
[:,
:,
3
]
*
self
.
prior_box_var
[
3
])
*
pb_h
output_boxes
=
paddle
.
stack
(
[
out_x
-
out_w
/
2.
,
out_y
-
out_h
/
2.
,
out_x
+
out_w
/
2.
-
1.
,
out_y
+
out_h
/
2.
-
1
.
out_x
-
out_w
/
2.
,
out_y
-
out_h
/
2.
,
out_x
+
out_w
/
2.
,
out_y
+
out_h
/
2
.
],
axis
=-
1
)
outputs
.
append
(
output
)
boxes
=
paddle
.
concat
(
outputs
,
axis
=
1
)
scores
=
F
.
softmax
(
paddle
.
concat
(
scores
,
axis
=
1
))
scores
=
paddle
.
transpose
(
scores
,
[
0
,
2
,
1
])
if
self
.
is_normalized
:
h
=
(
im_shape
[:,
0
]
/
scale_factor
[:,
0
]).
unsqueeze
(
-
1
)
w
=
(
im_shape
[:,
1
]
/
scale_factor
[:,
1
]).
unsqueeze
(
-
1
)
im_shape
=
paddle
.
stack
([
w
,
h
,
w
,
h
],
axis
=-
1
)
output_boxes
*=
im_shape
else
:
output_boxes
[...,
-
2
:]
-=
1.0
output_scores
=
F
.
softmax
(
paddle
.
concat
(
scores
,
axis
=
1
)).
transpose
([
0
,
2
,
1
])
return
boxes
,
scores
return
output_boxes
,
output_
scores
@
register
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录