Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
00149853
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看板
未验证
提交
00149853
编写于
4月 08, 2022
作者:
W
wangxinxin08
提交者:
GitHub
4月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[cherry-pick] add nms trt cp (#5604)
* add nms trt support * add check version code * fix bugs
上级
10b62145
变更
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
浏览文件 @
00149853
...
...
@@ -653,7 +653,7 @@ def load_predictor(model_dir,
}
if
run_mode
in
precision_map
.
keys
():
config
.
enable_tensorrt_engine
(
workspace_size
=
1
<<
25
,
workspace_size
=
(
1
<<
25
)
*
batch_size
,
max_batch_size
=
batch_size
,
min_subgraph_size
=
min_subgraph_size
,
precision_mode
=
precision_map
[
run_mode
],
...
...
ppdet/modeling/heads/ppyoloe_head.py
浏览文件 @
00149853
...
...
@@ -23,6 +23,7 @@ from ..initializer import bias_init_with_prob, constant_, normal_
from
..assigners.utils
import
generate_anchors_for_grid_cell
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.layers
import
MultiClassNMS
__all__
=
[
'PPYOLOEHead'
]
...
...
@@ -86,6 +87,8 @@ class PPYOLOEHead(nn.Layer):
self
.
static_assigner
=
static_assigner
self
.
assigner
=
assigner
self
.
nms
=
nms
if
isinstance
(
self
.
nms
,
MultiClassNMS
)
and
trt
:
self
.
nms
.
trt
=
trt
self
.
exclude_nms
=
exclude_nms
# stem
self
.
stem_cls
=
nn
.
LayerList
()
...
...
ppdet/modeling/layers.py
浏览文件 @
00149853
...
...
@@ -440,7 +440,8 @@ class MultiClassNMS(object):
normalized
=
True
,
nms_eta
=
1.0
,
return_index
=
False
,
return_rois_num
=
True
):
return_rois_num
=
True
,
trt
=
False
):
super
(
MultiClassNMS
,
self
).
__init__
()
self
.
score_threshold
=
score_threshold
self
.
nms_top_k
=
nms_top_k
...
...
@@ -450,6 +451,7 @@ class MultiClassNMS(object):
self
.
nms_eta
=
nms_eta
self
.
return_index
=
return_index
self
.
return_rois_num
=
return_rois_num
self
.
trt
=
trt
def
__call__
(
self
,
bboxes
,
score
,
background_label
=-
1
):
"""
...
...
@@ -471,6 +473,18 @@ class MultiClassNMS(object):
kwargs
.
update
({
'rois_num'
:
bbox_num
})
if
background_label
>
-
1
:
kwargs
.
update
({
'background_label'
:
background_label
})
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
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录