Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Bug fixes in data converters and transforms #69

Merged
merged 15 commits into from Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions mmhuman3d/data/data_converters/agora.py
Expand Up @@ -105,7 +105,7 @@ def convert_by_mode(self, dataset_path: str, out_path: str,
for idx in tqdm(range(len(df))):
imgname = df.iloc[idx]['imgPath']
if self.res == (1280, 720):
imgname.replace('.png', '_1280x720.png')
imgname = imgname.replace('.png', '_1280x720.png')
img_path = os.path.join('images', mode, imgname)
valid_pers_idx = np.where(df.iloc[idx].at['isValid'])[0]
for pidx in valid_pers_idx:
Expand All @@ -118,7 +118,7 @@ def convert_by_mode(self, dataset_path: str, out_path: str,

# obtain keypoints
keypoints2d = df.iloc[idx]['gt_joints_2d'][pidx]
if self.res == '1280x720':
if self.res == (1280, 720):
keypoints2d *= (720 / 2160)
keypoints3d = df.iloc[idx]['gt_joints_3d'][pidx]

Expand Down
15 changes: 8 additions & 7 deletions mmhuman3d/data/data_converters/posetrack.py
Expand Up @@ -49,23 +49,24 @@ def convert_by_mode(self, dataset_path: str, out_path: str,
for ann_file in tqdm(ann_files):
json_data = mmcv.load(ann_file)

counter = 0
for im, ann in zip(json_data['images'], json_data['annotations']):
# sample every 10 image and check image is labelled
if counter % 10 != 0 and not im['is_labeled']:
continue
imgs = {}
for img in json_data['images']:
imgs[img['id']] = img

for ann in json_data['annotations']:
image_id = ann['image_id']
image_path = str(imgs[image_id]['file_name'])

keypoints2d = np.array(ann['keypoints']).reshape(17, 3)
keypoints2d[keypoints2d[:, 2] > 0, 2] = 1
# check if all major body joints are annotated
if sum(keypoints2d[5:, 2] > 0) < 12:
continue

image_path = im['file_name']
image_abs_path = os.path.join(dataset_path, image_path)
if not os.path.exists(image_abs_path):
print('{} does not exist!'.format(image_abs_path))
continue
counter += 1
bbox_xywh = np.array(ann['bbox'])

# store data
Expand Down
2 changes: 1 addition & 1 deletion mmhuman3d/data/data_converters/surreal.py
Expand Up @@ -184,10 +184,10 @@ def convert_by_mode(self, dataset_path: str, out_path: str,
success, image = vidcap.read()
if not success:
break
frame += 1
# image name
imgname = os.path.join(img_dir,
'frame_%06d.jpg' % frame)
frame += 1
# save image
cv2.imwrite(imgname, image)

Expand Down