Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
43b410b7
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看板
未验证
提交
43b410b7
编写于
4月 08, 2022
作者:
W
wangxinxin08
提交者:
GitHub
4月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add nms trt (#5603)
* add nms trt support * add check version code * fix bugs
上级
71424eb4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
3 deletion
+20
-3
deploy/python/infer.py
deploy/python/infer.py
+1
-1
ppdet/modeling/heads/ppyoloe_head.py
ppdet/modeling/heads/ppyoloe_head.py
+3
-0
ppdet/modeling/layers.py
ppdet/modeling/layers.py
+16
-2
未找到文件。
deploy/python/infer.py
浏览文件 @
43b410b7
...
@@ -653,7 +653,7 @@ def load_predictor(model_dir,
...
@@ -653,7 +653,7 @@ def load_predictor(model_dir,
}
}
if
run_mode
in
precision_map
.
keys
():
if
run_mode
in
precision_map
.
keys
():
config
.
enable_tensorrt_engine
(
config
.
enable_tensorrt_engine
(
workspace_size
=
1
<<
25
,
workspace_size
=
(
1
<<
25
)
*
batch_size
,
max_batch_size
=
batch_size
,
max_batch_size
=
batch_size
,
min_subgraph_size
=
min_subgraph_size
,
min_subgraph_size
=
min_subgraph_size
,
precision_mode
=
precision_map
[
run_mode
],
precision_mode
=
precision_map
[
run_mode
],
...
...
ppdet/modeling/heads/ppyoloe_head.py
浏览文件 @
43b410b7
...
@@ -23,6 +23,7 @@ from ..initializer import bias_init_with_prob, constant_, normal_
...
@@ -23,6 +23,7 @@ from ..initializer import bias_init_with_prob, constant_, normal_
from
..assigners.utils
import
generate_anchors_for_grid_cell
from
..assigners.utils
import
generate_anchors_for_grid_cell
from
ppdet.modeling.backbones.cspresnet
import
ConvBNLayer
from
ppdet.modeling.backbones.cspresnet
import
ConvBNLayer
from
ppdet.modeling.ops
import
get_static_shape
,
paddle_distributed_is_initialized
,
get_act_fn
from
ppdet.modeling.ops
import
get_static_shape
,
paddle_distributed_is_initialized
,
get_act_fn
from
ppdet.modeling.layers
import
MultiClassNMS
__all__
=
[
'PPYOLOEHead'
]
__all__
=
[
'PPYOLOEHead'
]
...
@@ -86,6 +87,8 @@ class PPYOLOEHead(nn.Layer):
...
@@ -86,6 +87,8 @@ class PPYOLOEHead(nn.Layer):
self
.
static_assigner
=
static_assigner
self
.
static_assigner
=
static_assigner
self
.
assigner
=
assigner
self
.
assigner
=
assigner
self
.
nms
=
nms
self
.
nms
=
nms
if
isinstance
(
self
.
nms
,
MultiClassNMS
)
and
trt
:
self
.
nms
.
trt
=
trt
self
.
exclude_nms
=
exclude_nms
self
.
exclude_nms
=
exclude_nms
# stem
# stem
self
.
stem_cls
=
nn
.
LayerList
()
self
.
stem_cls
=
nn
.
LayerList
()
...
...
ppdet/modeling/layers.py
浏览文件 @
43b410b7
...
@@ -440,7 +440,8 @@ class MultiClassNMS(object):
...
@@ -440,7 +440,8 @@ class MultiClassNMS(object):
normalized
=
True
,
normalized
=
True
,
nms_eta
=
1.0
,
nms_eta
=
1.0
,
return_index
=
False
,
return_index
=
False
,
return_rois_num
=
True
):
return_rois_num
=
True
,
trt
=
False
):
super
(
MultiClassNMS
,
self
).
__init__
()
super
(
MultiClassNMS
,
self
).
__init__
()
self
.
score_threshold
=
score_threshold
self
.
score_threshold
=
score_threshold
self
.
nms_top_k
=
nms_top_k
self
.
nms_top_k
=
nms_top_k
...
@@ -450,6 +451,7 @@ class MultiClassNMS(object):
...
@@ -450,6 +451,7 @@ class MultiClassNMS(object):
self
.
nms_eta
=
nms_eta
self
.
nms_eta
=
nms_eta
self
.
return_index
=
return_index
self
.
return_index
=
return_index
self
.
return_rois_num
=
return_rois_num
self
.
return_rois_num
=
return_rois_num
self
.
trt
=
trt
def
__call__
(
self
,
bboxes
,
score
,
background_label
=-
1
):
def
__call__
(
self
,
bboxes
,
score
,
background_label
=-
1
):
"""
"""
...
@@ -471,7 +473,19 @@ class MultiClassNMS(object):
...
@@ -471,7 +473,19 @@ class MultiClassNMS(object):
kwargs
.
update
({
'rois_num'
:
bbox_num
})
kwargs
.
update
({
'rois_num'
:
bbox_num
})
if
background_label
>
-
1
:
if
background_label
>
-
1
:
kwargs
.
update
({
'background_label'
:
background_label
})
kwargs
.
update
({
'background_label'
:
background_label
})
return
ops
.
multiclass_nms
(
bboxes
,
score
,
**
kwargs
)
kwargs
.
pop
(
'trt'
)
# TODO(wangxinxin08): paddle version should be develop or 2.3 and above to run nms on tensorrt
if
self
.
trt
and
(
int
(
paddle
.
version
.
major
)
==
0
or
(
int
(
paddle
.
version
.
major
)
>=
2
and
int
(
paddle
.
version
.
minor
)
>=
3
)):
# TODO(wangxinxin08): tricky switch to run nms on tensorrt
kwargs
.
update
({
'nms_eta'
:
1.1
})
bbox
,
bbox_num
,
_
=
ops
.
multiclass_nms
(
bboxes
,
score
,
**
kwargs
)
mask
=
paddle
.
slice
(
bbox
,
[
-
1
],
[
0
],
[
1
])
!=
-
1
bbox
=
paddle
.
masked_select
(
bbox
,
mask
).
reshape
((
-
1
,
6
))
return
bbox
,
bbox_num
,
None
else
:
return
ops
.
multiclass_nms
(
bboxes
,
score
,
**
kwargs
)
@
register
@
register
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录