Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
4f047309
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看板
未验证
提交
4f047309
编写于
4月 08, 2021
作者:
W
wangxinxin08
提交者:
GitHub
4月 08, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
yolo annotations (#2554)
上级
d59c0ebf
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
170 addition
and
0 deletion
+170
-0
ppdet/modeling/architectures/yolo.py
ppdet/modeling/architectures/yolo.py
+10
-0
ppdet/modeling/backbones/darknet.py
ppdet/modeling/backbones/darknet.py
+66
-0
ppdet/modeling/heads/yolo_head.py
ppdet/modeling/heads/yolo_head.py
+12
-0
ppdet/modeling/losses/yolo_loss.py
ppdet/modeling/losses/yolo_loss.py
+12
-0
ppdet/modeling/necks/yolo_fpn.py
ppdet/modeling/necks/yolo_fpn.py
+70
-0
未找到文件。
ppdet/modeling/architectures/yolo.py
浏览文件 @
4f047309
...
@@ -20,6 +20,16 @@ class YOLOv3(BaseArch):
...
@@ -20,6 +20,16 @@ class YOLOv3(BaseArch):
yolo_head
=
'YOLOv3Head'
,
yolo_head
=
'YOLOv3Head'
,
post_process
=
'BBoxPostProcess'
,
post_process
=
'BBoxPostProcess'
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
YOLOv3 network, see https://arxiv.org/abs/1804.02767
Args:
backbone (nn.Layer): backbone instance
neck (nn.Layer): neck instance
yolo_head (nn.Layer): anchor_head instance
bbox_post_process (object): `BBoxPostProcess` instance
data_format (str): data format, NCHW or NHWC
"""
super
(
YOLOv3
,
self
).
__init__
(
data_format
=
data_format
)
super
(
YOLOv3
,
self
).
__init__
(
data_format
=
data_format
)
self
.
backbone
=
backbone
self
.
backbone
=
backbone
self
.
neck
=
neck
self
.
neck
=
neck
...
...
ppdet/modeling/backbones/darknet.py
浏览文件 @
4f047309
...
@@ -37,6 +37,22 @@ class ConvBNLayer(nn.Layer):
...
@@ -37,6 +37,22 @@ class ConvBNLayer(nn.Layer):
act
=
"leaky"
,
act
=
"leaky"
,
name
=
None
,
name
=
None
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
conv + bn + activation layer
Args:
ch_in (int): input channel
ch_out (int): output channel
filter_size (int): filter size, default 3
stride (int): stride, default 1
groups (int): number of groups of conv layer, default 1
padding (int): padding size, default 0
norm_type (str): batch norm type, default bn
norm_decay (str): decay for weight and bias of batch norm layer, default 0.
act (str): activation function type, default 'leaky', which means leaky_relu
name (str): layer name
data_format (str): data format, NCHW or NHWC
"""
super
(
ConvBNLayer
,
self
).
__init__
()
super
(
ConvBNLayer
,
self
).
__init__
()
self
.
conv
=
nn
.
Conv2D
(
self
.
conv
=
nn
.
Conv2D
(
...
@@ -75,6 +91,20 @@ class DownSample(nn.Layer):
...
@@ -75,6 +91,20 @@ class DownSample(nn.Layer):
norm_decay
=
0.
,
norm_decay
=
0.
,
name
=
None
,
name
=
None
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
downsample layer
Args:
ch_in (int): input channel
ch_out (int): output channel
filter_size (int): filter size, default 3
stride (int): stride, default 2
padding (int): padding size, default 1
norm_type (str): batch norm type, default bn
norm_decay (str): decay for weight and bias of batch norm layer, default 0.
name (str): layer name
data_format (str): data format, NCHW or NHWC
"""
super
(
DownSample
,
self
).
__init__
()
super
(
DownSample
,
self
).
__init__
()
...
@@ -103,6 +133,18 @@ class BasicBlock(nn.Layer):
...
@@ -103,6 +133,18 @@ class BasicBlock(nn.Layer):
norm_decay
=
0.
,
norm_decay
=
0.
,
name
=
None
,
name
=
None
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
BasicBlock layer of DarkNet
Args:
ch_in (int): input channel
ch_out (int): output channel
norm_type (str): batch norm type, default bn
norm_decay (str): decay for weight and bias of batch norm layer, default 0.
name (str): layer name
data_format (str): data format, NCHW or NHWC
"""
super
(
BasicBlock
,
self
).
__init__
()
super
(
BasicBlock
,
self
).
__init__
()
self
.
conv1
=
ConvBNLayer
(
self
.
conv1
=
ConvBNLayer
(
...
@@ -142,6 +184,18 @@ class Blocks(nn.Layer):
...
@@ -142,6 +184,18 @@ class Blocks(nn.Layer):
norm_decay
=
0.
,
norm_decay
=
0.
,
name
=
None
,
name
=
None
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
Blocks layer, which consist of some BaickBlock layers
Args:
ch_in (int): input channel
ch_out (int): output channel
count (int): number of BasicBlock layer
norm_type (str): batch norm type, default bn
norm_decay (str): decay for weight and bias of batch norm layer, default 0.
name (str): layer name
data_format (str): data format, NCHW or NHWC
"""
super
(
Blocks
,
self
).
__init__
()
super
(
Blocks
,
self
).
__init__
()
self
.
basicblock0
=
BasicBlock
(
self
.
basicblock0
=
BasicBlock
(
...
@@ -189,6 +243,18 @@ class DarkNet(nn.Layer):
...
@@ -189,6 +243,18 @@ class DarkNet(nn.Layer):
norm_type
=
'bn'
,
norm_type
=
'bn'
,
norm_decay
=
0.
,
norm_decay
=
0.
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
Darknet, see https://pjreddie.com/darknet/yolo/
Args:
depth (int): depth of network
freeze_at (int): freeze the backbone at which stage
filter_size (int): filter size, default 3
return_idx (list): index of stages whose feature maps are returned
norm_type (str): batch norm type, default bn
norm_decay (str): decay for weight and bias of batch norm layer, default 0.
data_format (str): data format, NCHW or NHWC
"""
super
(
DarkNet
,
self
).
__init__
()
super
(
DarkNet
,
self
).
__init__
()
self
.
depth
=
depth
self
.
depth
=
depth
self
.
freeze_at
=
freeze_at
self
.
freeze_at
=
freeze_at
...
...
ppdet/modeling/heads/yolo_head.py
浏览文件 @
4f047309
...
@@ -28,6 +28,18 @@ class YOLOv3Head(nn.Layer):
...
@@ -28,6 +28,18 @@ class YOLOv3Head(nn.Layer):
iou_aware
=
False
,
iou_aware
=
False
,
iou_aware_factor
=
0.4
,
iou_aware_factor
=
0.4
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
Head for YOLOv3 network
Args:
num_classes (int): number of foreground classes
anchors (list): anchors
anchor_masks (list): anchor masks
loss (object): YOLOv3Loss instance
iou_aware (bool): whether to use iou_aware
iou_aware_factor (float): iou aware factor
data_format (str): data format, NCHW or NHWC
"""
super
(
YOLOv3Head
,
self
).
__init__
()
super
(
YOLOv3Head
,
self
).
__init__
()
self
.
num_classes
=
num_classes
self
.
num_classes
=
num_classes
self
.
loss
=
loss
self
.
loss
=
loss
...
...
ppdet/modeling/losses/yolo_loss.py
浏览文件 @
4f047309
...
@@ -46,6 +46,18 @@ class YOLOv3Loss(nn.Layer):
...
@@ -46,6 +46,18 @@ class YOLOv3Loss(nn.Layer):
scale_x_y
=
1.
,
scale_x_y
=
1.
,
iou_loss
=
None
,
iou_loss
=
None
,
iou_aware_loss
=
None
):
iou_aware_loss
=
None
):
"""
YOLOv3Loss layer
Args:
num_calsses (int): number of foreground classes
ignore_thresh (float): threshold to ignore confidence loss
label_smooth (bool): whether to use label smoothing
downsample (list): downsample ratio for each detection block
scale_x_y (float): scale_x_y factor
iou_loss (object): IoULoss instance
iou_aware_loss (object): IouAwareLoss instance
"""
super
(
YOLOv3Loss
,
self
).
__init__
()
super
(
YOLOv3Loss
,
self
).
__init__
()
self
.
num_classes
=
num_classes
self
.
num_classes
=
num_classes
self
.
ignore_thresh
=
ignore_thresh
self
.
ignore_thresh
=
ignore_thresh
...
...
ppdet/modeling/necks/yolo_fpn.py
浏览文件 @
4f047309
...
@@ -27,6 +27,16 @@ __all__ = ['YOLOv3FPN', 'PPYOLOFPN']
...
@@ -27,6 +27,16 @@ __all__ = ['YOLOv3FPN', 'PPYOLOFPN']
class
YoloDetBlock
(
nn
.
Layer
):
class
YoloDetBlock
(
nn
.
Layer
):
def
__init__
(
self
,
ch_in
,
channel
,
norm_type
,
name
,
data_format
=
'NCHW'
):
def
__init__
(
self
,
ch_in
,
channel
,
norm_type
,
name
,
data_format
=
'NCHW'
):
"""
YOLODetBlock layer for yolov3, see https://arxiv.org/abs/1804.02767
Args:
ch_in (int): input channel
channel (int): base channel
norm_type (str): batch norm type
name (str): layer name
data_format (str): data format, NCHW or NHWC
"""
super
(
YoloDetBlock
,
self
).
__init__
()
super
(
YoloDetBlock
,
self
).
__init__
()
self
.
ch_in
=
ch_in
self
.
ch_in
=
ch_in
self
.
channel
=
channel
self
.
channel
=
channel
...
@@ -78,6 +88,17 @@ class SPP(nn.Layer):
...
@@ -78,6 +88,17 @@ class SPP(nn.Layer):
norm_type
,
norm_type
,
name
,
name
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
SPP layer, which consist of four pooling layer follwed by conv layer
Args:
ch_in (int): input channel of conv layer
ch_out (int): output channel of conv layer
k (int): kernel size of conv layer
norm_type (str): batch norm type
name (str): layer name
data_format (str): data format, NCHW or NHWC
"""
super
(
SPP
,
self
).
__init__
()
super
(
SPP
,
self
).
__init__
()
self
.
pool
=
[]
self
.
pool
=
[]
for
size
in
pool_size
:
for
size
in
pool_size
:
...
@@ -110,6 +131,15 @@ class SPP(nn.Layer):
...
@@ -110,6 +131,15 @@ class SPP(nn.Layer):
class
DropBlock
(
nn
.
Layer
):
class
DropBlock
(
nn
.
Layer
):
def
__init__
(
self
,
block_size
,
keep_prob
,
name
,
data_format
=
'NCHW'
):
def
__init__
(
self
,
block_size
,
keep_prob
,
name
,
data_format
=
'NCHW'
):
"""
DropBlock layer, see https://arxiv.org/abs/1810.12890
Args:
block_size (int): block size
keep_prob (int): keep probability
name (str): layer name
data_format (str): data format, NCHW or NHWC
"""
super
(
DropBlock
,
self
).
__init__
()
super
(
DropBlock
,
self
).
__init__
()
self
.
block_size
=
block_size
self
.
block_size
=
block_size
self
.
keep_prob
=
keep_prob
self
.
keep_prob
=
keep_prob
...
@@ -149,6 +179,19 @@ class CoordConv(nn.Layer):
...
@@ -149,6 +179,19 @@ class CoordConv(nn.Layer):
norm_type
,
norm_type
,
name
,
name
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
CoordConv layer
Args:
ch_in (int): input channel
ch_out (int): output channel
filter_size (int): filter size, default 3
padding (int): padding size, default 0
norm_type (str): batch norm type, default bn
name (str): layer name
data_format (str): data format, NCHW or NHWC
"""
super
(
CoordConv
,
self
).
__init__
()
super
(
CoordConv
,
self
).
__init__
()
self
.
conv
=
ConvBNLayer
(
self
.
conv
=
ConvBNLayer
(
ch_in
+
2
,
ch_in
+
2
,
...
@@ -193,6 +236,14 @@ class CoordConv(nn.Layer):
...
@@ -193,6 +236,14 @@ class CoordConv(nn.Layer):
class
PPYOLODetBlock
(
nn
.
Layer
):
class
PPYOLODetBlock
(
nn
.
Layer
):
def
__init__
(
self
,
cfg
,
name
,
data_format
=
'NCHW'
):
def
__init__
(
self
,
cfg
,
name
,
data_format
=
'NCHW'
):
"""
PPYOLODetBlock layer
Args:
cfg (list): layer configs for this block
name (str): block name
data_format (str): data format, NCHW or NHWC
"""
super
(
PPYOLODetBlock
,
self
).
__init__
()
super
(
PPYOLODetBlock
,
self
).
__init__
()
self
.
conv_module
=
nn
.
Sequential
()
self
.
conv_module
=
nn
.
Sequential
()
for
idx
,
(
conv_name
,
layer
,
args
,
kwargs
)
in
enumerate
(
cfg
[:
-
1
]):
for
idx
,
(
conv_name
,
layer
,
args
,
kwargs
)
in
enumerate
(
cfg
[:
-
1
]):
...
@@ -220,6 +271,15 @@ class YOLOv3FPN(nn.Layer):
...
@@ -220,6 +271,15 @@ class YOLOv3FPN(nn.Layer):
in_channels
=
[
256
,
512
,
1024
],
in_channels
=
[
256
,
512
,
1024
],
norm_type
=
'bn'
,
norm_type
=
'bn'
,
data_format
=
'NCHW'
):
data_format
=
'NCHW'
):
"""
YOLOv3FPN layer
Args:
in_channels (list): input channels for fpn
norm_type (str): batch norm type, default bn
data_format (str): data format, NCHW or NHWC
"""
super
(
YOLOv3FPN
,
self
).
__init__
()
super
(
YOLOv3FPN
,
self
).
__init__
()
assert
len
(
in_channels
)
>
0
,
"in_channels length should > 0"
assert
len
(
in_channels
)
>
0
,
"in_channels length should > 0"
self
.
in_channels
=
in_channels
self
.
in_channels
=
in_channels
...
@@ -300,6 +360,16 @@ class PPYOLOFPN(nn.Layer):
...
@@ -300,6 +360,16 @@ class PPYOLOFPN(nn.Layer):
norm_type
=
'bn'
,
norm_type
=
'bn'
,
data_format
=
'NCHW'
,
data_format
=
'NCHW'
,
**
kwargs
):
**
kwargs
):
"""
PPYOLOFPN layer
Args:
in_channels (list): input channels for fpn
norm_type (str): batch norm type, default bn
data_format (str): data format, NCHW or NHWC
kwargs: extra key-value pairs, such as parameter of DropBlock and spp
"""
super
(
PPYOLOFPN
,
self
).
__init__
()
super
(
PPYOLOFPN
,
self
).
__init__
()
assert
len
(
in_channels
)
>
0
,
"in_channels length should > 0"
assert
len
(
in_channels
)
>
0
,
"in_channels length should > 0"
self
.
in_channels
=
in_channels
self
.
in_channels
=
in_channels
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录