Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
6cfe3643
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看板
未验证
提交
6cfe3643
编写于
5月 18, 2021
作者:
G
George Ni
提交者:
GitHub
5月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[MOT] fix for_mot in yolo_fpn (#3039)
* fix for_mot in PPYOLOTinyFPN and PPYOLOPAN * fix yolo_fpn
上级
fa474195
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
39 addition
and
12 deletion
+39
-12
ppdet/modeling/architectures/yolo.py
ppdet/modeling/architectures/yolo.py
+2
-1
ppdet/modeling/necks/yolo_fpn.py
ppdet/modeling/necks/yolo_fpn.py
+37
-11
未找到文件。
ppdet/modeling/architectures/yolo.py
浏览文件 @
6cfe3643
...
@@ -30,7 +30,8 @@ class YOLOv3(BaseArch):
...
@@ -30,7 +30,8 @@ class YOLOv3(BaseArch):
yolo_head (nn.Layer): anchor_head instance
yolo_head (nn.Layer): anchor_head instance
bbox_post_process (object): `BBoxPostProcess` instance
bbox_post_process (object): `BBoxPostProcess` instance
data_format (str): data format, NCHW or NHWC
data_format (str): data format, NCHW or NHWC
for_mot (bool): whether return other features used in tracking model
for_mot (bool): whether return other features for multi-object tracking
models, default False in pure object detection models.
"""
"""
super
(
YOLOv3
,
self
).
__init__
(
data_format
=
data_format
)
super
(
YOLOv3
,
self
).
__init__
(
data_format
=
data_format
)
self
.
backbone
=
backbone
self
.
backbone
=
backbone
...
...
ppdet/modeling/necks/yolo_fpn.py
浏览文件 @
6cfe3643
...
@@ -18,11 +18,9 @@ import paddle.nn.functional as F
...
@@ -18,11 +18,9 @@ import paddle.nn.functional as F
from
paddle
import
ParamAttr
from
paddle
import
ParamAttr
from
ppdet.core.workspace
import
register
,
serializable
from
ppdet.core.workspace
import
register
,
serializable
from
..backbones.darknet
import
ConvBNLayer
from
..backbones.darknet
import
ConvBNLayer
import
numpy
as
np
from
..shape_spec
import
ShapeSpec
from
..shape_spec
import
ShapeSpec
__all__
=
[
'YOLOv3FPN'
,
'PPYOLOFPN'
]
__all__
=
[
'YOLOv3FPN'
,
'PPYOLOFPN'
,
'PPYOLOTinyFPN'
,
'PPYOLOPAN'
]
def
add_coord
(
x
,
data_format
):
def
add_coord
(
x
,
data_format
):
...
@@ -492,8 +490,11 @@ class YOLOv3FPN(nn.Layer):
...
@@ -492,8 +490,11 @@ class YOLOv3FPN(nn.Layer):
assert
len
(
blocks
)
==
self
.
num_blocks
assert
len
(
blocks
)
==
self
.
num_blocks
blocks
=
blocks
[::
-
1
]
blocks
=
blocks
[::
-
1
]
yolo_feats
=
[]
yolo_feats
=
[]
# add embedding features output for multi-object tracking model
if
for_mot
:
if
for_mot
:
emb_feats
=
[]
emb_feats
=
[]
for
i
,
block
in
enumerate
(
blocks
):
for
i
,
block
in
enumerate
(
blocks
):
if
i
>
0
:
if
i
>
0
:
if
self
.
data_format
==
'NCHW'
:
if
self
.
data_format
==
'NCHW'
:
...
@@ -504,7 +505,7 @@ class YOLOv3FPN(nn.Layer):
...
@@ -504,7 +505,7 @@ class YOLOv3FPN(nn.Layer):
yolo_feats
.
append
(
tip
)
yolo_feats
.
append
(
tip
)
if
for_mot
:
if
for_mot
:
# add emb
_feat
s output
# add emb
edding feature
s output
emb_feats
.
append
(
route
)
emb_feats
.
append
(
route
)
if
i
<
self
.
num_blocks
-
1
:
if
i
<
self
.
num_blocks
-
1
:
...
@@ -668,8 +669,11 @@ class PPYOLOFPN(nn.Layer):
...
@@ -668,8 +669,11 @@ class PPYOLOFPN(nn.Layer):
assert
len
(
blocks
)
==
self
.
num_blocks
assert
len
(
blocks
)
==
self
.
num_blocks
blocks
=
blocks
[::
-
1
]
blocks
=
blocks
[::
-
1
]
yolo_feats
=
[]
yolo_feats
=
[]
# add embedding features output for multi-object tracking model
if
for_mot
:
if
for_mot
:
emb_feats
=
[]
emb_feats
=
[]
for
i
,
block
in
enumerate
(
blocks
):
for
i
,
block
in
enumerate
(
blocks
):
if
i
>
0
:
if
i
>
0
:
if
self
.
data_format
==
'NCHW'
:
if
self
.
data_format
==
'NCHW'
:
...
@@ -680,7 +684,7 @@ class PPYOLOFPN(nn.Layer):
...
@@ -680,7 +684,7 @@ class PPYOLOFPN(nn.Layer):
yolo_feats
.
append
(
tip
)
yolo_feats
.
append
(
tip
)
if
for_mot
:
if
for_mot
:
# add emb
_feat
s output
# add emb
edding feature
s output
emb_feats
.
append
(
route
)
emb_feats
.
append
(
route
)
if
i
<
self
.
num_blocks
-
1
:
if
i
<
self
.
num_blocks
-
1
:
...
@@ -780,11 +784,15 @@ class PPYOLOTinyFPN(nn.Layer):
...
@@ -780,11 +784,15 @@ class PPYOLOTinyFPN(nn.Layer):
name
=
name
))
name
=
name
))
self
.
routes
.
append
(
route
)
self
.
routes
.
append
(
route
)
def
forward
(
self
,
blocks
):
def
forward
(
self
,
blocks
,
for_mot
=
False
):
assert
len
(
blocks
)
==
self
.
num_blocks
assert
len
(
blocks
)
==
self
.
num_blocks
blocks
=
blocks
[::
-
1
]
blocks
=
blocks
[::
-
1
]
yolo_feats
=
[]
yolo_feats
=
[]
# add embedding features output for multi-object tracking model
if
for_mot
:
emb_feats
=
[]
for
i
,
block
in
enumerate
(
blocks
):
for
i
,
block
in
enumerate
(
blocks
):
if
i
==
0
and
self
.
spp_
:
if
i
==
0
and
self
.
spp_
:
block
=
self
.
spp
(
block
)
block
=
self
.
spp
(
block
)
...
@@ -797,11 +805,18 @@ class PPYOLOTinyFPN(nn.Layer):
...
@@ -797,11 +805,18 @@ class PPYOLOTinyFPN(nn.Layer):
route
,
tip
=
self
.
yolo_blocks
[
i
](
block
)
route
,
tip
=
self
.
yolo_blocks
[
i
](
block
)
yolo_feats
.
append
(
tip
)
yolo_feats
.
append
(
tip
)
if
for_mot
:
# add embedding features output
emb_feats
.
append
(
route
)
if
i
<
self
.
num_blocks
-
1
:
if
i
<
self
.
num_blocks
-
1
:
route
=
self
.
routes
[
i
](
route
)
route
=
self
.
routes
[
i
](
route
)
route
=
F
.
interpolate
(
route
=
F
.
interpolate
(
route
,
scale_factor
=
2.
,
data_format
=
self
.
data_format
)
route
,
scale_factor
=
2.
,
data_format
=
self
.
data_format
)
if
for_mot
:
return
{
'yolo_feats'
:
yolo_feats
,
'emb_feats'
:
emb_feats
}
else
:
return
yolo_feats
return
yolo_feats
@
classmethod
@
classmethod
...
@@ -964,11 +979,15 @@ class PPYOLOPAN(nn.Layer):
...
@@ -964,11 +979,15 @@ class PPYOLOPAN(nn.Layer):
self
.
_out_channels
=
self
.
_out_channels
[::
-
1
]
self
.
_out_channels
=
self
.
_out_channels
[::
-
1
]
def
forward
(
self
,
blocks
):
def
forward
(
self
,
blocks
,
for_mot
=
False
):
assert
len
(
blocks
)
==
self
.
num_blocks
assert
len
(
blocks
)
==
self
.
num_blocks
blocks
=
blocks
[::
-
1
]
blocks
=
blocks
[::
-
1
]
# fpn
fpn_feats
=
[]
fpn_feats
=
[]
# add embedding features output for multi-object tracking model
if
for_mot
:
emb_feats
=
[]
for
i
,
block
in
enumerate
(
blocks
):
for
i
,
block
in
enumerate
(
blocks
):
if
i
>
0
:
if
i
>
0
:
if
self
.
data_format
==
'NCHW'
:
if
self
.
data_format
==
'NCHW'
:
...
@@ -978,6 +997,10 @@ class PPYOLOPAN(nn.Layer):
...
@@ -978,6 +997,10 @@ class PPYOLOPAN(nn.Layer):
route
,
tip
=
self
.
fpn_blocks
[
i
](
block
)
route
,
tip
=
self
.
fpn_blocks
[
i
](
block
)
fpn_feats
.
append
(
tip
)
fpn_feats
.
append
(
tip
)
if
for_mot
:
# add embedding features output
emb_feats
.
append
(
route
)
if
i
<
self
.
num_blocks
-
1
:
if
i
<
self
.
num_blocks
-
1
:
route
=
self
.
fpn_routes
[
i
](
route
)
route
=
self
.
fpn_routes
[
i
](
route
)
route
=
F
.
interpolate
(
route
=
F
.
interpolate
(
...
@@ -996,6 +1019,9 @@ class PPYOLOPAN(nn.Layer):
...
@@ -996,6 +1019,9 @@ class PPYOLOPAN(nn.Layer):
route
,
tip
=
self
.
pan_blocks
[
i
](
block
)
route
,
tip
=
self
.
pan_blocks
[
i
](
block
)
pan_feats
.
append
(
tip
)
pan_feats
.
append
(
tip
)
if
for_mot
:
return
{
'yolo_feats'
:
pan_feats
[::
-
1
],
'emb_feats'
:
emb_feats
}
else
:
return
pan_feats
[::
-
1
]
return
pan_feats
[::
-
1
]
@
classmethod
@
classmethod
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录