Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
633d8c56
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看板
未验证
提交
633d8c56
编写于
5月 19, 2020
作者:
W
wangguanzhong
提交者:
GitHub
5月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Activate scale x y (#734)
* activate scale_x_y * update cspdarknet pretrained model
上级
f4e1436f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
201 addition
and
19 deletion
+201
-19
configs/yolov4/yolov4_cspdarknet.yml
configs/yolov4/yolov4_cspdarknet.yml
+3
-2
configs/yolov4/yolov4_cspdarknet_coco.yml
configs/yolov4/yolov4_cspdarknet_coco.yml
+179
-0
configs/yolov4/yolov4_cspdarknet_voc.yml
configs/yolov4/yolov4_cspdarknet_voc.yml
+2
-1
ppdet/modeling/anchor_heads/yolo_head.py
ppdet/modeling/anchor_heads/yolo_head.py
+7
-7
ppdet/modeling/losses/yolo_loss.py
ppdet/modeling/losses/yolo_loss.py
+10
-9
未找到文件。
configs/yolov4/yolov4_cspdarknet.yml
浏览文件 @
633d8c56
...
@@ -32,6 +32,7 @@ YOLOv4Head:
...
@@ -32,6 +32,7 @@ YOLOv4Head:
normalized
:
true
normalized
:
true
score_threshold
:
0.001
score_threshold
:
0.001
downsample
:
[
8
,
16
,
32
]
downsample
:
[
8
,
16
,
32
]
scale_x_y
:
[
1.2
,
1.1
,
1.05
]
YOLOv3Loss
:
YOLOv3Loss
:
# batch_size here is only used for fine grained loss, not used
# batch_size here is only used for fine grained loss, not used
...
@@ -42,7 +43,7 @@ YOLOv3Loss:
...
@@ -42,7 +43,7 @@ YOLOv3Loss:
ignore_thresh
:
0.7
ignore_thresh
:
0.7
label_smooth
:
true
label_smooth
:
true
downsample
:
[
8
,
16
,
32
]
downsample
:
[
8
,
16
,
32
]
#
scale_x_y: [1.2, 1.1, 1.05]
scale_x_y
:
[
1.2
,
1.1
,
1.05
]
iou_loss
:
IouLoss
iou_loss
:
IouLoss
match_score
:
true
match_score
:
true
...
@@ -83,7 +84,7 @@ EvalReader:
...
@@ -83,7 +84,7 @@ EvalReader:
!COCODataSet
!COCODataSet
image_dir
:
test2017
image_dir
:
test2017
anno_path
:
annotations/image_info_test-dev2017.json
anno_path
:
annotations/image_info_test-dev2017.json
dataset_dir
:
data/coco
dataset_dir
:
data
set
/coco
with_background
:
false
with_background
:
false
sample_transforms
:
sample_transforms
:
-
!DecodeImage
-
!DecodeImage
...
...
configs/yolov4/yolov4_cspdarknet_coco.yml
0 → 100644
浏览文件 @
633d8c56
architecture
:
YOLOv4
use_gpu
:
true
max_iters
:
500200
log_smooth_window
:
20
save_dir
:
output
snapshot_iter
:
10000
metric
:
COCO
pretrain_weights
:
https://paddlemodels.bj.bcebos.com/object_detection/CSPDarkNet53_pretrained.pdparams
weights
:
output/yolov4_cspdarknet_coco/model_final
num_classes
:
80
use_fine_grained_loss
:
true
YOLOv4
:
backbone
:
CSPDarkNet
yolo_head
:
YOLOv4Head
CSPDarkNet
:
norm_type
:
sync_bn
norm_decay
:
0.
depth
:
53
YOLOv4Head
:
anchors
:
[[
12
,
16
],
[
19
,
36
],
[
40
,
28
],
[
36
,
75
],
[
76
,
55
],
[
72
,
146
],
[
142
,
110
],
[
192
,
243
],
[
459
,
401
]]
anchor_masks
:
[[
0
,
1
,
2
],
[
3
,
4
,
5
],
[
6
,
7
,
8
]]
nms
:
background_label
:
-1
keep_top_k
:
-1
nms_threshold
:
0.45
nms_top_k
:
-1
normalized
:
true
score_threshold
:
0.001
downsample
:
[
8
,
16
,
32
]
scale_x_y
:
[
1.2
,
1.1
,
1.05
]
YOLOv3Loss
:
# batch_size here is only used for fine grained loss, not used
# for training batch_size setting, training batch_size setting
# is in configs/yolov3_reader.yml TrainReader.batch_size, batch
# size here should be set as same value as TrainReader.batch_size
batch_size
:
8
ignore_thresh
:
0.7
label_smooth
:
true
downsample
:
[
8
,
16
,
32
]
scale_x_y
:
[
1.2
,
1.1
,
1.05
]
iou_loss
:
IouLoss
match_score
:
true
IouLoss
:
loss_weight
:
0.07
max_height
:
608
max_width
:
608
ciou_term
:
true
loss_square
:
true
LearningRate
:
base_lr
:
0.0001
schedulers
:
-
!PiecewiseDecay
gamma
:
0.1
milestones
:
-
400000
-
450000
-
!LinearWarmup
start_factor
:
0.
steps
:
4000
OptimizerBuilder
:
clip_grad_by_norm
:
10.
optimizer
:
momentum
:
0.949
type
:
Momentum
regularizer
:
factor
:
0.0005
type
:
L2
_READER_
:
'
../yolov3_reader.yml'
TrainReader
:
inputs_def
:
fields
:
[
'
image'
,
'
gt_bbox'
,
'
gt_class'
,
'
gt_score'
,
'
im_id'
]
num_max_boxes
:
50
dataset
:
!COCODataSet
image_dir
:
train2017
anno_path
:
annotations/instances_train2017.json
dataset_dir
:
dataset/coco
with_background
:
false
sample_transforms
:
-
!DecodeImage
to_rgb
:
True
-
!ColorDistort
{}
-
!RandomExpand
fill_value
:
[
123.675
,
116.28
,
103.53
]
-
!RandomCrop
{}
-
!RandomFlipImage
is_normalized
:
false
-
!NormalizeBox
{}
-
!PadBox
num_max_boxes
:
50
-
!BboxXYXY2XYWH
{}
batch_transforms
:
-
!RandomShape
sizes
:
[
320
,
352
,
384
,
416
,
448
,
480
,
512
,
544
,
576
,
608
]
random_inter
:
True
-
!NormalizeImage
mean
:
[
0.
,
0.
,
0.
]
std
:
[
1.
,
1.
,
1.
]
is_scale
:
True
is_channel_first
:
false
-
!Permute
to_bgr
:
false
channel_first
:
True
# Gt2YoloTarget is only used when use_fine_grained_loss set as true,
# this operator will be deleted automatically if use_fine_grained_loss
# is set as false
-
!Gt2YoloTarget
anchor_masks
:
[[
0
,
1
,
2
],
[
3
,
4
,
5
],
[
6
,
7
,
8
]]
anchors
:
[[
12
,
16
],
[
19
,
36
],
[
40
,
28
],
[
36
,
75
],
[
76
,
55
],
[
72
,
146
],
[
142
,
110
],
[
192
,
243
],
[
459
,
401
]]
downsample_ratios
:
[
8
,
16
,
32
]
batch_size
:
8
shuffle
:
true
drop_last
:
true
worker_num
:
8
bufsize
:
16
use_process
:
true
drop_empty
:
false
EvalReader
:
inputs_def
:
fields
:
[
'
image'
,
'
im_size'
,
'
im_id'
]
num_max_boxes
:
90
dataset
:
!COCODataSet
image_dir
:
val2017
anno_path
:
annotations/instances_val2017.json
dataset_dir
:
dataset/coco
with_background
:
false
sample_transforms
:
-
!DecodeImage
to_rgb
:
True
-
!ResizeImage
target_size
:
608
interp
:
1
-
!NormalizeImage
mean
:
[
0.
,
0.
,
0.
]
std
:
[
1.
,
1.
,
1.
]
is_scale
:
True
is_channel_first
:
false
-
!PadBox
num_max_boxes
:
90
-
!Permute
to_bgr
:
false
channel_first
:
True
batch_size
:
4
drop_empty
:
false
worker_num
:
8
bufsize
:
16
TestReader
:
dataset
:
!ImageFolder
use_default_label
:
true
with_background
:
false
sample_transforms
:
-
!DecodeImage
to_rgb
:
True
-
!ResizeImage
target_size
:
608
interp
:
1
-
!NormalizeImage
mean
:
[
0.
,
0.
,
0.
]
std
:
[
1.
,
1.
,
1.
]
is_scale
:
True
is_channel_first
:
false
-
!Permute
to_bgr
:
false
channel_first
:
True
configs/yolov4/yolov4_cspdarknet_voc.yml
浏览文件 @
633d8c56
...
@@ -31,6 +31,7 @@ YOLOv4Head:
...
@@ -31,6 +31,7 @@ YOLOv4Head:
normalized
:
true
normalized
:
true
score_threshold
:
0.001
score_threshold
:
0.001
downsample
:
[
8
,
16
,
32
]
downsample
:
[
8
,
16
,
32
]
scale_x_y
:
[
1.2
,
1.1
,
1.05
]
YOLOv3Loss
:
YOLOv3Loss
:
# batch_size here is only used for fine grained loss, not used
# batch_size here is only used for fine grained loss, not used
...
@@ -41,7 +42,7 @@ YOLOv3Loss:
...
@@ -41,7 +42,7 @@ YOLOv3Loss:
ignore_thresh
:
0.7
ignore_thresh
:
0.7
label_smooth
:
true
label_smooth
:
true
downsample
:
[
8
,
16
,
32
]
downsample
:
[
8
,
16
,
32
]
#
scale_x_y: [1.2, 1.1, 1.05]
scale_x_y
:
[
1.2
,
1.1
,
1.05
]
iou_loss
:
IouLoss
iou_loss
:
IouLoss
match_score
:
true
match_score
:
true
...
...
ppdet/modeling/anchor_heads/yolo_head.py
浏览文件 @
633d8c56
...
@@ -85,8 +85,7 @@ class YOLOv3Head(object):
...
@@ -85,8 +85,7 @@ class YOLOv3Head(object):
if
isinstance
(
nms
,
dict
):
if
isinstance
(
nms
,
dict
):
self
.
nms
=
MultiClassNMS
(
**
nms
)
self
.
nms
=
MultiClassNMS
(
**
nms
)
self
.
downsample
=
downsample
self
.
downsample
=
downsample
# TODO(guanzhong) activate scale_x_y in Paddle 2.0
self
.
scale_x_y
=
scale_x_y
#self.scale_x_y = scale_x_y
self
.
clip_bbox
=
clip_bbox
self
.
clip_bbox
=
clip_bbox
def
_conv_bn
(
self
,
def
_conv_bn
(
self
,
...
@@ -317,8 +316,8 @@ class YOLOv3Head(object):
...
@@ -317,8 +316,8 @@ class YOLOv3Head(object):
len
(
self
.
anchor_masks
[
i
]),
len
(
self
.
anchor_masks
[
i
]),
self
.
num_classes
,
self
.
num_classes
,
self
.
iou_aware_factor
)
self
.
iou_aware_factor
)
#
scale_x_y = self.scale_x_y if not isinstance(
scale_x_y
=
self
.
scale_x_y
if
not
isinstance
(
#
self.scale_x_y, Sequence) else self.scale_x_y[i]
self
.
scale_x_y
,
Sequence
)
else
self
.
scale_x_y
[
i
]
box
,
score
=
fluid
.
layers
.
yolo_box
(
box
,
score
=
fluid
.
layers
.
yolo_box
(
x
=
output
,
x
=
output
,
img_size
=
im_size
,
img_size
=
im_size
,
...
@@ -327,7 +326,8 @@ class YOLOv3Head(object):
...
@@ -327,7 +326,8 @@ class YOLOv3Head(object):
conf_thresh
=
self
.
nms
.
score_threshold
,
conf_thresh
=
self
.
nms
.
score_threshold
,
downsample_ratio
=
self
.
downsample
[
i
],
downsample_ratio
=
self
.
downsample
[
i
],
name
=
self
.
prefix_name
+
"yolo_box"
+
str
(
i
),
name
=
self
.
prefix_name
+
"yolo_box"
+
str
(
i
),
clip_bbox
=
self
.
clip_bbox
)
clip_bbox
=
self
.
clip_bbox
,
scale_x_y
=
scale_x_y
)
boxes
.
append
(
box
)
boxes
.
append
(
box
)
scores
.
append
(
fluid
.
layers
.
transpose
(
score
,
perm
=
[
0
,
2
,
1
]))
scores
.
append
(
fluid
.
layers
.
transpose
(
score
,
perm
=
[
0
,
2
,
1
]))
...
@@ -349,7 +349,7 @@ class YOLOv4Head(YOLOv3Head):
...
@@ -349,7 +349,7 @@ class YOLOv4Head(YOLOv3Head):
spp_stage (int): apply spp on which stage.
spp_stage (int): apply spp on which stage.
num_classes (int): number of output classes
num_classes (int): number of output classes
downsample (list): downsample ratio for each yolo_head
downsample (list): downsample ratio for each yolo_head
scale_x_y (list): scale the
left top
point of bbox at each stage
scale_x_y (list): scale the
center
point of bbox at each stage
"""
"""
__inject__
=
[
'nms'
,
'yolo_loss'
]
__inject__
=
[
'nms'
,
'yolo_loss'
]
__shared__
=
[
'num_classes'
,
'weight_prefix_name'
]
__shared__
=
[
'num_classes'
,
'weight_prefix_name'
]
...
@@ -368,7 +368,7 @@ class YOLOv4Head(YOLOv3Head):
...
@@ -368,7 +368,7 @@ class YOLOv4Head(YOLOv3Head):
num_classes
=
80
,
num_classes
=
80
,
weight_prefix_name
=
''
,
weight_prefix_name
=
''
,
downsample
=
[
8
,
16
,
32
],
downsample
=
[
8
,
16
,
32
],
scale_x_y
=
[
1.2
,
1.1
,
1.05
]
,
scale_x_y
=
1.0
,
yolo_loss
=
"YOLOv3Loss"
,
yolo_loss
=
"YOLOv3Loss"
,
iou_aware
=
False
,
iou_aware
=
False
,
iou_aware_factor
=
0.4
,
iou_aware_factor
=
0.4
,
...
...
ppdet/modeling/losses/yolo_loss.py
浏览文件 @
633d8c56
...
@@ -58,8 +58,7 @@ class YOLOv3Loss(object):
...
@@ -58,8 +58,7 @@ class YOLOv3Loss(object):
self
.
_iou_loss
=
iou_loss
self
.
_iou_loss
=
iou_loss
self
.
_iou_aware_loss
=
iou_aware_loss
self
.
_iou_aware_loss
=
iou_aware_loss
self
.
downsample
=
downsample
self
.
downsample
=
downsample
# TODO(guanzhong) activate scale_x_y in Paddle 2.0
self
.
scale_x_y
=
scale_x_y
#self.scale_x_y = scale_x_y
self
.
match_score
=
match_score
self
.
match_score
=
match_score
def
__call__
(
self
,
outputs
,
gt_box
,
gt_label
,
gt_score
,
targets
,
anchors
,
def
__call__
(
self
,
outputs
,
gt_box
,
gt_label
,
gt_score
,
targets
,
anchors
,
...
@@ -71,8 +70,8 @@ class YOLOv3Loss(object):
...
@@ -71,8 +70,8 @@ class YOLOv3Loss(object):
else
:
else
:
losses
=
[]
losses
=
[]
for
i
,
output
in
enumerate
(
outputs
):
for
i
,
output
in
enumerate
(
outputs
):
#
scale_x_y = self.scale_x_y if not isinstance(
scale_x_y
=
self
.
scale_x_y
if
not
isinstance
(
#
self.scale_x_y, Sequence) else self.scale_x_y[i]
self
.
scale_x_y
,
Sequence
)
else
self
.
scale_x_y
[
i
]
anchor_mask
=
anchor_masks
[
i
]
anchor_mask
=
anchor_masks
[
i
]
loss
=
fluid
.
layers
.
yolov3_loss
(
loss
=
fluid
.
layers
.
yolov3_loss
(
x
=
output
,
x
=
output
,
...
@@ -85,6 +84,7 @@ class YOLOv3Loss(object):
...
@@ -85,6 +84,7 @@ class YOLOv3Loss(object):
ignore_thresh
=
self
.
_ignore_thresh
,
ignore_thresh
=
self
.
_ignore_thresh
,
downsample_ratio
=
self
.
downsample
[
i
],
downsample_ratio
=
self
.
downsample
[
i
],
use_label_smooth
=
self
.
_label_smooth
,
use_label_smooth
=
self
.
_label_smooth
,
scale_x_y
=
scale_x_y
,
name
=
prefix_name
+
"yolo_loss"
+
str
(
i
))
name
=
prefix_name
+
"yolo_loss"
+
str
(
i
))
losses
.
append
(
fluid
.
layers
.
reduce_mean
(
loss
))
losses
.
append
(
fluid
.
layers
.
reduce_mean
(
loss
))
...
@@ -162,11 +162,11 @@ class YOLOv3Loss(object):
...
@@ -162,11 +162,11 @@ class YOLOv3Loss(object):
loss_iou_aware
,
dim
=
[
1
,
2
,
3
])
loss_iou_aware
,
dim
=
[
1
,
2
,
3
])
loss_iou_awares
.
append
(
fluid
.
layers
.
reduce_mean
(
loss_iou_aware
))
loss_iou_awares
.
append
(
fluid
.
layers
.
reduce_mean
(
loss_iou_aware
))
#
scale_x_y = self.scale_x_y if not isinstance(
scale_x_y
=
self
.
scale_x_y
if
not
isinstance
(
#
self.scale_x_y, Sequence) else self.scale_x_y[i]
self
.
scale_x_y
,
Sequence
)
else
self
.
scale_x_y
[
i
]
loss_obj_pos
,
loss_obj_neg
=
self
.
_calc_obj_loss
(
loss_obj_pos
,
loss_obj_neg
=
self
.
_calc_obj_loss
(
output
,
obj
,
tobj
,
gt_box
,
self
.
_batch_size
,
anchors
,
output
,
obj
,
tobj
,
gt_box
,
self
.
_batch_size
,
anchors
,
num_classes
,
downsample
,
self
.
_ignore_thresh
)
num_classes
,
downsample
,
self
.
_ignore_thresh
,
scale_x_y
)
loss_cls
=
fluid
.
layers
.
sigmoid_cross_entropy_with_logits
(
cls
,
tcls
)
loss_cls
=
fluid
.
layers
.
sigmoid_cross_entropy_with_logits
(
cls
,
tcls
)
loss_cls
=
fluid
.
layers
.
elementwise_mul
(
loss_cls
,
tobj
,
axis
=
0
)
loss_cls
=
fluid
.
layers
.
elementwise_mul
(
loss_cls
,
tobj
,
axis
=
0
)
...
@@ -276,7 +276,7 @@ class YOLOv3Loss(object):
...
@@ -276,7 +276,7 @@ class YOLOv3Loss(object):
return
(
tx
,
ty
,
tw
,
th
,
tscale
,
tobj
,
tcls
)
return
(
tx
,
ty
,
tw
,
th
,
tscale
,
tobj
,
tcls
)
def
_calc_obj_loss
(
self
,
output
,
obj
,
tobj
,
gt_box
,
batch_size
,
anchors
,
def
_calc_obj_loss
(
self
,
output
,
obj
,
tobj
,
gt_box
,
batch_size
,
anchors
,
num_classes
,
downsample
,
ignore_thresh
):
num_classes
,
downsample
,
ignore_thresh
,
scale_x_y
):
# A prediction bbox overlap any gt_bbox over ignore_thresh,
# A prediction bbox overlap any gt_bbox over ignore_thresh,
# objectness loss will be ignored, process as follows:
# objectness loss will be ignored, process as follows:
...
@@ -290,7 +290,8 @@ class YOLOv3Loss(object):
...
@@ -290,7 +290,8 @@ class YOLOv3Loss(object):
class_num
=
num_classes
,
class_num
=
num_classes
,
conf_thresh
=
0.
,
conf_thresh
=
0.
,
downsample_ratio
=
downsample
,
downsample_ratio
=
downsample
,
clip_bbox
=
False
)
clip_bbox
=
False
,
scale_x_y
=
scale_x_y
)
# 2. split pred bbox and gt bbox by sample, calculate IoU between pred bbox
# 2. split pred bbox and gt bbox by sample, calculate IoU between pred bbox
# and gt bbox in each sample
# and gt bbox in each sample
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录