kbrodt commited on
Commit
00074b2
1 Parent(s): 3680899

Upload constants.py

Browse files
Files changed (1) hide show
  1. src/spin/constants.py +272 -0
src/spin/constants.py ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FOCAL_LENGTH = 5000.0
2
+ IMG_RES = 224
3
+
4
+ # Mean and standard deviation for normalizing input image
5
+ IMG_NORM_MEAN = [0.485, 0.456, 0.406]
6
+ IMG_NORM_STD = [0.229, 0.224, 0.225]
7
+
8
+ """
9
+ We create a superset of joints containing the OpenPose joints together with the ones that each dataset provides.
10
+ We keep a superset of 24 joints such that we include all joints from every dataset.
11
+ If a dataset doesn't provide annotations for a specific joint, we simply ignore it.
12
+ The joints used here are the following:
13
+ """
14
+ JOINT_NAMES = (
15
+ "Hips",
16
+ "Left Upper Leg",
17
+ "Right Upper Leg",
18
+ "Spine",
19
+ "Left Leg",
20
+ "Right Leg",
21
+ "Spine1",
22
+ "Left Foot",
23
+ "Right Foot",
24
+ "Thorax",
25
+ "Left Toe",
26
+ "Right Toe",
27
+ "Neck",
28
+ "Left Shoulder",
29
+ "Right Shoulder",
30
+ "Head",
31
+ "Left ForeArm",
32
+ "Right ForeArm",
33
+ "Left Arm",
34
+ "Right Arm",
35
+ "Left Hand",
36
+ "Right Hand",
37
+ # 25 OpenPose joints (in the order provided by OpenPose)
38
+ # "OP Nose",
39
+ # "OP Neck",
40
+ # "OP RShoulder",
41
+ # "OP RElbow",
42
+ # "OP RWrist",
43
+ # "OP LShoulder",
44
+ # "OP LElbow",
45
+ # "OP LWrist",
46
+ # "OP MidHip",
47
+ # "OP RHip",
48
+ # "OP RKnee",
49
+ # "OP RAnkle",
50
+ # "OP LHip",
51
+ # "OP LKnee",
52
+ # "OP LAnkle",
53
+ # "OP REye",
54
+ # "OP LEye",
55
+ # "OP REar",
56
+ # "OP LEar",
57
+ # "OP LBigToe",
58
+ # "OP LSmallToe",
59
+ # "OP LHeel",
60
+ # "OP RBigToe",
61
+ # "OP RSmallToe",
62
+ # "OP RHeel",
63
+ ## 24 Ground Truth joints (superset of joints from different datasets)
64
+ # "Right Ankle",
65
+ # "Right Knee",
66
+ # "Right Hip",
67
+ # "Left Hip",
68
+ # "Left Knee",
69
+ # "Left Ankle",
70
+ # "Right Wrist",
71
+ # "Right Elbow",
72
+ # "Right Shoulder",
73
+ # "Left Shoulder",
74
+ # "Left Elbow",
75
+ # "Left Wrist",
76
+ # "Neck (LSP)",
77
+ # "Top of Head (LSP)",
78
+ # "Pelvis (MPII)",
79
+ # "Thorax (MPII)",
80
+ # "Spine (H36M)",
81
+ # "Jaw (H36M)",
82
+ # "Head (H36M)",
83
+ # "Nose",
84
+ # "Left Eye",
85
+ # "Right Eye",
86
+ # "Left Ear",
87
+ # "Right Ear",
88
+ # "OP MidHip",
89
+ # "Spine1",
90
+ # "Spine2",
91
+ # "Spine3",
92
+ # "OP Neck",
93
+ # "Head",
94
+ )
95
+
96
+ # Dict containing the joints in numerical order
97
+ JOINT_IDS = {JOINT_NAMES[i]: i for i in range(len(JOINT_NAMES))}
98
+
99
+ # Map joints to SMPL joints
100
+ JOINT_MAP = {
101
+ "Hips": 0,
102
+ "Left Upper Leg": 1,
103
+ "Right Upper Leg": 2,
104
+ "Spine": 3,
105
+ "Left Leg": 4,
106
+ "Right Leg": 5,
107
+ "Spine1": 6,
108
+ "Left Foot": 7,
109
+ "Right Foot": 8,
110
+ "Thorax": 9,
111
+ "Left Toe": 10,
112
+ "Right Toe": 11,
113
+ "Neck": 12,
114
+ "Left Shoulder": 13,
115
+ "Right Shoulder": 14,
116
+ "Head": 15,
117
+ "Left ForeArm": 16,
118
+ "Right ForeArm": 17,
119
+ "Left Arm": 18,
120
+ "Right Arm": 19,
121
+ "Left Hand": 20,
122
+ "Right Hand": 21,
123
+ # "OP Nose": 24,
124
+ # "OP Neck": 12,
125
+ # "OP RShoulder": 17,
126
+ # "OP RElbow": 19,
127
+ # "OP RWrist": 21,
128
+ # "OP LShoulder": 16,
129
+ # "OP LElbow": 18,
130
+ # "OP LWrist": 20,
131
+ # "OP MidHip": 0,
132
+ # "OP RHip": 2,
133
+ # "OP RKnee": 5,
134
+ # "OP RAnkle": 8,
135
+ # "OP LHip": 1,
136
+ # "OP LKnee": 4,
137
+ # "OP LAnkle": 7,
138
+ # "OP REye": 25,
139
+ # "OP LEye": 26,
140
+ # "OP REar": 27,
141
+ # "OP LEar": 28,
142
+ # "OP LBigToe": 29,
143
+ # "OP LSmallToe": 30,
144
+ # "OP LHeel": 31,
145
+ # "OP RBigToe": 32,
146
+ # "OP RSmallToe": 33,
147
+ # "OP RHeel": 34,
148
+ # "Right Ankle": 8,
149
+ # "Right Knee": 5,
150
+ # "Right Hip": 45,
151
+ # "Left Hip": 46,
152
+ # "Left Knee": 4,
153
+ # "Left Ankle": 7,
154
+ # "Right Wrist": 21,
155
+ # "Right Elbow": 19,
156
+ # "Right Shoulder": 17,
157
+ # "Left Shoulder": 16,
158
+ # "Left Elbow": 18,
159
+ # "Left Wrist": 20,
160
+ # "Neck (LSP)": 47,
161
+ # "Top of Head (LSP)": 15, # 48,
162
+ # "Pelvis (MPII)": 49,
163
+ # "Thorax (MPII)": 50,
164
+ # "Spine (H36M)": 51,
165
+ # "Jaw (H36M)": 52,
166
+ # "Head (H36M)": 15, # 53,
167
+ # "Nose": 24,
168
+ # "Left Eye": 26,
169
+ # "Right Eye": 25,
170
+ # "Left Ear": 28,
171
+ # "Right Ear": 27,
172
+ # "Spine1": 3,
173
+ # "Spine2": 6,
174
+ # "Spine3": 9,
175
+ # "Head": 15,
176
+ }
177
+
178
+ # Joint selectors
179
+ # Indices to get the 14 LSP joints from the 17 H36M joints
180
+ H36M_TO_J17 = [6, 5, 4, 1, 2, 3, 16, 15, 14, 11, 12, 13, 8, 10, 0, 7, 9]
181
+ H36M_TO_J14 = H36M_TO_J17[:14]
182
+ # Indices to get the 14 LSP joints from the ground truth joints
183
+ J24_TO_J17 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 18, 14, 16, 17]
184
+ J24_TO_J14 = J24_TO_J17[:14]
185
+
186
+ # Permutation of SMPL pose parameters when flipping the shape
187
+ SMPL_JOINTS_FLIP_PERM = [
188
+ 0,
189
+ 2,
190
+ 1,
191
+ 3,
192
+ 5,
193
+ 4,
194
+ 6,
195
+ 8,
196
+ 7,
197
+ 9,
198
+ 11,
199
+ 10,
200
+ 12,
201
+ 14,
202
+ 13,
203
+ 15,
204
+ 17,
205
+ 16,
206
+ 19,
207
+ 18,
208
+ 21,
209
+ 20,
210
+ 23,
211
+ 22,
212
+ ]
213
+ SMPL_POSE_FLIP_PERM = []
214
+ for i in SMPL_JOINTS_FLIP_PERM:
215
+ SMPL_POSE_FLIP_PERM.append(3 * i)
216
+ SMPL_POSE_FLIP_PERM.append(3 * i + 1)
217
+ SMPL_POSE_FLIP_PERM.append(3 * i + 2)
218
+ # Permutation indices for the 24 ground truth joints
219
+ J24_FLIP_PERM = [
220
+ 5,
221
+ 4,
222
+ 3,
223
+ 2,
224
+ 1,
225
+ 0,
226
+ 11,
227
+ 10,
228
+ 9,
229
+ 8,
230
+ 7,
231
+ 6,
232
+ 12,
233
+ 13,
234
+ 14,
235
+ 15,
236
+ 16,
237
+ 17,
238
+ 18,
239
+ 19,
240
+ 21,
241
+ 20,
242
+ 23,
243
+ 22,
244
+ ]
245
+ # Permutation indices for the full set of 49 joints
246
+ J49_FLIP_PERM = [
247
+ 0,
248
+ 1,
249
+ 5,
250
+ 6,
251
+ 7,
252
+ 2,
253
+ 3,
254
+ 4,
255
+ 8,
256
+ 12,
257
+ 13,
258
+ 14,
259
+ 9,
260
+ 10,
261
+ 11,
262
+ 16,
263
+ 15,
264
+ 18,
265
+ 17,
266
+ 22,
267
+ 23,
268
+ 24,
269
+ 19,
270
+ 20,
271
+ 21,
272
+ ] + [25 + i for i in J24_FLIP_PERM]