-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_poses.py
205 lines (182 loc) · 4.51 KB
/
generate_poses.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import pose
import fist_pose
import argparse
import os
MODELS_DIR = "models"
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--input-path",
type=str,
default="../input",
help="Path to the input directory"
)
parser.add_argument(
"--pose-estimation-model-path",
type=str,
default=f"./{MODELS_DIR}/hrn_w48_384x288.onnx",
help="Pose Estimation model",
)
parser.add_argument(
"--contact-model-path",
type=str,
default=f"./{MODELS_DIR}/contact_hrn_w32_256x192.onnx",
help="Contact model",
)
parser.add_argument(
"--device",
type=str,
default="cuda",
choices=["cpu", "cuda"],
help="Torch device",
)
parser.add_argument(
"--spin-model-path",
type=str,
default=f"./{MODELS_DIR}/spin_model_smplx_eft_18.pt",
help="SPIN model path",
)
parser.add_argument(
"--smpl-type",
type=str,
default="smplx",
choices=["smplx"],
help="SMPL model type",
)
parser.add_argument(
"--smpl-model-dir",
type=str,
default=f"./{MODELS_DIR}/models/smplx",
help="SMPL model dir",
)
parser.add_argument(
"--smpl-mean-params-path",
type=str,
default=f"./{MODELS_DIR}/data/smpl_mean_params.npz",
help="SMPL mean params",
)
parser.add_argument(
"--essentials-dir",
type=str,
default=f"./{MODELS_DIR}/smplify-xmc-essentials",
help="SMPL Essentials folder for contacts",
)
parser.add_argument(
"--parametrization-path",
type=str,
default=f"./{MODELS_DIR}/smplx_parametrization/parametrization.npy",
help="Parametrization path",
)
parser.add_argument(
"--bone-parametrization-path",
type=str,
default=f"./{MODELS_DIR}/smplx_parametrization/bone_to_param2.npy",
help="Bone parametrization path",
)
parser.add_argument(
"--foot-inds-path",
type=str,
default=f"./{MODELS_DIR}/smplx_parametrization/foot_inds.npy",
help="Foot indinces",
)
parser.add_argument(
"--save-path",
type=str,
help="Path to save the results",
)
parser.add_argument(
"--img-path",
type=str,
help="Path to img to test",
)
parser.add_argument(
"--use-contacts",
action="store_true",
help="Use contact model",
)
parser.add_argument(
"--use-msc",
action="store_true",
help="Use MSC loss",
)
parser.add_argument(
"--use-natural",
action="store_true",
help="Use regularity",
)
parser.add_argument(
"--use-cos",
action="store_true",
help="Use cos model",
)
parser.add_argument(
"--use-angle-transf",
action="store_true",
help="Use cube foreshortening transformation",
)
parser.add_argument(
"--c-mse",
type=float,
default=0,
help="MSE weight",
)
parser.add_argument(
"--c-par",
type=float,
default=10,
help="Parallel weight",
)
parser.add_argument(
"--c-f",
type=float,
default=1000,
help="Cos coef",
)
parser.add_argument(
"--c-parallel",
type=float,
default=100,
help="Parallel weight",
)
parser.add_argument(
"--c-reg",
type=float,
default=1000,
help="Regularity weight",
)
parser.add_argument(
"--c-cont2d",
type=float,
default=1,
help="Contact 2D weight",
)
parser.add_argument(
"--c-msc",
type=float,
default=17_500,
help="MSC weight",
)
parser.add_argument(
"--fist",
nargs="+",
type=str,
choices=list(fist_pose.INT_TO_FIST),
)
args = parser.parse_args()
return args
def main(args):
path = args.input_path
args.use_contacts = True
args.use_natural = True
args.use_cos = True
args.use_angle_transf = True
for dirname in os.listdir(path):
if not os.path.isdir(os.path.join(path, dirname)):
continue
print(f'Processing {dirname}')
args.img_path = os.path.join(path, dirname)
args.save_path = os.path.join(path, dirname, 'pose_output')
pose.main(args)
if __name__ == '__main__':
args = parse_args()
main(args)