Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
ec77c58e
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看板
未验证
提交
ec77c58e
编写于
9月 09, 2022
作者:
W
wangguanzhong
提交者:
GitHub
9月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[cherry-pick] compat dev & release (#6911)
* compat dev & release * fix ops import
上级
6b62ffcd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
37 deletion
+57
-37
ppdet/modeling/heads/roi_extractor.py
ppdet/modeling/heads/roi_extractor.py
+17
-7
ppdet/modeling/ops.py
ppdet/modeling/ops.py
+13
-9
ppdet/modeling/proposal_generator/proposal_generator.py
ppdet/modeling/proposal_generator/proposal_generator.py
+27
-12
ppdet/utils/check.py
ppdet/utils/check.py
+0
-9
未找到文件。
ppdet/modeling/heads/roi_extractor.py
浏览文件 @
ec77c58e
...
...
@@ -87,13 +87,23 @@ class RoIAlign(object):
offset
=
2
k_min
=
self
.
start_level
+
offset
k_max
=
self
.
end_level
+
offset
rois_dist
,
restore_index
,
rois_num_dist
=
ops
.
distribute_fpn_proposals
(
roi
,
k_min
,
k_max
,
self
.
canconical_level
,
self
.
canonical_size
,
rois_num
=
rois_num
)
if
hasattr
(
paddle
.
vision
.
ops
,
"distribute_fpn_proposals"
):
rois_dist
,
restore_index
,
rois_num_dist
=
paddle
.
vision
.
ops
.
distribute_fpn_proposals
(
roi
,
k_min
,
k_max
,
self
.
canconical_level
,
self
.
canonical_size
,
rois_num
=
rois_num
)
else
:
ops
.
distribute_fpn_proposals
(
roi
,
k_min
,
k_max
,
self
.
canconical_level
,
self
.
canonical_size
,
rois_num
=
rois_num
)
rois_feat_list
=
[]
for
lvl
in
range
(
self
.
start_level
,
self
.
end_level
+
1
):
roi_feat
=
paddle
.
vision
.
ops
.
roi_align
(
...
...
ppdet/modeling/ops.py
浏览文件 @
ec77c58e
...
...
@@ -17,7 +17,10 @@ import paddle.nn.functional as F
import
paddle.nn
as
nn
from
paddle
import
ParamAttr
from
paddle.regularizer
import
L2Decay
from
paddle
import
_C_ops
try
:
import
paddle._legacy_C_ops
as
C_ops
except
:
import
paddle._C_ops
as
C_ops
from
paddle
import
in_dynamic_mode
from
paddle.common_ops_import
import
Variable
,
LayerHelper
,
check_variable_and_dtype
,
check_type
,
check_dtype
...
...
@@ -198,8 +201,9 @@ def distribute_fpn_proposals(fpn_rois,
attrs
=
(
'min_level'
,
min_level
,
'max_level'
,
max_level
,
'refer_level'
,
refer_level
,
'refer_scale'
,
refer_scale
,
'pixel_offset'
,
pixel_offset
)
multi_rois
,
restore_ind
,
rois_num_per_level
=
_
C_ops
.
distribute_fpn_proposals
(
multi_rois
,
restore_ind
,
rois_num_per_level
=
C_ops
.
distribute_fpn_proposals
(
fpn_rois
,
rois_num
,
num_lvl
,
num_lvl
,
*
attrs
)
return
multi_rois
,
restore_ind
,
rois_num_per_level
else
:
...
...
@@ -353,7 +357,7 @@ def prior_box(input,
'min_max_aspect_ratios_order'
,
min_max_aspect_ratios_order
)
if
cur_max_sizes
is
not
None
:
attrs
+=
(
'max_sizes'
,
cur_max_sizes
)
box
,
var
=
_
C_ops
.
prior_box
(
input
,
image
,
*
attrs
)
box
,
var
=
C_ops
.
prior_box
(
input
,
image
,
*
attrs
)
return
box
,
var
else
:
attrs
=
{
...
...
@@ -496,8 +500,8 @@ def multiclass_nms(bboxes,
score_threshold
,
'nms_top_k'
,
nms_top_k
,
'nms_threshold'
,
nms_threshold
,
'keep_top_k'
,
keep_top_k
,
'nms_eta'
,
nms_eta
,
'normalized'
,
normalized
)
output
,
index
,
nms_rois_num
=
_
C_ops
.
multiclass_nms3
(
bboxes
,
scores
,
rois_num
,
*
attrs
)
output
,
index
,
nms_rois_num
=
C_ops
.
multiclass_nms3
(
bboxes
,
scores
,
rois_num
,
*
attrs
)
if
not
return_index
:
index
=
None
return
output
,
nms_rois_num
,
index
...
...
@@ -638,7 +642,7 @@ def matrix_nms(bboxes,
nms_top_k
,
'gaussian_sigma'
,
gaussian_sigma
,
'use_gaussian'
,
use_gaussian
,
'keep_top_k'
,
keep_top_k
,
'normalized'
,
normalized
)
out
,
index
,
rois_num
=
_
C_ops
.
matrix_nms
(
bboxes
,
scores
,
*
attrs
)
out
,
index
,
rois_num
=
C_ops
.
matrix_nms
(
bboxes
,
scores
,
*
attrs
)
if
not
return_index
:
index
=
None
if
not
return_rois_num
:
...
...
@@ -791,12 +795,12 @@ def box_coder(prior_box,
if
in_dynamic_mode
():
if
isinstance
(
prior_box_var
,
Variable
):
output_box
=
_
C_ops
.
box_coder
(
output_box
=
C_ops
.
box_coder
(
prior_box
,
prior_box_var
,
target_box
,
"code_type"
,
code_type
,
"box_normalized"
,
box_normalized
,
"axis"
,
axis
)
elif
isinstance
(
prior_box_var
,
list
):
output_box
=
_
C_ops
.
box_coder
(
output_box
=
C_ops
.
box_coder
(
prior_box
,
None
,
target_box
,
"code_type"
,
code_type
,
"box_normalized"
,
box_normalized
,
"axis"
,
axis
,
"variance"
,
prior_box_var
)
...
...
@@ -919,7 +923,7 @@ def generate_proposals(scores,
attrs
=
(
'pre_nms_topN'
,
pre_nms_top_n
,
'post_nms_topN'
,
post_nms_top_n
,
'nms_thresh'
,
nms_thresh
,
'min_size'
,
min_size
,
'eta'
,
eta
,
'pixel_offset'
,
pixel_offset
)
rpn_rois
,
rpn_roi_probs
,
rpn_rois_num
=
_
C_ops
.
generate_proposals_v2
(
rpn_rois
,
rpn_roi_probs
,
rpn_rois_num
=
C_ops
.
generate_proposals_v2
(
scores
,
bbox_deltas
,
im_shape
,
anchors
,
variances
,
*
attrs
)
if
not
return_rois_num
:
rpn_rois_num
=
None
...
...
ppdet/modeling/proposal_generator/proposal_generator.py
浏览文件 @
ec77c58e
...
...
@@ -62,16 +62,31 @@ class ProposalGenerator(object):
top_n
=
self
.
pre_nms_top_n
if
self
.
topk_after_collect
else
self
.
post_nms_top_n
variances
=
paddle
.
ones_like
(
anchors
)
rpn_rois
,
rpn_rois_prob
,
rpn_rois_num
=
ops
.
generate_proposals
(
scores
,
bbox_deltas
,
im_shape
,
anchors
,
variances
,
pre_nms_top_n
=
self
.
pre_nms_top_n
,
post_nms_top_n
=
top_n
,
nms_thresh
=
self
.
nms_thresh
,
min_size
=
self
.
min_size
,
eta
=
self
.
eta
,
return_rois_num
=
True
)
if
hasattr
(
paddle
.
vision
.
ops
,
"generate_proposals"
):
rpn_rois
,
rpn_rois_prob
,
rpn_rois_num
=
paddle
.
vision
.
ops
.
generate_proposals
(
scores
,
bbox_deltas
,
im_shape
,
anchors
,
variances
,
pre_nms_top_n
=
self
.
pre_nms_top_n
,
post_nms_top_n
=
top_n
,
nms_thresh
=
self
.
nms_thresh
,
min_size
=
self
.
min_size
,
eta
=
self
.
eta
,
return_rois_num
=
True
)
else
:
rpn_rois
,
rpn_rois_prob
,
rpn_rois_num
=
ops
.
generate_proposals
(
scores
,
bbox_deltas
,
im_shape
,
anchors
,
variances
,
pre_nms_top_n
=
self
.
pre_nms_top_n
,
post_nms_top_n
=
top_n
,
nms_thresh
=
self
.
nms_thresh
,
min_size
=
self
.
min_size
,
eta
=
self
.
eta
,
return_rois_num
=
True
)
return
rpn_rois
,
rpn_rois_prob
,
rpn_rois_num
,
self
.
post_nms_top_n
ppdet/utils/check.py
浏览文件 @
ec77c58e
...
...
@@ -101,18 +101,9 @@ def check_version(version='2.2'):
paddle_version
.
rc
]
# Paddledet develop version is only used on Paddle develop
if
version_installed
==
[
'0'
,
'0'
,
'0'
,
'0'
]
and
version
!=
'develop'
:
raise
Exception
(
"PaddlePaddle version {} or higher is required, and develop version is only used for PaddleDetection develop version!"
.
format
(
version
))
if
version_installed
==
[
'0'
,
'0'
,
'0'
,
'0'
]:
return
if
version
==
'develop'
:
raise
Exception
(
"PaddlePaddle develop version is required!"
)
version_split
=
version
.
split
(
'.'
)
length
=
min
(
len
(
version_installed
),
len
(
version_split
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录