Custom model def in Config.toml, not skeletons.py
This commit is contained in:
parent
ad26885c69
commit
b970c86d1d
@ -21,10 +21,9 @@ opensim_folder_name = 'opensim'
|
||||
|
||||
[pose]
|
||||
pose_model = 'BODY_25B' #With openpose: BODY_25B, BODY_25, BODY_135, COCO, MPII.
|
||||
#With mediapipe: BLAZEPOSE.
|
||||
#With alphapose: HALPE_26, HALPE_68, HALPE_136, COCO_133.
|
||||
#With deeplabcut: CUSTOM
|
||||
# See Pose2Sim\skeleton.py for their skeleton hierarchy
|
||||
#With mediapipe: BLAZEPOSE.
|
||||
#With alphapose: HALPE_26, HALPE_68, HALPE_136, COCO_133.
|
||||
#With deeplabcut: CUSTOM. See example at the end of the file.
|
||||
# What follows has not been implemented yet
|
||||
pose_framework = 'openpose' # 'openpose', 'mediapipe', 'alphapose', 'deeplabcut'
|
||||
overwrite_pose = false
|
||||
@ -123,3 +122,76 @@ display_figures = true # true or false (lowercase)
|
||||
kernel_size = 9
|
||||
|
||||
[opensim]
|
||||
|
||||
|
||||
# CUSTOM skeleton, for DeepLabCut for example (others are in skeletons.py)
|
||||
# In this example, CUSTOM reproduces the BODY_25B skeleton.
|
||||
# You can create as many custom skeletons as you want,
|
||||
# just add them further down the file and replace CUSTOM by the name of your choice.
|
||||
# Make sure the node ids correspond to the column numbers, starting from zero.
|
||||
[pose.CUSTOM]
|
||||
name = "CHip"
|
||||
id = "None"
|
||||
[[pose.CUSTOM.children]]
|
||||
id = 12
|
||||
name = "RHip"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 14
|
||||
name = "RKnee"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 16
|
||||
name = "RAnkle"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 22
|
||||
name = "RBigToe"
|
||||
[[pose.CUSTOM.children.children.children.children.children]]
|
||||
id = 23
|
||||
name = "RSmallToe"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 24
|
||||
name = "RHeel"
|
||||
[[pose.CUSTOM.children]]
|
||||
id = 11
|
||||
name = "LHip"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 13
|
||||
name = "LKnee"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 15
|
||||
name = "LAnkle"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 19
|
||||
name = "LBigToe"
|
||||
[[pose.CUSTOM.children.children.children.children.children]]
|
||||
id = 20
|
||||
name = "LSmallToe"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 21
|
||||
name = "LHeel"
|
||||
[[pose.CUSTOM.children]]
|
||||
id = 17
|
||||
name = "Neck"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 18
|
||||
name = "Head"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 0
|
||||
name = "Nose"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 6
|
||||
name = "RShoulder"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 8
|
||||
name = "RElbow"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 10
|
||||
name = "RWrist"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 5
|
||||
name = "LShoulder"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 7
|
||||
name = "LElbow"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 9
|
||||
name = "LWrist"
|
||||
|
@ -21,10 +21,9 @@ opensim_folder_name = 'opensim'
|
||||
|
||||
[pose]
|
||||
pose_model = 'BODY_25B' #With openpose: BODY_25B, BODY_25, BODY_135, COCO, MPII.
|
||||
#With mediapipe: BLAZEPOSE.
|
||||
#With alphapose: HALPE_26, HALPE_68, HALPE_136, COCO_133.
|
||||
#With deeplabcut: CUSTOM
|
||||
# See Pose2Sim\skeleton.py for their skeleton hierarchy
|
||||
#With mediapipe: BLAZEPOSE.
|
||||
#With alphapose: HALPE_26, HALPE_68, HALPE_136, COCO_133.
|
||||
#With deeplabcut: CUSTOM. See example at the end of the file.
|
||||
# What follows has not been implemented yet
|
||||
pose_framework = 'openpose' # 'openpose', 'mediapipe', 'alphapose', 'deeplabcut'
|
||||
overwrite_pose = false
|
||||
@ -124,3 +123,75 @@ display_figures = false # true or false (lowercase)
|
||||
|
||||
[opensim]
|
||||
|
||||
|
||||
# CUSTOM skeleton, for DeepLabCut for example (others are in skeletons.py)
|
||||
# In this example, CUSTOM reproduces the BODY_25B skeleton.
|
||||
# You can create as many custom skeletons as you want,
|
||||
# just add them further down the file and replace CUSTOM by the name of your choice.
|
||||
# Make sure the node ids correspond to the column numbers, starting from zero.
|
||||
[pose.CUSTOM]
|
||||
name = "CHip"
|
||||
id = "None"
|
||||
[[pose.CUSTOM.children]]
|
||||
id = 12
|
||||
name = "RHip"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 14
|
||||
name = "RKnee"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 16
|
||||
name = "RAnkle"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 22
|
||||
name = "RBigToe"
|
||||
[[pose.CUSTOM.children.children.children.children.children]]
|
||||
id = 23
|
||||
name = "RSmallToe"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 24
|
||||
name = "RHeel"
|
||||
[[pose.CUSTOM.children]]
|
||||
id = 11
|
||||
name = "LHip"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 13
|
||||
name = "LKnee"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 15
|
||||
name = "LAnkle"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 19
|
||||
name = "LBigToe"
|
||||
[[pose.CUSTOM.children.children.children.children.children]]
|
||||
id = 20
|
||||
name = "LSmallToe"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 21
|
||||
name = "LHeel"
|
||||
[[pose.CUSTOM.children]]
|
||||
id = 17
|
||||
name = "Neck"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 18
|
||||
name = "Head"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 0
|
||||
name = "Nose"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 6
|
||||
name = "RShoulder"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 8
|
||||
name = "RElbow"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 10
|
||||
name = "RWrist"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 5
|
||||
name = "LShoulder"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 7
|
||||
name = "LElbow"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 9
|
||||
name = "LWrist"
|
||||
|
@ -21,10 +21,9 @@ opensim_folder_name = 'opensim'
|
||||
|
||||
[pose]
|
||||
pose_model = 'BODY_25B' #With openpose: BODY_25B, BODY_25, BODY_135, COCO, MPII.
|
||||
#With mediapipe: BLAZEPOSE.
|
||||
#With alphapose: HALPE_26, HALPE_68, HALPE_136, COCO_133.
|
||||
#With deeplabcut: CUSTOM
|
||||
# See Pose2Sim\skeleton.py for their skeleton hierarchy
|
||||
#With mediapipe: BLAZEPOSE.
|
||||
#With alphapose: HALPE_26, HALPE_68, HALPE_136, COCO_133.
|
||||
#With deeplabcut: CUSTOM. See example at the end of the file.
|
||||
# What follows has not been implemented yet
|
||||
pose_framework = 'openpose' # 'openpose', 'mediapipe', 'alphapose', 'deeplabcut'
|
||||
overwrite_pose = false
|
||||
@ -84,7 +83,7 @@ calibration_type = 'convert' # 'convert' or 'calculate'
|
||||
calibration_points = 'wand' # 'wand' or 'keypoints'
|
||||
# Not supported yet.
|
||||
|
||||
|
||||
|
||||
[personAssociation]
|
||||
tracked_keypoint = 'Neck' # If the neck is not detected by the pose_model, check skeleton.py
|
||||
# and choose a stable point for tracking the person of interest (e.g., 'right_shoulder' with BLAZEPOSE)
|
||||
@ -124,3 +123,75 @@ display_figures = true # true or false (lowercase)
|
||||
|
||||
[opensim]
|
||||
|
||||
|
||||
# CUSTOM skeleton, for DeepLabCut for example (others are in skeletons.py)
|
||||
# In this example, CUSTOM reproduces the BODY_25B skeleton.
|
||||
# You can create as many custom skeletons as you want,
|
||||
# just add them further down the file and replace CUSTOM by the name of your choice.
|
||||
# Make sure the node ids correspond to the column numbers, starting from zero.
|
||||
[pose.CUSTOM]
|
||||
name = "CHip"
|
||||
id = "None"
|
||||
[[pose.CUSTOM.children]]
|
||||
id = 12
|
||||
name = "RHip"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 14
|
||||
name = "RKnee"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 16
|
||||
name = "RAnkle"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 22
|
||||
name = "RBigToe"
|
||||
[[pose.CUSTOM.children.children.children.children.children]]
|
||||
id = 23
|
||||
name = "RSmallToe"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 24
|
||||
name = "RHeel"
|
||||
[[pose.CUSTOM.children]]
|
||||
id = 11
|
||||
name = "LHip"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 13
|
||||
name = "LKnee"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 15
|
||||
name = "LAnkle"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 19
|
||||
name = "LBigToe"
|
||||
[[pose.CUSTOM.children.children.children.children.children]]
|
||||
id = 20
|
||||
name = "LSmallToe"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 21
|
||||
name = "LHeel"
|
||||
[[pose.CUSTOM.children]]
|
||||
id = 17
|
||||
name = "Neck"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 18
|
||||
name = "Head"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 0
|
||||
name = "Nose"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 6
|
||||
name = "RShoulder"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 8
|
||||
name = "RElbow"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 10
|
||||
name = "RWrist"
|
||||
[[pose.CUSTOM.children.children]]
|
||||
id = 5
|
||||
name = "LShoulder"
|
||||
[[pose.CUSTOM.children.children.children]]
|
||||
id = 7
|
||||
name = "LElbow"
|
||||
[[pose.CUSTOM.children.children.children.children]]
|
||||
id = 9
|
||||
name = "LWrist"
|
||||
|
@ -34,6 +34,8 @@ import json
|
||||
import itertools as it
|
||||
import toml
|
||||
from tqdm import tqdm
|
||||
from anytree import RenderTree
|
||||
from anytree.importer import DictImporter
|
||||
import logging
|
||||
|
||||
from Pose2Sim.common import computeP, weighted_triangulation, reprojection, \
|
||||
@ -258,7 +260,15 @@ def track_2d_all(config):
|
||||
P = computeP(calib_file)
|
||||
|
||||
# selection of tracked keypoint id
|
||||
model = eval(pose_model)
|
||||
try: # from skeletons.py
|
||||
model = eval(pose_model)
|
||||
except:
|
||||
try: # from Config.toml
|
||||
model = DictImporter().import_(config.get('pose').get(pose_model))
|
||||
if model.id == 'None':
|
||||
model.id = None
|
||||
except:
|
||||
raise NameError('Model not found in skeletons.py nor in Config.toml')
|
||||
tracked_keypoint_id = [node.id for _, _, node in RenderTree(model) if node.name==tracked_keypoint][0]
|
||||
|
||||
# 2d-pose files selection
|
||||
|
@ -8,11 +8,11 @@
|
||||
###########################################################################
|
||||
|
||||
The definition and hierarchy of the following skeletons are available:
|
||||
- CUSTOM (e.g.., from DeepLabCut),
|
||||
- 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")
|
||||
- DeepLabCut CUSTOM: the skeleton will be defined in Config.toml
|
||||
|
||||
N.B.: Not all face and hand keypoints are reported in the skeleton architecture,
|
||||
since some are redundant for the orientation of some bodies.
|
||||
@ -20,17 +20,10 @@
|
||||
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}')
|
||||
If you build it from a DeepLabCut model, make sure the node ids
|
||||
correspond to the column numbers, starting from zero.
|
||||
'''
|
||||
|
||||
## INIT
|
||||
from anytree import Node, RenderTree
|
||||
from anytree import Node
|
||||
|
||||
|
||||
## AUTHORSHIP INFORMATION
|
||||
@ -44,13 +37,6 @@ __email__ = "contact@david-pagnon.com"
|
||||
__status__ = "Development"
|
||||
|
||||
|
||||
'''CUSTOM SKELETON (e.g., from DeepLabCut detection)'''
|
||||
CUSTOM = Node("Root", id=0, children=[
|
||||
Node("Child1", id=1),
|
||||
Node("Child2", id=2),
|
||||
])
|
||||
|
||||
|
||||
'''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=[
|
||||
|
@ -41,6 +41,8 @@ import toml
|
||||
from tqdm import tqdm
|
||||
from scipy import interpolate
|
||||
from collections import Counter
|
||||
from anytree import RenderTree
|
||||
from anytree.importer import DictImporter
|
||||
import logging
|
||||
|
||||
from Pose2Sim.common import computeP, weighted_triangulation, reprojection, \
|
||||
@ -425,7 +427,15 @@ def triangulate_all(config):
|
||||
P = computeP(calib_file)
|
||||
|
||||
# Retrieve keypoints from model
|
||||
model = eval(pose_model)
|
||||
try: # from skeletons.py
|
||||
model = eval(pose_model)
|
||||
except:
|
||||
try: # from Config.toml
|
||||
model = DictImporter().import_(config.get('pose').get(pose_model))
|
||||
if model.id == 'None':
|
||||
model.id = None
|
||||
except:
|
||||
raise NameError('Model not found in skeletons.py nor in Config.toml')
|
||||
keypoints_ids = [node.id for _, _, node in RenderTree(model) if node.id!=None]
|
||||
keypoints_names = [node.name for _, _, node in RenderTree(model) if node.id!=None]
|
||||
keypoints_idx = list(range(len(keypoints_ids)))
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = pose2sim
|
||||
version = 0.4.7
|
||||
version = 0.4.8
|
||||
author = David Pagnon
|
||||
author_email = contact@david-pagnon.com
|
||||
description = Perform a markerless kinematic analysis from multiple calibrated views as a unified workflow from an OpenPose input to an OpenSim result.
|
||||
|
Loading…
Reference in New Issue
Block a user