Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
fb82692a
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
fb82692a
编写于
4月 26, 2020
作者:
X
xinyingxinying
提交者:
GitHub
4月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add dcn on fcos head and backbone (#562)
* #add dcn on FCOS_head and backbone
上级
4a7cba60
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
320 addition
and
4 deletion
+320
-4
configs/anchor_free/README.md
configs/anchor_free/README.md
+1
-0
configs/anchor_free/fcos_dcn_r50_fpn_1x.yml
configs/anchor_free/fcos_dcn_r50_fpn_1x.yml
+183
-0
ppdet/modeling/anchor_heads/fcos_head.py
ppdet/modeling/anchor_heads/fcos_head.py
+7
-3
ppdet/modeling/ops.py
ppdet/modeling/ops.py
+129
-1
未找到文件。
configs/anchor_free/README.md
浏览文件 @
fb82692a
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
| CornerNet-Squeeze-dcn-mixup-cosine
*
| ResNet50-vd | 14 |
[
faster\_rcnn\_dcn\_r50\_vd\_fpn\_2x
](
https://paddlemodels.bj.bcebos.com/object_detection/faster_rcnn_dcn_r50_vd_fpn_2x.tar
)
| 38.2 | 40.05 |
[
下载链接
](
https://paddlemodels.bj.bcebos.com/object_detection/cornernet_squeeze_dcn_r50_vd_fpn_mixup_cosine.pdparams
)
|
| CornerNet-Squeeze-dcn-mixup-cosine
*
| ResNet50-vd | 14 |
[
faster\_rcnn\_dcn\_r50\_vd\_fpn\_2x
](
https://paddlemodels.bj.bcebos.com/object_detection/faster_rcnn_dcn_r50_vd_fpn_2x.tar
)
| 38.2 | 40.05 |
[
下载链接
](
https://paddlemodels.bj.bcebos.com/object_detection/cornernet_squeeze_dcn_r50_vd_fpn_mixup_cosine.pdparams
)
|
| FCOS | ResNet50 | 2 |
[
ResNet50\_cos\_pretrained
](
https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
)
| 39.8 | - |
[
下载链接
](
https://paddlemodels.bj.bcebos.com/object_detection/fcos_r50_fpn_1x.pdparams
)
|
| FCOS | ResNet50 | 2 |
[
ResNet50\_cos\_pretrained
](
https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
)
| 39.8 | - |
[
下载链接
](
https://paddlemodels.bj.bcebos.com/object_detection/fcos_r50_fpn_1x.pdparams
)
|
| FCOS+multiscale_train | ResNet50 | 2 |
[
ResNet50\_cos\_pretrained
](
https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
)
| 42.0 | - |
[
下载链接
](
https://paddlemodels.bj.bcebos.com/object_detection/fcos_r50_fpn_multiscale_2x.pdparams
)
|
| FCOS+multiscale_train | ResNet50 | 2 |
[
ResNet50\_cos\_pretrained
](
https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
)
| 42.0 | - |
[
下载链接
](
https://paddlemodels.bj.bcebos.com/object_detection/fcos_r50_fpn_multiscale_2x.pdparams
)
|
| FCOS+DCN | ResNet50 | 2 |
[
ResNet50\_cos\_pretrained
](
https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
)
| 44.4 | - |
[
下载链接
](
https://paddlemodels.bj.bcebos.com/object_detection/fcos_dcn_r50_fpn_1x.pdparams
)
|
**注意:**
**注意:**
...
...
configs/anchor_free/fcos_dcn_r50_fpn_1x.yml
0 → 100644
浏览文件 @
fb82692a
architecture
:
FCOS
max_iters
:
90000
use_gpu
:
true
snapshot_iter
:
5000
log_smooth_window
:
20
log_iter
:
20
save_dir
:
output
pretrain_weights
:
https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
metric
:
COCO
weights
:
output/fcos_dcn_r50_fpn_1x/model_final
num_classes
:
81
FCOS
:
backbone
:
ResNet
fpn
:
FPN
fcos_head
:
FCOSHead
ResNet
:
norm_type
:
affine_channel
norm_decay
:
0.
depth
:
50
feature_maps
:
[
3
,
4
,
5
]
freeze_at
:
2
dcn_v2_stages
:
[
3
,
4
,
5
]
FPN
:
min_level
:
3
max_level
:
7
num_chan
:
256
use_c5
:
false
spatial_scale
:
[
0.03125
,
0.0625
,
0.125
]
has_extra_convs
:
true
FCOSHead
:
num_classes
:
81
fpn_stride
:
[
8
,
16
,
32
,
64
,
128
]
num_convs
:
4
norm_type
:
"
gn"
fcos_loss
:
FCOSLoss
norm_reg_targets
:
True
centerness_on_reg
:
True
use_dcn_in_tower
:
True
nms
:
MultiClassNMS
MultiClassNMS
:
score_threshold
:
0.025
nms_top_k
:
1000
keep_top_k
:
100
nms_threshold
:
0.6
background_label
:
-1
FCOSLoss
:
loss_alpha
:
0.25
loss_gamma
:
2.0
iou_loss_type
:
"
giou"
reg_weights
:
1.0
LearningRate
:
base_lr
:
0.01
schedulers
:
-
!PiecewiseDecay
gamma
:
0.1
milestones
:
[
60000
,
80000
]
-
!LinearWarmup
start_factor
:
0.3333333333333333
steps
:
500
OptimizerBuilder
:
optimizer
:
momentum
:
0.9
type
:
Momentum
regularizer
:
factor
:
0.0001
type
:
L2
TrainReader
:
inputs_def
:
fields
:
[
'
image'
,
'
gt_bbox'
,
'
gt_class'
,
'
gt_score'
,
'
im_info'
]
dataset
:
!COCODataSet
image_dir
:
train2017
anno_path
:
annotations/instances_train2017.json
dataset_dir
:
dataset/coco
with_background
:
true
sample_transforms
:
-
!DecodeImage
to_rgb
:
true
-
!RandomFlipImage
prob
:
0.5
-
!NormalizeImage
is_channel_first
:
false
is_scale
:
true
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
-
!ResizeImage
target_size
:
800
max_size
:
1333
interp
:
1
use_cv2
:
true
-
!Permute
to_bgr
:
false
channel_first
:
true
batch_transforms
:
-
!PadBatch
pad_to_stride
:
128
use_padded_im_info
:
false
-
!Gt2FCOSTarget
object_sizes_boundary
:
[
64
,
128
,
256
,
512
]
center_sampling_radius
:
1.5
downsample_ratios
:
[
8
,
16
,
32
,
64
,
128
]
norm_reg_targets
:
True
batch_size
:
2
shuffle
:
true
worker_num
:
16
use_process
:
false
EvalReader
:
inputs_def
:
fields
:
[
'
image'
,
'
im_id'
,
'
im_shape'
,
'
im_info'
]
dataset
:
!COCODataSet
image_dir
:
val2017
anno_path
:
annotations/instances_val2017.json
dataset_dir
:
dataset/coco
with_background
:
false
sample_transforms
:
-
!DecodeImage
to_rgb
:
true
with_mixup
:
false
-
!NormalizeImage
is_channel_first
:
false
is_scale
:
true
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
-
!ResizeImage
target_size
:
800
max_size
:
1333
interp
:
1
use_cv2
:
true
-
!Permute
channel_first
:
true
to_bgr
:
false
batch_transforms
:
-
!PadBatch
pad_to_stride
:
128
use_padded_im_info
:
true
batch_size
:
8
shuffle
:
false
worker_num
:
2
use_process
:
false
TestReader
:
inputs_def
:
# set image_shape if needed
fields
:
[
'
image'
,
'
im_id'
,
'
im_shape'
,
'
im_info'
]
dataset
:
!ImageFolder
anno_path
:
annotations/instances_val2017.json
with_background
:
false
sample_transforms
:
-
!DecodeImage
to_rgb
:
true
with_mixup
:
false
-
!NormalizeImage
is_channel_first
:
false
is_scale
:
true
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
-
!ResizeImage
interp
:
1
max_size
:
1333
target_size
:
800
use_cv2
:
true
-
!Permute
channel_first
:
true
to_bgr
:
false
batch_transforms
:
-
!PadBatch
pad_to_stride
:
128
use_padded_im_info
:
true
batch_size
:
1
shuffle
:
false
ppdet/modeling/anchor_heads/fcos_head.py
浏览文件 @
fb82692a
...
@@ -22,7 +22,7 @@ import paddle.fluid as fluid
...
@@ -22,7 +22,7 @@ import paddle.fluid as fluid
from
paddle.fluid.param_attr
import
ParamAttr
from
paddle.fluid.param_attr
import
ParamAttr
from
paddle.fluid.initializer
import
Normal
,
Constant
,
NumpyArrayInitializer
from
paddle.fluid.initializer
import
Normal
,
Constant
,
NumpyArrayInitializer
from
paddle.fluid.regularizer
import
L2Decay
from
paddle.fluid.regularizer
import
L2Decay
from
ppdet.modeling.ops
import
ConvNorm
from
ppdet.modeling.ops
import
ConvNorm
,
DeformConvNorm
from
ppdet.modeling.ops
import
MultiClassNMS
from
ppdet.modeling.ops
import
MultiClassNMS
from
ppdet.core.workspace
import
register
from
ppdet.core.workspace
import
register
...
@@ -89,9 +89,13 @@ class FCOSHead(object):
...
@@ -89,9 +89,13 @@ class FCOSHead(object):
subnet_blob_cls
=
features
subnet_blob_cls
=
features
subnet_blob_reg
=
features
subnet_blob_reg
=
features
in_channles
=
features
.
shape
[
1
]
in_channles
=
features
.
shape
[
1
]
if
self
.
use_dcn_in_tower
:
conv_norm
=
DeformConvNorm
else
:
conv_norm
=
ConvNorm
for
lvl
in
range
(
0
,
self
.
num_convs
):
for
lvl
in
range
(
0
,
self
.
num_convs
):
conv_cls_name
=
'fcos_head_cls_tower_conv_{}'
.
format
(
lvl
)
conv_cls_name
=
'fcos_head_cls_tower_conv_{}'
.
format
(
lvl
)
subnet_blob_cls
=
ConvN
orm
(
subnet_blob_cls
=
conv_n
orm
(
input
=
subnet_blob_cls
,
input
=
subnet_blob_cls
,
num_filters
=
in_channles
,
num_filters
=
in_channles
,
filter_size
=
3
,
filter_size
=
3
,
...
@@ -104,7 +108,7 @@ class FCOSHead(object):
...
@@ -104,7 +108,7 @@ class FCOSHead(object):
norm_name
=
conv_cls_name
+
"_norm"
,
norm_name
=
conv_cls_name
+
"_norm"
,
name
=
conv_cls_name
)
name
=
conv_cls_name
)
conv_reg_name
=
'fcos_head_reg_tower_conv_{}'
.
format
(
lvl
)
conv_reg_name
=
'fcos_head_reg_tower_conv_{}'
.
format
(
lvl
)
subnet_blob_reg
=
ConvN
orm
(
subnet_blob_reg
=
conv_n
orm
(
input
=
subnet_blob_reg
,
input
=
subnet_blob_reg
,
num_filters
=
in_channles
,
num_filters
=
in_channles
,
filter_size
=
3
,
filter_size
=
3
,
...
...
ppdet/modeling/ops.py
浏览文件 @
fb82692a
...
@@ -27,11 +27,139 @@ __all__ = [
...
@@ -27,11 +27,139 @@ __all__ = [
'AnchorGenerator'
,
'DropBlock'
,
'RPNTargetAssign'
,
'GenerateProposals'
,
'AnchorGenerator'
,
'DropBlock'
,
'RPNTargetAssign'
,
'GenerateProposals'
,
'MultiClassNMS'
,
'BBoxAssigner'
,
'MaskAssigner'
,
'RoIAlign'
,
'RoIPool'
,
'MultiClassNMS'
,
'BBoxAssigner'
,
'MaskAssigner'
,
'RoIAlign'
,
'RoIPool'
,
'MultiBoxHead'
,
'SSDLiteMultiBoxHead'
,
'SSDOutputDecoder'
,
'MultiBoxHead'
,
'SSDLiteMultiBoxHead'
,
'SSDOutputDecoder'
,
'RetinaTargetAssign'
,
'RetinaOutputDecoder'
,
'ConvNorm'
,
'RetinaTargetAssign'
,
'RetinaOutputDecoder'
,
'ConvNorm'
,
'DeformConvNorm'
,
'MultiClassSoftNMS'
,
'LibraBBoxAssigner'
'MultiClassSoftNMS'
,
'LibraBBoxAssigner'
]
]
def
_conv_offset
(
input
,
filter_size
,
stride
,
padding
,
act
=
None
,
name
=
None
):
out_channel
=
filter_size
*
filter_size
*
3
out
=
fluid
.
layers
.
conv2d
(
input
,
num_filters
=
out_channel
,
filter_size
=
filter_size
,
stride
=
stride
,
padding
=
padding
,
param_attr
=
ParamAttr
(
initializer
=
fluid
.
initializer
.
Constant
(
value
=
0
),
name
=
name
+
".w_0"
),
bias_attr
=
ParamAttr
(
initializer
=
fluid
.
initializer
.
Constant
(
value
=
0
),
name
=
name
+
".b_0"
),
act
=
act
,
name
=
name
)
return
out
def
DeformConvNorm
(
input
,
num_filters
,
filter_size
,
stride
=
1
,
groups
=
1
,
norm_decay
=
0.
,
norm_type
=
'affine_channel'
,
norm_groups
=
32
,
dilation
=
1
,
lr_scale
=
1
,
freeze_norm
=
False
,
act
=
None
,
norm_name
=
None
,
initializer
=
None
,
bias_attr
=
False
,
name
=
None
):
if
bias_attr
:
bias_para
=
ParamAttr
(
name
=
name
+
"_bias"
,
initializer
=
fluid
.
initializer
.
Constant
(
value
=
0
),
learning_rate
=
lr_scale
*
2
)
else
:
bias_para
=
False
offset_mask
=
_conv_offset
(
input
=
input
,
filter_size
=
filter_size
,
stride
=
stride
,
padding
=
(
filter_size
-
1
)
//
2
,
act
=
None
,
name
=
name
+
"_conv_offset"
)
offset_channel
=
filter_size
**
2
*
2
mask_channel
=
filter_size
**
2
offset
,
mask
=
fluid
.
layers
.
split
(
input
=
offset_mask
,
num_or_sections
=
[
offset_channel
,
mask_channel
],
dim
=
1
)
mask
=
fluid
.
layers
.
sigmoid
(
mask
)
conv
=
fluid
.
layers
.
deformable_conv
(
input
=
input
,
offset
=
offset
,
mask
=
mask
,
num_filters
=
num_filters
,
filter_size
=
filter_size
,
stride
=
stride
,
padding
=
(
filter_size
-
1
)
//
2
*
dilation
,
dilation
=
dilation
,
groups
=
groups
,
deformable_groups
=
1
,
im2col_step
=
1
,
param_attr
=
ParamAttr
(
name
=
name
+
"_weights"
,
initializer
=
initializer
,
learning_rate
=
lr_scale
),
bias_attr
=
bias_para
,
name
=
name
+
".conv2d.output.1"
)
norm_lr
=
0.
if
freeze_norm
else
1.
pattr
=
ParamAttr
(
name
=
norm_name
+
'_scale'
,
learning_rate
=
norm_lr
*
lr_scale
,
regularizer
=
L2Decay
(
norm_decay
))
battr
=
ParamAttr
(
name
=
norm_name
+
'_offset'
,
learning_rate
=
norm_lr
*
lr_scale
,
regularizer
=
L2Decay
(
norm_decay
))
if
norm_type
in
[
'bn'
,
'sync_bn'
]:
global_stats
=
True
if
freeze_norm
else
False
out
=
fluid
.
layers
.
batch_norm
(
input
=
conv
,
act
=
act
,
name
=
norm_name
+
'.output.1'
,
param_attr
=
pattr
,
bias_attr
=
battr
,
moving_mean_name
=
norm_name
+
'_mean'
,
moving_variance_name
=
norm_name
+
'_variance'
,
use_global_stats
=
global_stats
)
scale
=
fluid
.
framework
.
_get_var
(
pattr
.
name
)
bias
=
fluid
.
framework
.
_get_var
(
battr
.
name
)
elif
norm_type
==
'gn'
:
out
=
fluid
.
layers
.
group_norm
(
input
=
conv
,
act
=
act
,
name
=
norm_name
+
'.output.1'
,
groups
=
norm_groups
,
param_attr
=
pattr
,
bias_attr
=
battr
)
scale
=
fluid
.
framework
.
_get_var
(
pattr
.
name
)
bias
=
fluid
.
framework
.
_get_var
(
battr
.
name
)
elif
norm_type
==
'affine_channel'
:
scale
=
fluid
.
layers
.
create_parameter
(
shape
=
[
conv
.
shape
[
1
]],
dtype
=
conv
.
dtype
,
attr
=
pattr
,
default_initializer
=
fluid
.
initializer
.
Constant
(
1.
))
bias
=
fluid
.
layers
.
create_parameter
(
shape
=
[
conv
.
shape
[
1
]],
dtype
=
conv
.
dtype
,
attr
=
battr
,
default_initializer
=
fluid
.
initializer
.
Constant
(
0.
))
out
=
fluid
.
layers
.
affine_channel
(
x
=
conv
,
scale
=
scale
,
bias
=
bias
,
act
=
act
)
if
freeze_norm
:
scale
.
stop_gradient
=
True
bias
.
stop_gradient
=
True
return
out
def
ConvNorm
(
input
,
def
ConvNorm
(
input
,
num_filters
,
num_filters
,
filter_size
,
filter_size
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录