Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
26a86017
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看板
未验证
提交
26a86017
编写于
4月 22, 2022
作者:
W
wangguanzhong
提交者:
GitHub
4月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add assign_on_cpu on postprocess (#5625)
* add assign_on_cpu on postprocess * add gpu check
上级
c7c59112
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
4 deletion
+15
-4
ppdet/modeling/post_process.py
ppdet/modeling/post_process.py
+11
-2
ppdet/modeling/proposal_generator/target_layer.py
ppdet/modeling/proposal_generator/target_layer.py
+4
-2
未找到文件。
ppdet/modeling/post_process.py
浏览文件 @
26a86017
...
...
@@ -179,7 +179,7 @@ class BBoxPostProcess(object):
@
register
class
MaskPostProcess
(
object
):
__shared__
=
[
'export_onnx'
]
__shared__
=
[
'export_onnx'
,
'assign_on_cpu'
]
"""
refer to:
https://github.com/facebookresearch/detectron2/layers/mask_ops.py
...
...
@@ -187,10 +187,15 @@ class MaskPostProcess(object):
Get Mask output according to the output from model
"""
def
__init__
(
self
,
binary_thresh
=
0.5
,
export_onnx
=
False
):
def
__init__
(
self
,
binary_thresh
=
0.5
,
export_onnx
=
False
,
assign_on_cpu
=
False
):
super
(
MaskPostProcess
,
self
).
__init__
()
self
.
binary_thresh
=
binary_thresh
self
.
export_onnx
=
export_onnx
self
.
assign_on_cpu
=
assign_on_cpu
and
paddle
.
device
.
is_compiled_with_cuda
(
)
def
paste_mask
(
self
,
masks
,
boxes
,
im_h
,
im_w
):
"""
...
...
@@ -207,6 +212,8 @@ class MaskPostProcess(object):
img_x
=
(
img_x
-
x0
)
/
(
x1
-
x0
)
*
2
-
1
# img_x, img_y have shapes (N, w), (N, h)
if
self
.
assign_on_cpu
:
paddle
.
set_device
(
'cpu'
)
gx
=
img_x
[:,
None
,
:].
expand
(
[
N
,
paddle
.
shape
(
img_y
)[
1
],
paddle
.
shape
(
img_x
)[
1
]])
gy
=
img_y
[:,
:,
None
].
expand
(
...
...
@@ -261,6 +268,8 @@ class MaskPostProcess(object):
pred_result
[
id_start
:
id_start
+
bbox_num
[
i
],
:
im_h
,
:
im_w
]
=
pred_mask
id_start
+=
bbox_num
[
i
]
if
self
.
assign_on_cpu
:
paddle
.
set_device
(
'gpu'
)
return
pred_result
...
...
ppdet/modeling/proposal_generator/target_layer.py
浏览文件 @
26a86017
...
...
@@ -68,7 +68,8 @@ class RPNTargetAssign(object):
self
.
negative_overlap
=
negative_overlap
self
.
ignore_thresh
=
ignore_thresh
self
.
use_random
=
use_random
self
.
assign_on_cpu
=
assign_on_cpu
self
.
assign_on_cpu
=
assign_on_cpu
and
paddle
.
device
.
is_compiled_with_cuda
(
)
def
__call__
(
self
,
inputs
,
anchors
):
"""
...
...
@@ -149,7 +150,8 @@ class BBoxAssigner(object):
self
.
use_random
=
use_random
self
.
cascade_iou
=
cascade_iou
self
.
num_classes
=
num_classes
self
.
assign_on_cpu
=
assign_on_cpu
self
.
assign_on_cpu
=
assign_on_cpu
and
paddle
.
device
.
is_compiled_with_cuda
(
)
def
__call__
(
self
,
rpn_rois
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录