-
Notifications
You must be signed in to change notification settings - Fork 1
/
reorder_smpl_files.py
64 lines (45 loc) · 1.94 KB
/
reorder_smpl_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'''
Reorder/Rename human images and smple params into original viton names
(c) 2019 Matiur Rahman Minar and Heejune Ahn @ icomlab.seoutech.ac.kr
Description
============
'''
import os
import sys
import numpy as np
def reorder_human_images(list_file, image_dir):
image_names = os.listdir(image_dir)
# pf = open(list_file)
filenp = np.load(list_file)
for each in zip(image_names, filenp):
src_path = image_dir + each[0]
dst_path = image_dir + each[1].split(" ")[0]
os.rename(src_path, dst_path)
print("Converting " + each[0] + " to " + each[1].split(" ")[0])
def reorder_smpl_params(list_file, smpl_dir):
# all_files = os.listdir(smpl_dir)
# pf = open(list_file)
filenp = np.load(list_file)
count = 0
# for each in pf.readlines():
for each in filenp:
fname = str(each.decode("utf-8"))
src_smpl_path = os.path.join(smpl_dir + '%04d.pkl' % count)
dst_smpl_path = os.path.join(smpl_dir + fname.split(" ")[0].replace(".jpg", ".pkl"))
os.rename(src_smpl_path, dst_smpl_path)
src_image_path = os.path.join(smpl_dir + '%04d.png' % count)
dst_image_path = os.path.join(smpl_dir + fname.split(" ")[0].replace(".jpg", ".png"))
os.rename(src_image_path, dst_image_path)
print("Converting " + src_smpl_path + " to " + fname.split(" ")[0].replace(".jpg", ".pkl"))
count = count + 1
if __name__ =='__main__':
if len(sys.argv) < 3:
print('usage: %s listnpyfile smpldir' % sys.argv[0])
exit()
# list_file = "test_pairs.txt" # viton original test pairs file
list_file = "list.npy" # viton original test files names' list
# image_dir = "./images/viton/" # human images directory path
smpl_dir = "./results/viton/smpl/" # saved smpl parameters directory path
# ============Re-order===========
# reorder_human_images(list_file, image_dir)
reorder_smpl_params(list_file, smpl_dir)