Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
df4a27c6
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看板
未验证
提交
df4a27c6
编写于
4月 12, 2022
作者:
H
hong
提交者:
GitHub
4月 12, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change core.ops to _C_ops (#5663)
上级
4bdb7471
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
13 deletion
+14
-13
ppdet/modeling/ops.py
ppdet/modeling/ops.py
+14
-13
未找到文件。
ppdet/modeling/ops.py
浏览文件 @
df4a27c6
...
@@ -17,6 +17,7 @@ import paddle.nn.functional as F
...
@@ -17,6 +17,7 @@ import paddle.nn.functional as F
import
paddle.nn
as
nn
import
paddle.nn
as
nn
from
paddle
import
ParamAttr
from
paddle
import
ParamAttr
from
paddle.regularizer
import
L2Decay
from
paddle.regularizer
import
L2Decay
from
paddle
import
_C_ops
from
paddle.fluid.framework
import
Variable
,
in_dygraph_mode
from
paddle.fluid.framework
import
Variable
,
in_dygraph_mode
from
paddle.fluid
import
core
from
paddle.fluid
import
core
...
@@ -174,7 +175,7 @@ def roi_pool(input,
...
@@ -174,7 +175,7 @@ def roi_pool(input,
pooled_height
,
pooled_width
=
output_size
pooled_height
,
pooled_width
=
output_size
if
in_dygraph_mode
():
if
in_dygraph_mode
():
assert
rois_num
is
not
None
,
"rois_num should not be None in dygraph mode."
assert
rois_num
is
not
None
,
"rois_num should not be None in dygraph mode."
pool_out
,
argmaxes
=
core
.
ops
.
roi_pool
(
pool_out
,
argmaxes
=
_C_
ops
.
roi_pool
(
input
,
rois
,
rois_num
,
"pooled_height"
,
pooled_height
,
input
,
rois
,
rois_num
,
"pooled_height"
,
pooled_height
,
"pooled_width"
,
pooled_width
,
"spatial_scale"
,
spatial_scale
)
"pooled_width"
,
pooled_width
,
"spatial_scale"
,
spatial_scale
)
return
pool_out
,
argmaxes
return
pool_out
,
argmaxes
...
@@ -281,7 +282,7 @@ def roi_align(input,
...
@@ -281,7 +282,7 @@ def roi_align(input,
if
in_dygraph_mode
():
if
in_dygraph_mode
():
assert
rois_num
is
not
None
,
"rois_num should not be None in dygraph mode."
assert
rois_num
is
not
None
,
"rois_num should not be None in dygraph mode."
align_out
=
core
.
ops
.
roi_align
(
align_out
=
_C_
ops
.
roi_align
(
input
,
rois
,
rois_num
,
"pooled_height"
,
pooled_height
,
input
,
rois
,
rois_num
,
"pooled_height"
,
pooled_height
,
"pooled_width"
,
pooled_width
,
"spatial_scale"
,
spatial_scale
,
"pooled_width"
,
pooled_width
,
"spatial_scale"
,
spatial_scale
,
"sampling_ratio"
,
sampling_ratio
,
"aligned"
,
aligned
)
"sampling_ratio"
,
sampling_ratio
,
"aligned"
,
aligned
)
...
@@ -364,7 +365,7 @@ def iou_similarity(x, y, box_normalized=True, name=None):
...
@@ -364,7 +365,7 @@ def iou_similarity(x, y, box_normalized=True, name=None):
"""
"""
if
in_dygraph_mode
():
if
in_dygraph_mode
():
out
=
core
.
ops
.
iou_similarity
(
x
,
y
,
'box_normalized'
,
box_normalized
)
out
=
_C_
ops
.
iou_similarity
(
x
,
y
,
'box_normalized'
,
box_normalized
)
return
out
return
out
else
:
else
:
helper
=
LayerHelper
(
"iou_similarity"
,
**
locals
())
helper
=
LayerHelper
(
"iou_similarity"
,
**
locals
())
...
@@ -460,7 +461,7 @@ def collect_fpn_proposals(multi_rois,
...
@@ -460,7 +461,7 @@ def collect_fpn_proposals(multi_rois,
if
in_dygraph_mode
():
if
in_dygraph_mode
():
assert
rois_num_per_level
is
not
None
,
"rois_num_per_level should not be None in dygraph mode."
assert
rois_num_per_level
is
not
None
,
"rois_num_per_level should not be None in dygraph mode."
attrs
=
(
'post_nms_topN'
,
post_nms_top_n
)
attrs
=
(
'post_nms_topN'
,
post_nms_top_n
)
output_rois
,
rois_num
=
core
.
ops
.
collect_fpn_proposals
(
output_rois
,
rois_num
=
_C_
ops
.
collect_fpn_proposals
(
input_rois
,
input_scores
,
rois_num_per_level
,
*
attrs
)
input_rois
,
input_scores
,
rois_num_per_level
,
*
attrs
)
return
output_rois
,
rois_num
return
output_rois
,
rois_num
...
@@ -575,7 +576,7 @@ def distribute_fpn_proposals(fpn_rois,
...
@@ -575,7 +576,7 @@ def distribute_fpn_proposals(fpn_rois,
attrs
=
(
'min_level'
,
min_level
,
'max_level'
,
max_level
,
'refer_level'
,
attrs
=
(
'min_level'
,
min_level
,
'max_level'
,
max_level
,
'refer_level'
,
refer_level
,
'refer_scale'
,
refer_scale
,
'pixel_offset'
,
refer_level
,
'refer_scale'
,
refer_scale
,
'pixel_offset'
,
pixel_offset
)
pixel_offset
)
multi_rois
,
restore_ind
,
rois_num_per_level
=
core
.
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
)
fpn_rois
,
rois_num
,
num_lvl
,
num_lvl
,
*
attrs
)
return
multi_rois
,
restore_ind
,
rois_num_per_level
return
multi_rois
,
restore_ind
,
rois_num_per_level
...
@@ -729,7 +730,7 @@ def yolo_box(
...
@@ -729,7 +730,7 @@ def yolo_box(
attrs
=
(
'anchors'
,
anchors
,
'class_num'
,
class_num
,
'conf_thresh'
,
attrs
=
(
'anchors'
,
anchors
,
'class_num'
,
class_num
,
'conf_thresh'
,
conf_thresh
,
'downsample_ratio'
,
downsample_ratio
,
'clip_bbox'
,
conf_thresh
,
'downsample_ratio'
,
downsample_ratio
,
'clip_bbox'
,
clip_bbox
,
'scale_x_y'
,
scale_x_y
)
clip_bbox
,
'scale_x_y'
,
scale_x_y
)
boxes
,
scores
=
core
.
ops
.
yolo_box
(
x
,
origin_shape
,
*
attrs
)
boxes
,
scores
=
_C_
ops
.
yolo_box
(
x
,
origin_shape
,
*
attrs
)
return
boxes
,
scores
return
boxes
,
scores
else
:
else
:
boxes
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
boxes
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -867,7 +868,7 @@ def prior_box(input,
...
@@ -867,7 +868,7 @@ def prior_box(input,
'min_max_aspect_ratios_order'
,
min_max_aspect_ratios_order
)
'min_max_aspect_ratios_order'
,
min_max_aspect_ratios_order
)
if
cur_max_sizes
is
not
None
:
if
cur_max_sizes
is
not
None
:
attrs
+=
(
'max_sizes'
,
cur_max_sizes
)
attrs
+=
(
'max_sizes'
,
cur_max_sizes
)
box
,
var
=
core
.
ops
.
prior_box
(
input
,
image
,
*
attrs
)
box
,
var
=
_C_
ops
.
prior_box
(
input
,
image
,
*
attrs
)
return
box
,
var
return
box
,
var
else
:
else
:
attrs
=
{
attrs
=
{
...
@@ -1010,7 +1011,7 @@ def multiclass_nms(bboxes,
...
@@ -1010,7 +1011,7 @@ def multiclass_nms(bboxes,
score_threshold
,
'nms_top_k'
,
nms_top_k
,
'nms_threshold'
,
score_threshold
,
'nms_top_k'
,
nms_top_k
,
'nms_threshold'
,
nms_threshold
,
'keep_top_k'
,
keep_top_k
,
'nms_eta'
,
nms_eta
,
nms_threshold
,
'keep_top_k'
,
keep_top_k
,
'nms_eta'
,
nms_eta
,
'normalized'
,
normalized
)
'normalized'
,
normalized
)
output
,
index
,
nms_rois_num
=
core
.
ops
.
multiclass_nms3
(
bboxes
,
scores
,
output
,
index
,
nms_rois_num
=
_C_
ops
.
multiclass_nms3
(
bboxes
,
scores
,
rois_num
,
*
attrs
)
rois_num
,
*
attrs
)
if
not
return_index
:
if
not
return_index
:
index
=
None
index
=
None
...
@@ -1152,7 +1153,7 @@ def matrix_nms(bboxes,
...
@@ -1152,7 +1153,7 @@ def matrix_nms(bboxes,
nms_top_k
,
'gaussian_sigma'
,
gaussian_sigma
,
'use_gaussian'
,
nms_top_k
,
'gaussian_sigma'
,
gaussian_sigma
,
'use_gaussian'
,
use_gaussian
,
'keep_top_k'
,
keep_top_k
,
'normalized'
,
use_gaussian
,
'keep_top_k'
,
keep_top_k
,
'normalized'
,
normalized
)
normalized
)
out
,
index
,
rois_num
=
core
.
ops
.
matrix_nms
(
bboxes
,
scores
,
*
attrs
)
out
,
index
,
rois_num
=
_C_
ops
.
matrix_nms
(
bboxes
,
scores
,
*
attrs
)
if
not
return_index
:
if
not
return_index
:
index
=
None
index
=
None
if
not
return_rois_num
:
if
not
return_rois_num
:
...
@@ -1273,7 +1274,7 @@ def bipartite_match(dist_matrix,
...
@@ -1273,7 +1274,7 @@ def bipartite_match(dist_matrix,
[
'float32'
,
'float64'
],
'bipartite_match'
)
[
'float32'
,
'float64'
],
'bipartite_match'
)
if
in_dygraph_mode
():
if
in_dygraph_mode
():
match_indices
,
match_distance
=
core
.
ops
.
bipartite_match
(
match_indices
,
match_distance
=
_C_
ops
.
bipartite_match
(
dist_matrix
,
"match_type"
,
match_type
,
"dist_threshold"
,
dist_matrix
,
"match_type"
,
match_type
,
"dist_threshold"
,
dist_threshold
)
dist_threshold
)
return
match_indices
,
match_distance
return
match_indices
,
match_distance
...
@@ -1410,12 +1411,12 @@ def box_coder(prior_box,
...
@@ -1410,12 +1411,12 @@ def box_coder(prior_box,
if
in_dygraph_mode
():
if
in_dygraph_mode
():
if
isinstance
(
prior_box_var
,
Variable
):
if
isinstance
(
prior_box_var
,
Variable
):
output_box
=
core
.
ops
.
box_coder
(
output_box
=
_C_
ops
.
box_coder
(
prior_box
,
prior_box_var
,
target_box
,
"code_type"
,
code_type
,
prior_box
,
prior_box_var
,
target_box
,
"code_type"
,
code_type
,
"box_normalized"
,
box_normalized
,
"axis"
,
axis
)
"box_normalized"
,
box_normalized
,
"axis"
,
axis
)
elif
isinstance
(
prior_box_var
,
list
):
elif
isinstance
(
prior_box_var
,
list
):
output_box
=
core
.
ops
.
box_coder
(
output_box
=
_C_
ops
.
box_coder
(
prior_box
,
None
,
target_box
,
"code_type"
,
code_type
,
prior_box
,
None
,
target_box
,
"code_type"
,
code_type
,
"box_normalized"
,
box_normalized
,
"axis"
,
axis
,
"variance"
,
"box_normalized"
,
box_normalized
,
"axis"
,
axis
,
"variance"
,
prior_box_var
)
prior_box_var
)
...
@@ -1538,7 +1539,7 @@ def generate_proposals(scores,
...
@@ -1538,7 +1539,7 @@ def generate_proposals(scores,
attrs
=
(
'pre_nms_topN'
,
pre_nms_top_n
,
'post_nms_topN'
,
post_nms_top_n
,
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
,
'nms_thresh'
,
nms_thresh
,
'min_size'
,
min_size
,
'eta'
,
eta
,
'pixel_offset'
,
pixel_offset
)
'pixel_offset'
,
pixel_offset
)
rpn_rois
,
rpn_roi_probs
,
rpn_rois_num
=
core
.
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
)
scores
,
bbox_deltas
,
im_shape
,
anchors
,
variances
,
*
attrs
)
if
not
return_rois_num
:
if
not
return_rois_num
:
rpn_rois_num
=
None
rpn_rois_num
=
None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录