未验证 提交 e6324fd5 编写于 作者: Z zhiboniu 提交者: GitHub

adapted between higherhrnet and petr (#7840)

* new adapted

* test ok
上级 bec57bcf
...@@ -66,6 +66,9 @@ TrainDataset: ...@@ -66,6 +66,9 @@ TrainDataset:
anno_path: annotations/person_keypoints_train2017.json anno_path: annotations/person_keypoints_train2017.json
dataset_dir: dataset/coco dataset_dir: dataset/coco
num_joints: *num_joints num_joints: *num_joints
return_bbox: False
return_area: False
return_class: False
EvalDataset: EvalDataset:
!KeypointBottomUpCocoDataset !KeypointBottomUpCocoDataset
...@@ -74,6 +77,9 @@ EvalDataset: ...@@ -74,6 +77,9 @@ EvalDataset:
dataset_dir: dataset/coco dataset_dir: dataset/coco
num_joints: *num_joints num_joints: *num_joints
test_mode: true test_mode: true
return_bbox: False
return_area: False
return_class: False
TestDataset: TestDataset:
!ImageFolder !ImageFolder
...@@ -88,7 +94,7 @@ TrainReader: ...@@ -88,7 +94,7 @@ TrainReader:
max_degree: 30 max_degree: 30
scale: [0.75, 1.5] scale: [0.75, 1.5]
max_shift: 0.2 max_shift: 0.2
trainsize: *input_size trainsize: [*input_size, *input_size]
hmsize: [*hm_size, *hm_size_2x] hmsize: [*hm_size, *hm_size_2x]
- KeyPointFlip: - KeyPointFlip:
flip_prob: 0.5 flip_prob: 0.5
......
...@@ -67,6 +67,9 @@ TrainDataset: ...@@ -67,6 +67,9 @@ TrainDataset:
anno_path: annotations/person_keypoints_train2017.json anno_path: annotations/person_keypoints_train2017.json
dataset_dir: dataset/coco dataset_dir: dataset/coco
num_joints: *num_joints num_joints: *num_joints
return_bbox: False
return_area: False
return_class: False
EvalDataset: EvalDataset:
!KeypointBottomUpCocoDataset !KeypointBottomUpCocoDataset
...@@ -75,6 +78,9 @@ EvalDataset: ...@@ -75,6 +78,9 @@ EvalDataset:
dataset_dir: dataset/coco dataset_dir: dataset/coco
num_joints: *num_joints num_joints: *num_joints
test_mode: true test_mode: true
return_bbox: False
return_area: False
return_class: False
TestDataset: TestDataset:
!ImageFolder !ImageFolder
...@@ -89,7 +95,7 @@ TrainReader: ...@@ -89,7 +95,7 @@ TrainReader:
max_degree: 30 max_degree: 30
scale: [0.75, 1.5] scale: [0.75, 1.5]
max_shift: 0.2 max_shift: 0.2
trainsize: *input_size trainsize: [*input_size, *input_size]
hmsize: [*hm_size, *hm_size_2x] hmsize: [*hm_size, *hm_size_2x]
- KeyPointFlip: - KeyPointFlip:
flip_prob: 0.5 flip_prob: 0.5
......
...@@ -66,6 +66,9 @@ TrainDataset: ...@@ -66,6 +66,9 @@ TrainDataset:
anno_path: annotations/person_keypoints_train2017.json anno_path: annotations/person_keypoints_train2017.json
dataset_dir: dataset/coco dataset_dir: dataset/coco
num_joints: *num_joints num_joints: *num_joints
return_bbox: False
return_area: False
return_class: False
EvalDataset: EvalDataset:
!KeypointBottomUpCocoDataset !KeypointBottomUpCocoDataset
...@@ -74,12 +77,15 @@ EvalDataset: ...@@ -74,12 +77,15 @@ EvalDataset:
dataset_dir: dataset/coco dataset_dir: dataset/coco
num_joints: *num_joints num_joints: *num_joints
test_mode: true test_mode: true
return_bbox: False
return_area: False
return_class: False
TestDataset: TestDataset:
!ImageFolder !ImageFolder
anno_path: dataset/coco/keypoint_imagelist.txt anno_path: dataset/coco/keypoint_imagelist.txt
worker_num: 0 worker_num: 8
global_mean: &global_mean [0.485, 0.456, 0.406] global_mean: &global_mean [0.485, 0.456, 0.406]
global_std: &global_std [0.229, 0.224, 0.225] global_std: &global_std [0.229, 0.224, 0.225]
TrainReader: TrainReader:
...@@ -88,7 +94,7 @@ TrainReader: ...@@ -88,7 +94,7 @@ TrainReader:
max_degree: 30 max_degree: 30
scale: [0.75, 1.5] scale: [0.75, 1.5]
max_shift: 0.2 max_shift: 0.2
trainsize: *input_size trainsize: [*input_size, *input_size]
hmsize: [*hm_size, *hm_size_2x] hmsize: [*hm_size, *hm_size_2x]
- KeyPointFlip: - KeyPointFlip:
flip_prob: 0.5 flip_prob: 0.5
......
...@@ -245,8 +245,7 @@ EvalReader: ...@@ -245,8 +245,7 @@ EvalReader:
TestReader: TestReader:
sample_transforms: sample_transforms:
- Decode: {} - Decode: {}
- EvalAffine: - EvalAffine: {size: 800}
size: *trainsize
- NormalizeImage: - NormalizeImage:
mean: *global_mean mean: *global_mean
std: *global_std std: *global_std
......
...@@ -76,7 +76,7 @@ class KeyPointFlip(object): ...@@ -76,7 +76,7 @@ class KeyPointFlip(object):
''' '''
records['gt_joints'] is Sequence in higherhrnet records['gt_joints'] is Sequence in higherhrnet
''' '''
if not ('gt_joints' in records and records['gt_joints'].size > 0): if not ('gt_joints' in records and len(records['gt_joints']) > 0):
return records return records
kpts_lst = records['gt_joints'] kpts_lst = records['gt_joints']
...@@ -147,7 +147,7 @@ class RandomAffine(object): ...@@ -147,7 +147,7 @@ class RandomAffine(object):
max_scale (list[2]): the scale range to apply, transform range is [min, max] max_scale (list[2]): the scale range to apply, transform range is [min, max]
max_shift (float): the max abslute shift ratio to apply, transform range is [-max_shift*imagesize, max_shift*imagesize] max_shift (float): the max abslute shift ratio to apply, transform range is [-max_shift*imagesize, max_shift*imagesize]
hmsize (list[2]): output heatmap's shape list of different scale outputs of higherhrnet hmsize (list[2]): output heatmap's shape list of different scale outputs of higherhrnet
trainsize (int): the standard length used to train, the 'scale_type' of [h,w] will be resize to trainsize for standard trainsize (list[2]): the standard length used to train, the 'scale_type' of [h,w] will be resize to trainsize for standard
scale_type (str): the length of [h,w] to used for trainsize, chosed between 'short' and 'long' scale_type (str): the length of [h,w] to used for trainsize, chosed between 'short' and 'long'
records(dict): the dict contained the image, mask and coords records(dict): the dict contained the image, mask and coords
...@@ -161,7 +161,7 @@ class RandomAffine(object): ...@@ -161,7 +161,7 @@ class RandomAffine(object):
scale=[0.75, 1.5], scale=[0.75, 1.5],
max_shift=0.2, max_shift=0.2,
hmsize=None, hmsize=None,
trainsize=512, trainsize=[512, 512],
scale_type='short', scale_type='short',
boldervalue=[114, 114, 114]): boldervalue=[114, 114, 114]):
super(RandomAffine, self).__init__() super(RandomAffine, self).__init__()
...@@ -304,7 +304,7 @@ class RandomAffine(object): ...@@ -304,7 +304,7 @@ class RandomAffine(object):
input_size = 2 * center input_size = 2 * center
if self.trainsize != -1: if self.trainsize != -1:
dsize = self.trainsize dsize = self.trainsize
imgshape = (dsize, dsize) imgshape = (dsize)
else: else:
dsize = scale dsize = scale
imgshape = (shape.tolist()) imgshape = (shape.tolist())
...@@ -379,6 +379,7 @@ class EvalAffine(object): ...@@ -379,6 +379,7 @@ class EvalAffine(object):
if 'gt_joints' in records: if 'gt_joints' in records:
del records['gt_joints'] del records['gt_joints']
records['image'] = image_resized records['image'] = image_resized
records['scale_factor'] = self.size / min(h, w)
return records return records
...@@ -1574,14 +1575,13 @@ class PETR_Resize: ...@@ -1574,14 +1575,13 @@ class PETR_Resize:
dict: Resized results, 'im_shape', 'pad_shape', 'scale_factor', \ dict: Resized results, 'im_shape', 'pad_shape', 'scale_factor', \
'keep_ratio' keys are added into result dict. 'keep_ratio' keys are added into result dict.
""" """
if 'scale' not in results: if 'scale' not in results:
if 'scale_factor' in results: if 'scale_factor' in results:
img_shape = results['image'].shape[:2] img_shape = results['image'].shape[:2]
scale_factor = results['scale_factor'] scale_factor = results['scale_factor'][0]
assert isinstance(scale_factor, float) # assert isinstance(scale_factor, float)
results['scale'] = tuple( results['scale'] = [int(x * scale_factor)
[int(x * scale_factor) for x in img_shape][::-1]) for x in img_shape][::-1]
else: else:
self._random_scale(results) self._random_scale(results)
else: else:
......
...@@ -238,7 +238,7 @@ def draw_pose(image, ...@@ -238,7 +238,7 @@ def draw_pose(image,
'for example: `pip install matplotlib`.') 'for example: `pip install matplotlib`.')
raise e raise e
skeletons = np.array([item['keypoints'] for item in results]).reshape((-1, 51)) skeletons = np.array([item['keypoints'] for item in results])
kpt_nums = 17 kpt_nums = 17
if len(skeletons) > 0: if len(skeletons) > 0:
kpt_nums = int(skeletons.shape[1] / 3) kpt_nums = int(skeletons.shape[1] / 3)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册