Skip to content

Commit 5984726

Browse files
authored
adapted between higherhrnet and petr (#7839)
* new adapted * test ok
1 parent c15cdb4 commit 5984726

File tree

6 files changed

+33
-16
lines changed

6 files changed

+33
-16
lines changed

configs/keypoint/higherhrnet/higherhrnet_hrnet_w32_512.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ TrainDataset:
6666
anno_path: annotations/person_keypoints_train2017.json
6767
dataset_dir: dataset/coco
6868
num_joints: *num_joints
69+
return_bbox: False
70+
return_area: False
71+
return_class: False
6972

7073
EvalDataset:
7174
!KeypointBottomUpCocoDataset
@@ -74,6 +77,9 @@ EvalDataset:
7477
dataset_dir: dataset/coco
7578
num_joints: *num_joints
7679
test_mode: true
80+
return_bbox: False
81+
return_area: False
82+
return_class: False
7783

7884
TestDataset:
7985
!ImageFolder
@@ -88,7 +94,7 @@ TrainReader:
8894
max_degree: 30
8995
scale: [0.75, 1.5]
9096
max_shift: 0.2
91-
trainsize: *input_size
97+
trainsize: [*input_size, *input_size]
9298
hmsize: [*hm_size, *hm_size_2x]
9399
- KeyPointFlip:
94100
flip_prob: 0.5

configs/keypoint/higherhrnet/higherhrnet_hrnet_w32_512_swahr.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ TrainDataset:
6767
anno_path: annotations/person_keypoints_train2017.json
6868
dataset_dir: dataset/coco
6969
num_joints: *num_joints
70+
return_bbox: False
71+
return_area: False
72+
return_class: False
7073

7174
EvalDataset:
7275
!KeypointBottomUpCocoDataset
@@ -75,6 +78,9 @@ EvalDataset:
7578
dataset_dir: dataset/coco
7679
num_joints: *num_joints
7780
test_mode: true
81+
return_bbox: False
82+
return_area: False
83+
return_class: False
7884

7985
TestDataset:
8086
!ImageFolder
@@ -89,7 +95,7 @@ TrainReader:
8995
max_degree: 30
9096
scale: [0.75, 1.5]
9197
max_shift: 0.2
92-
trainsize: *input_size
98+
trainsize: [*input_size, *input_size]
9399
hmsize: [*hm_size, *hm_size_2x]
94100
- KeyPointFlip:
95101
flip_prob: 0.5

configs/keypoint/higherhrnet/higherhrnet_hrnet_w32_640.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ TrainDataset:
6666
anno_path: annotations/person_keypoints_train2017.json
6767
dataset_dir: dataset/coco
6868
num_joints: *num_joints
69+
return_bbox: False
70+
return_area: False
71+
return_class: False
6972

7073
EvalDataset:
7174
!KeypointBottomUpCocoDataset
@@ -74,12 +77,15 @@ EvalDataset:
7477
dataset_dir: dataset/coco
7578
num_joints: *num_joints
7679
test_mode: true
80+
return_bbox: False
81+
return_area: False
82+
return_class: False
7783

7884
TestDataset:
7985
!ImageFolder
8086
anno_path: dataset/coco/keypoint_imagelist.txt
8187

82-
worker_num: 0
88+
worker_num: 8
8389
global_mean: &global_mean [0.485, 0.456, 0.406]
8490
global_std: &global_std [0.229, 0.224, 0.225]
8591
TrainReader:
@@ -88,7 +94,7 @@ TrainReader:
8894
max_degree: 30
8995
scale: [0.75, 1.5]
9096
max_shift: 0.2
91-
trainsize: *input_size
97+
trainsize: [*input_size, *input_size]
9298
hmsize: [*hm_size, *hm_size_2x]
9399
- KeyPointFlip:
94100
flip_prob: 0.5

configs/keypoint/petr/petr_resnet50_16x2_coco.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ EvalReader:
245245
TestReader:
246246
sample_transforms:
247247
- Decode: {}
248-
- EvalAffine:
249-
size: *trainsize
248+
- EvalAffine: {size: 800}
250249
- NormalizeImage:
251250
mean: *global_mean
252251
std: *global_std

ppdet/data/transform/keypoint_operators.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _flipjoints(self, records, sizelst):
7676
'''
7777
records['gt_joints'] is Sequence in higherhrnet
7878
'''
79-
if not ('gt_joints' in records and records['gt_joints'].size > 0):
79+
if not ('gt_joints' in records and len(records['gt_joints']) > 0):
8080
return records
8181

8282
kpts_lst = records['gt_joints']
@@ -147,7 +147,7 @@ class RandomAffine(object):
147147
max_scale (list[2]): the scale range to apply, transform range is [min, max]
148148
max_shift (float): the max abslute shift ratio to apply, transform range is [-max_shift*imagesize, max_shift*imagesize]
149149
hmsize (list[2]): output heatmap's shape list of different scale outputs of higherhrnet
150-
trainsize (int): the standard length used to train, the 'scale_type' of [h,w] will be resize to trainsize for standard
150+
trainsize (list[2]): the standard length used to train, the 'scale_type' of [h,w] will be resize to trainsize for standard
151151
scale_type (str): the length of [h,w] to used for trainsize, chosed between 'short' and 'long'
152152
records(dict): the dict contained the image, mask and coords
153153
@@ -161,7 +161,7 @@ def __init__(self,
161161
scale=[0.75, 1.5],
162162
max_shift=0.2,
163163
hmsize=None,
164-
trainsize=512,
164+
trainsize=[512, 512],
165165
scale_type='short',
166166
boldervalue=[114, 114, 114]):
167167
super(RandomAffine, self).__init__()
@@ -304,7 +304,7 @@ def __call__(self, records):
304304
input_size = 2 * center
305305
if self.trainsize != -1:
306306
dsize = self.trainsize
307-
imgshape = (dsize, dsize)
307+
imgshape = (dsize)
308308
else:
309309
dsize = scale
310310
imgshape = (shape.tolist())
@@ -379,6 +379,7 @@ def __call__(self, records):
379379
if 'gt_joints' in records:
380380
del records['gt_joints']
381381
records['image'] = image_resized
382+
records['scale_factor'] = self.size / min(h, w)
382383
return records
383384

384385

@@ -1574,14 +1575,13 @@ def __call__(self, results):
15741575
dict: Resized results, 'im_shape', 'pad_shape', 'scale_factor', \
15751576
'keep_ratio' keys are added into result dict.
15761577
"""
1577-
15781578
if 'scale' not in results:
15791579
if 'scale_factor' in results:
15801580
img_shape = results['image'].shape[:2]
1581-
scale_factor = results['scale_factor']
1582-
assert isinstance(scale_factor, float)
1583-
results['scale'] = tuple(
1584-
[int(x * scale_factor) for x in img_shape][::-1])
1581+
scale_factor = results['scale_factor'][0]
1582+
# assert isinstance(scale_factor, float)
1583+
results['scale'] = [int(x * scale_factor)
1584+
for x in img_shape][::-1]
15851585
else:
15861586
self._random_scale(results)
15871587
else:

ppdet/utils/visualizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def draw_pose(image,
238238
'for example: `pip install matplotlib`.')
239239
raise e
240240

241-
skeletons = np.array([item['keypoints'] for item in results]).reshape((-1, 51))
241+
skeletons = np.array([item['keypoints'] for item in results])
242242
kpt_nums = 17
243243
if len(skeletons) > 0:
244244
kpt_nums = int(skeletons.shape[1] / 3)

0 commit comments

Comments
 (0)