carsten12 commited on
Commit
0226e07
·
verified ·
1 Parent(s): 4a6ad07

Update joint_definitions.py

Browse files
Files changed (1) hide show
  1. joint_definitions.py +24 -123
joint_definitions.py CHANGED
@@ -1,123 +1,24 @@
1
- import smplx
2
- import torch
3
- import os
4
-
5
- #from https://meshcapade.wiki/SMPL
6
-
7
- SMPL_NUM_JOINTS = 24
8
-
9
- SMPL_IND2JOINT = {
10
- 0: 'pelvis',
11
- 1: 'left_hip',
12
- 2: 'right_hip',
13
- 3: 'spine1',
14
- 4: 'left_knee',
15
- 5: 'right_knee',
16
- 6: 'spine2',
17
- 7: 'left_ankle',
18
- 8: 'right_ankle',
19
- 9: 'spine3',
20
- 10: 'left_foot',
21
- 11: 'right_foot',
22
- 12: 'neck',
23
- 13: 'left_collar',
24
- 14: 'right_collar',
25
- 15: 'head',
26
- 16: 'left_shoulder',
27
- 17: 'right_shoulder',
28
- 18: 'left_elbow',
29
- 19: 'right_elbow',
30
- 20: 'left_wrist',
31
- 21: 'right_wrist',
32
- 22: 'left_hand',
33
- 23: 'right_hand'
34
- }
35
-
36
- SMPL_JOINT2IND = {name:ind for ind,name in SMPL_IND2JOINT.items()}
37
-
38
-
39
-
40
-
41
- SMPLX_NUM_JOINTS = 55
42
-
43
- SMPLX_IND2JOINT = {
44
- 0: 'pelvis',
45
- 1: 'left_hip',
46
- 2: 'right_hip',
47
- 3: 'spine1',
48
- 4: 'left_knee',
49
- 5: 'right_knee',
50
- 6: 'spine2',
51
- 7: 'left_ankle',
52
- 8: 'right_ankle',
53
- 9: 'spine3',
54
- 10: 'left_foot',
55
- 11: 'right_foot',
56
- 12: 'neck',
57
- 13: 'left_collar',
58
- 14: 'right_collar',
59
- 15: 'head',
60
- 16: 'left_shoulder',
61
- 17: 'right_shoulder',
62
- 18: 'left_elbow',
63
- 19: 'right_elbow',
64
- 20: 'left_wrist',
65
- 21: 'right_wrist',
66
- 22: 'jaw',
67
- 23: 'left_eye',
68
- 24: 'right_eye',
69
- 25: 'left_index1',
70
- 26: 'left_index2',
71
- 27: 'left_index3',
72
- 28: 'left_middle1',
73
- 29: 'left_middle2',
74
- 30: 'left_middle3',
75
- 31: 'left_pinky1',
76
- 32: 'left_pinky2',
77
- 33: 'left_pinky3',
78
- 34: 'left_ring1',
79
- 35: 'left_ring2',
80
- 36: 'left_ring3',
81
- 37: 'left_thumb1',
82
- 38: 'left_thumb2',
83
- 39: 'left_thumb3',
84
- 40: 'right_index1',
85
- 41: 'right_index2',
86
- 42: 'right_index3',
87
- 43: 'right_middle1',
88
- 44: 'right_middle2',
89
- 45: 'right_middle3',
90
- 46: 'right_pinky1',
91
- 47: 'right_pinky2',
92
- 48: 'right_pinky3',
93
- 49: 'right_ring1',
94
- 50: 'right_ring2',
95
- 51: 'right_ring3',
96
- 52: 'right_thumb1',
97
- 53: 'right_thumb2',
98
- 54: 'right_thumb3'
99
- }
100
-
101
- SMPLX_JOINT2IND = {name:ind for ind,name in SMPLX_IND2JOINT.items()}
102
-
103
- def get_joint_regressor(body_model_type, body_model_root, gender="MALE", num_thetas=24):
104
- '''
105
- Extract joint regressor from SMPL body model
106
- :param body_model_type: str of body model type (smpl or smplx, etc.)
107
- :param body_model_root: str of location of folders where smpl/smplx
108
- inside which .pkl models
109
-
110
- Return:
111
- :param model.J_regressor: torch.tensor (23,N) used to
112
- multiply with body model to get
113
- joint locations
114
- '''
115
-
116
- model = smplx.create(model_path=body_model_root,
117
- model_type=body_model_type,
118
- gender=gender,
119
- use_face_contour=False,
120
- num_betas=10,
121
- body_pose=torch.zeros((1, num_thetas-1 * 3)),
122
- ext='pkl')
123
- return model.J_regressor
 
1
+ # joint_definitions.py
2
+
3
+ class SMPLJoints:
4
+ PELVIS = 0
5
+ L_HIP = 1
6
+ R_HIP = 2
7
+ SPINE1 = 3
8
+ L_KNEE = 4
9
+ R_KNEE = 5
10
+ SPINE2 = 6
11
+ L_ANKLE = 7
12
+ R_ANKLE = 8
13
+ SPINE3 = 9
14
+ L_FOOT = 10
15
+ R_FOOT = 11
16
+ NECK = 12
17
+ HEAD = 13
18
+ L_SHOULDER = 14
19
+ R_SHOULDER = 15
20
+ L_ELBOW = 16
21
+ R_ELBOW = 17
22
+ L_WRIST = 18
23
+ R_WRIST = 19
24
+ # (Additional joints can be defined as needed)