Skip to content

Commit 396a519

Browse files
authored
add WiderNaive-18 base model (PaddlePaddle#4312)
* fix naive-lite-hrnet backbone * add WiderNaive-18 model
1 parent dbfc8c9 commit 396a519

File tree

3 files changed

+148
-7
lines changed

3 files changed

+148
-7
lines changed

configs/keypoint/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ COCO数据集
2323
| HRNet-w32 | 384x288 | 77.8 | [hrnet_w32_384x288.pdparams](https://paddledet.bj.bcebos.com/models/keypoint/hrnet_w32_384x288.pdparams) | [config](./hrnet/hrnet_w32_384x288.yml) |
2424
| HRNet-w32+DarkPose | 256x192 | 78.0 | [dark_hrnet_w32_256x192.pdparams](https://paddledet.bj.bcebos.com/models/keypoint/dark_hrnet_w32_256x192.pdparams) | [config](./hrnet/dark_hrnet_w32_256x192.yml) |
2525
| HRNet-w32+DarkPose | 384x288 | 78.3 | [dark_hrnet_w32_384x288.pdparams](https://paddledet.bj.bcebos.com/models/keypoint/dark_hrnet_w32_384x288.pdparams) | [config](./hrnet/dark_hrnet_w32_384x288.yml) |
26+
| WiderNaiveHRNet-18 | 256x192 | 67.6(+DARK 68.4) | [wider_naive_hrnet_18_256x192_coco.pdparams](https://bj.bcebos.com/v1/paddledet/models/keypoint/wider_naive_hrnet_18_256x192_coco.pdparams) | [config](./lite_hrnet/wider_naive_hrnet_18_256x192_coco.yml) |
2627
| LiteHRNet-18 | 256x192 | 66.5 | [lite_hrnet_18_256x192_coco.pdparams](https://bj.bcebos.com/v1/paddledet/models/keypoint/lite_hrnet_18_256x192_coco.pdparams) | [config](./lite_hrnet/lite_hrnet_18_256x192_coco.yml) |
2728
| LiteHRNet-18 | 384x288 | 69.7 | [lite_hrnet_18_384x288_coco.pdparams](https://bj.bcebos.com/v1/paddledet/models/keypoint/lite_hrnet_18_384x288_coco.pdparams) | [config](./lite_hrnet/lite_hrnet_18_384x288_coco.yml) |
2829
| LiteHRNet-30 | 256x192 | 69.4 | [lite_hrnet_30_256x192_coco.pdparams](https://bj.bcebos.com/v1/paddledet/models/keypoint/lite_hrnet_30_256x192_coco.pdparams) | [config](./lite_hrnet/lite_hrnet_30_256x192_coco.yml) |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
use_gpu: true
2+
log_iter: 5
3+
save_dir: output
4+
snapshot_epoch: 10
5+
weights: output/wider_naive_hrnet_18_256x192_coco/model_final
6+
epoch: 210
7+
num_joints: &num_joints 17
8+
pixel_std: &pixel_std 200
9+
metric: KeyPointTopDownCOCOEval
10+
num_classes: 1
11+
train_height: &train_height 256
12+
train_width: &train_width 192
13+
trainsize: &trainsize [*train_width, *train_height]
14+
hmsize: &hmsize [48, 64]
15+
flip_perm: &flip_perm [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]
16+
17+
18+
#####model
19+
architecture: TopDownHRNet
20+
21+
TopDownHRNet:
22+
backbone: LiteHRNet
23+
post_process: HRNetPostProcess
24+
flip_perm: *flip_perm
25+
num_joints: *num_joints
26+
width: &width 40
27+
loss: KeyPointMSELoss
28+
use_dark: false
29+
30+
LiteHRNet:
31+
network_type: wider_naive
32+
freeze_at: -1
33+
freeze_norm: false
34+
return_idx: [0]
35+
36+
KeyPointMSELoss:
37+
use_target_weight: true
38+
loss_scale: 1.0
39+
40+
#####optimizer
41+
LearningRate:
42+
base_lr: 0.002
43+
schedulers:
44+
- !PiecewiseDecay
45+
milestones: [170, 200]
46+
gamma: 0.1
47+
- !LinearWarmup
48+
start_factor: 0.001
49+
steps: 500
50+
51+
OptimizerBuilder:
52+
optimizer:
53+
type: Adam
54+
regularizer:
55+
factor: 0.0
56+
type: L2
57+
58+
59+
#####data
60+
TrainDataset:
61+
!KeypointTopDownCocoDataset
62+
image_dir: train2017
63+
anno_path: annotations/person_keypoints_train2017.json
64+
dataset_dir: dataset/coco
65+
num_joints: *num_joints
66+
trainsize: *trainsize
67+
pixel_std: *pixel_std
68+
use_gt_bbox: True
69+
70+
71+
EvalDataset:
72+
!KeypointTopDownCocoDataset
73+
image_dir: val2017
74+
anno_path: annotations/person_keypoints_val2017.json
75+
dataset_dir: dataset/coco
76+
num_joints: *num_joints
77+
trainsize: *trainsize
78+
pixel_std: *pixel_std
79+
use_gt_bbox: True
80+
image_thre: 0.0
81+
82+
83+
TestDataset:
84+
!ImageFolder
85+
anno_path: dataset/coco/keypoint_imagelist.txt
86+
87+
worker_num: 2
88+
global_mean: &global_mean [0.485, 0.456, 0.406]
89+
global_std: &global_std [0.229, 0.224, 0.225]
90+
TrainReader:
91+
sample_transforms:
92+
- RandomFlipHalfBodyTransform:
93+
scale: 0.25
94+
rot: 30
95+
num_joints_half_body: 8
96+
prob_half_body: 0.3
97+
pixel_std: *pixel_std
98+
trainsize: *trainsize
99+
upper_body_ids: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
100+
flip_pairs: *flip_perm
101+
- TopDownAffine:
102+
trainsize: *trainsize
103+
- ToHeatmapsTopDown:
104+
hmsize: *hmsize
105+
sigma: 2
106+
batch_transforms:
107+
- NormalizeImage:
108+
mean: *global_mean
109+
std: *global_std
110+
is_scale: true
111+
- Permute: {}
112+
batch_size: 64
113+
shuffle: true
114+
drop_last: false
115+
116+
EvalReader:
117+
sample_transforms:
118+
- TopDownAffine:
119+
trainsize: *trainsize
120+
batch_transforms:
121+
- NormalizeImage:
122+
mean: *global_mean
123+
std: *global_std
124+
is_scale: true
125+
- Permute: {}
126+
batch_size: 16
127+
128+
TestReader:
129+
inputs_def:
130+
image_shape: [3, *train_height, *train_width]
131+
sample_transforms:
132+
- Decode: {}
133+
- TopDownEvalAffine:
134+
trainsize: *trainsize
135+
- NormalizeImage:
136+
mean: *global_mean
137+
std: *global_std
138+
is_scale: true
139+
- Permute: {}
140+
batch_size: 1

ppdet/modeling/backbones/lite_hrnet.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def __init__(self,
271271
norm_decay=0.):
272272
super(ShuffleUnit, self).__init__()
273273
branch_channel = out_channel // 2
274-
stride = self.stride
274+
self.stride = stride
275275
if self.stride == 1:
276276
assert (
277277
in_channel == branch_channel * 2,
@@ -544,11 +544,11 @@ def _make_weighting_blocks(self,
544544
norm_decay=norm_decay))
545545
return nn.Sequential(*layers)
546546

547-
def _make_naive_branchs(self,
548-
num_branches,
549-
num_blocks,
550-
freeze_norm=False,
551-
norm_decay=0.):
547+
def _make_naive_branches(self,
548+
num_branches,
549+
num_blocks,
550+
freeze_norm=False,
551+
norm_decay=0.):
552552
branches = []
553553
for branch_idx in range(num_branches):
554554
layers = []
@@ -644,7 +644,7 @@ def forward(self, x):
644644
out = self.layers(x)
645645
elif self.module_type == 'NAIVE':
646646
for i in range(self.num_branches):
647-
x[i] = self.layers(x[i])
647+
x[i] = self.layers[i](x[i])
648648
out = x
649649
if self.with_fuse:
650650
out_fuse = []

0 commit comments

Comments
 (0)