diff --git a/Pose2Sim/skeletons.py b/Pose2Sim/skeletons.py index a149061..ab67035 100644 --- a/Pose2Sim/skeletons.py +++ b/Pose2Sim/skeletons.py @@ -7,23 +7,24 @@ ## SKELETONS DEFINITIONS ## ########################################################################### - Skeletons definition and hierarchy. + The definition and hierarchy of the following skeletons are available: - CUSTOM (i.e., from DeepLabCut), - - OpenPose BODY_25B, BODY_25, BODY_135, COCO, MPII, - - AlphaPose - - Mediapipe (BLAZEPOSE), - HALPE (AlphaPose), BLAZEPOSE (MediaPipe), COCO and MPI are provided. - Note that not all face keypoints are reported, since less are needed to determine head orientation. - - You can also build your own custom skeleton. Verify your structure by typing: - from anytree import Node, RenderTree - for pre, _, node in RenderTree(CUSTOM): - print(f'{pre}{node.name} id={node.id}') + - OpenPose BODY_25B, BODY_25, BODY_135, COCO, MPII + - Mediapipe BLAZEPOSE + - AlphaPose HALPE_26, HALPE_68, HALPE_136, COCO_133, COCO, MPII + (for COCO and MPII, AlphaPose must be run with the flag "--format cmu") - Note that only Body_25 and Body_25b OpenSim files are provided (in "Empty project" folder). + N.B.: Not all face and hand keypoints are reported in the skeleton architecture, + since some are redundant for the orientation of some bodies. + + N.B.: The corresponding OpenSim model files are provided in the "Pose2Sim\Empty project" folder. If you wish to use any other, you will need to adjust the markerset in the .osim model file, as well as in the scaling and IK setup files. + N.B.: In case you built a custom skeleton, you can check its structure by typing: + from anytree import Node, RenderTree + for pre, _, node in RenderTree(CUSTOM): + print(f'{pre}{node.name} id={node.id}') ''' ## INIT @@ -48,7 +49,9 @@ CUSTOM = Node("Root", id=0, children=[ Node("Child2", id=2), ]) -# BODY_25B (experimental, from OpenPose https://github.com/CMU-Perceptual-Computing-Lab/openpose_train/blob/master/experimental_models/README.md) + +# BODY_25B (full-body without hands, experimental, from OpenPose) +# https://github.com/CMU-Perceptual-Computing-Lab/openpose_train/blob/master/experimental_models/README.md BODY_25B = Node("CHip", id=None, children=[ Node("RHip", id=12, children=[ Node("RKnee", id=14, children=[ @@ -87,7 +90,9 @@ BODY_25B = Node("CHip", id=None, children=[ ]), ]) -# BODY_25 (from OpenPose, standard ) + +# BODY_25 (full-body without hands, standard, from OpenPose) +# https://github.com/CMU-Perceptual-Computing-Lab/openpose/tree/master/models BODY_25 = Node("CHip", id=8, children=[ Node("RHip", id=9, children=[ Node("RKnee", id=10, children=[ @@ -124,7 +129,58 @@ BODY_25 = Node("CHip", id=8, children=[ ]), ]) -# BLAZEPOSE (from mediapipe https://google.github.io/mediapipe/solutions/pose) + +# BODY_135 (full-body with hands and face, experimental, from OpenPose) +# https://github.com/CMU-Perceptual-Computing-Lab/openpose_train/blob/master/experimental_models/README.md) +BODY_135 = Node("CHip", id=None, children=[ + Node("RHip", id=12, children=[ + Node("RKnee", id=14, children=[ + Node("RAnkle", id=16, children=[ + Node("RBigToe", id=22, children=[ + Node("RSmallToe", id=23), + ]), + Node("RHeel", id=24), + ]), + ]), + ]), + Node("LHip", id=11, children=[ + Node("LKnee", id=13, children=[ + Node("LAnkle", id=15, children=[ + Node("LBigToe", id=19, children=[ + Node("LSmallToe", id=20), + ]), + Node("LHeel", id=21), + ]), + ]), + ]), + Node("Neck", id=17, children=[ + Node("Head", id=18, children=[ + Node("Nose", id=0), + ]), + Node("RShoulder", id=6, children=[ + Node("RElbow", id=8, children=[ + Node("RWrist", id=10, children=[ + Node("RThumb", id=27), + Node("RIndex", id=30), + Node("RPinky", id=42), + ]), + ]), + ]), + Node("LShoulder", id=5, children=[ + Node("LElbow", id=7, children=[ + Node("LWrist", id=9, children=[ + Node("RThumb", id=48), + Node("RIndex", id=51), + Node("RPinky", id=63), + ]), + ]), + ]), + ]), +]) + + +# BLAZEPOSE (full-body with simplified hand and foot, from mediapipe) +# https://google.github.io/mediapipe/solutions/pose BLAZEPOSE = Node("root", id=None, children=[ Node("right_hip", id=24, children=[ Node("right_knee", id=26, children=[ @@ -167,8 +223,9 @@ BLAZEPOSE = Node("root", id=None, children=[ ]) -# HALPE (from AlphaPose) https://github.com/Fang-Haoshu/Halpe-FullBody -ALPHAPOSE = Node("Hip", id=19, children=[ +# HALPE_26 (full-body without hands, from AlphaPose) +# https://github.com/MVIG-SJTU/AlphaPose/blob/master/docs/MODEL_ZOO.md +HALPE_26 = Node("Hip", id=19, children=[ Node("RHip", id=12, children=[ Node("RKnee", id=14, children=[ Node("RAnkle", id=16, children=[ @@ -207,7 +264,154 @@ ALPHAPOSE = Node("Hip", id=19, children=[ ]) -# COCO (from OpenPose, AlphaPose, OpenPifPaf, YOLO-pose, etc) +# HALPE_68 (full-body with hands without face, from AlphaPose) +# https://github.com/MVIG-SJTU/AlphaPose/blob/master/docs/MODEL_ZOO.md +HALPE_26 = Node("Hip", id=19, children=[ + Node("RHip", id=12, children=[ + Node("RKnee", id=14, children=[ + Node("RAnkle", id=16, children=[ + Node("RBigToe", id=21, children=[ + Node("RSmallToe", id=23), + ]), + Node("RHeel", id=25), + ]), + ]), + ]), + Node("LHip", id=11, children=[ + Node("LKnee", id=13, children=[ + Node("LAnkle", id=15, children=[ + Node("LBigToe", id=20, children=[ + Node("LSmallToe", id=22), + ]), + Node("LHeel", id=24), + ]), + ]), + ]), + Node("Neck", id=18, children=[ + Node("Nose", id=0), + Node("RShoulder", id=6, children=[ + Node("RElbow", id=8, children=[ + Node("RWrist", id=10, children=[ + Node("RThumb", id=49), + Node("RIndex", id=52), + Node("RPinky", id=64), + ]), + ]), + ]), + Node("LShoulder", id=5, children=[ + Node("LElbow", id=7, children=[ + Node("LWrist", id=9, children=[ + Node("LThumb", id=28), + Node("LIndex", id=31), + Node("LPinky", id=43), + ]) + ]), + ]), + ]), +]) + + +# HALPE_136 (full-body with hands and face, from AlphaPose) +# https://github.com/MVIG-SJTU/AlphaPose/blob/master/docs/MODEL_ZOO.md +HALPE_136 = Node("Hip", id=19, children=[ + Node("RHip", id=12, children=[ + Node("RKnee", id=14, children=[ + Node("RAnkle", id=16, children=[ + Node("RBigToe", id=21, children=[ + Node("RSmallToe", id=23), + ]), + Node("RHeel", id=25), + ]), + ]), + ]), + Node("LHip", id=11, children=[ + Node("LKnee", id=13, children=[ + Node("LAnkle", id=15, children=[ + Node("LBigToe", id=20, children=[ + Node("LSmallToe", id=22), + ]), + Node("LHeel", id=24), + ]), + ]), + ]), + Node("Neck", id=18, children=[ + Node("Nose", id=0), + Node("RShoulder", id=6, children=[ + Node("RElbow", id=8, children=[ + Node("RWrist", id=10, children=[ + Node("RThumb", id=117), + Node("RIndex", id=120), + Node("RPinky", id=132), + ]), + ]), + ]), + Node("LShoulder", id=5, children=[ + Node("LElbow", id=7, children=[ + Node("LWrist", id=9, children=[ + Node("LThumb", id=96), + Node("LIndex", id=99), + Node("LPinky", id=111), + ]) + ]), + ]), + ]), +]) + + +# COCO_133 (full-body with hands and face, from AlphaPose) +# https://github.com/MVIG-SJTU/AlphaPose/blob/master/docs/MODEL_ZOO.md +COCO_133 = Node("Hip", id=None, children=[ + Node("RHip", id=13, children=[ + Node("RKnee", id=15, children=[ + Node("RAnkle", id=17, children=[ + Node("RBigToe", id=21, children=[ + Node("RSmallToe", id=22), + ]), + Node("RHeel", id=23), + ]), + ]), + ]), + Node("LHip", id=12, children=[ + Node("LKnee", id=14, children=[ + Node("LAnkle", id=16, children=[ + Node("LBigToe", id=18, children=[ + Node("LSmallToe", id=19), + ]), + Node("LHeel", id=20), + ]), + ]), + ]), + Node("Neck", id=None, children=[ + Node("Head", id=17, children=[ + Node("Nose", id=0, children=[ + Node("right_eye", id=3), + Node("left_eye", id=2), + ]), + ]), + Node("RShoulder", id=7, children=[ + Node("RElbow", id=9, children=[ + Node("RWrist", id=11, children=[ + Node("RThumb", id=115), + Node("RIndex", id=118), + Node("RPinky", id=130), + ]), + ]), + ]), + Node("LShoulder", id=6, children=[ + Node("LElbow", id=8, children=[ + Node("LWrist", id=10, children=[ + Node("LThumb", id=94), + Node("LIndex", id=97), + Node("LPinky", id=109), + ]) + ]), + ]), + ]), +]) + + +# COCO (full-body without hands and feet, from OpenPose, AlphaPose, OpenPifPaf, YOLO-pose, etc) +# https://github.com/CMU-Perceptual-Computing-Lab/openpose/tree/master/models COCO = Node("CHip", id=None, children=[ Node("RHip", id=8, children=[ Node("RKnee", id=9, children=[ @@ -234,7 +438,9 @@ COCO = Node("CHip", id=None, children=[ ]), ]) -# MPII (from OpenPose, AlphaPose, OpenPifPaf, YOLO-pose, etc) + +# MPII (full-body without hands and feet, from OpenPose, AlphaPose, OpenPifPaf, YOLO-pose, etc) +# https://github.com/CMU-Perceptual-Computing-Lab/openpose/tree/master/models MPII = Node("CHip", id=14, children=[ Node("RHip", id=8, children=[ Node("RKnee", id=9, children=[ @@ -261,5 +467,3 @@ MPII = Node("CHip", id=14, children=[ ]), ]) -# BODY_135 (experimental, from OpenPose https://github.com/CMU-Perceptual-Computing-Lab/openpose_train/blob/master/experimental_models/README.md) -BODY_135 = Node("")