Skip to content

Commit

Permalink
Revert commits df08552 and b94f6a6.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpagnon committed Jan 4, 2025
1 parent 57e36ab commit 1baf7a5
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 117 deletions.
11 changes: 3 additions & 8 deletions Pose2Sim/Demo_Batch/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,19 @@ frame_range = [] # For example [10,300], or [] for all frames.
exclude_from_batch = [] # List of trials to be excluded from batch analysis, ['<participant_dir/trial_dir>', 'etc'].
# e.g. ['S00_P00_Participant/S00_P00_T00_StaticTrial', 'S00_P00_Participant/S00_P00_T01_BalancingTrial']


[pose]
vid_img_extension = 'mp4' # any video or image extension

pose_model = 'Body_with_feet' #With RTMLib: Body_with_feet (default HALPE_26 model), Whole_body (COCO_133: body + feet + hands), Body (COCO_17)
pose_model = 'HALPE_26' #With RTMLib: HALPE_26 (body and feet, default), COCO_133 (body, feet, hands), COCO_17 (body)
# /!\ Only RTMPose is natively embeded in Pose2Sim. For all other pose estimation methods, you will have to run them yourself, and then refer to the documentation to convert the output files if needed
#With MMPose: HALPE_26, COCO_133, COCO_17, CUSTOM. See CUSTOM example at the end of the file
#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 example at the end of the file
mode = 'balanced' # 'lightweight', 'balanced', 'performance'
det_frequency = 1 # Run person detection only every N frames, and inbetween track previously detected bounding boxes (keypoint detection is still run on all frames).
det_frequency = 100 # Run person detection only every N frames, and inbetween track previously detected bounding boxes (keypoint detection is still run on all frames).
# Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate.
device = 'auto' # 'auto', 'CPU', 'CUDA', 'MPS', 'ROCM'
backend = 'auto' # 'auto', 'openvino', 'onnxruntime', 'opencv'

display_detection = true
display_detection = false
overwrite_pose = false # set to false if you don't want to recalculate pose estimation when it has already been done
save_video = 'to_video' # 'to_video' or 'to_images', 'none', or ['to_video', 'to_images']
output_format = 'openpose' # 'openpose', 'mmpose', 'deeplabcut', 'none' or a list of them # /!\ only 'openpose' is supported for now
Expand Down
11 changes: 3 additions & 8 deletions Pose2Sim/Demo_Batch/Trial_1/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@
# exclude_from_batch = [] # List of trials to be excluded from batch analysis, ['<participant_dir/trial_dir>', 'etc'].
# # e.g. ['S00_P00_Participant/S00_P00_T00_StaticTrial', 'S00_P00_Participant/S00_P00_T01_BalancingTrial']


# [pose]
# vid_img_extension = 'mp4' # any video or image extension

# pose_model = 'Body_with_feet' #With RTMLib: Body_with_feet (default HALPE_26 model), Whole_body (COCO_133: body + feet + hands), Body (COCO_17)
# # /!\ Only RTMPose is natively embeded in Pose2Sim. For all other pose estimation methods, you will have to run them yourself, and then refer to the documentation to convert the output files if needed
# pose_model = 'HALPE_26' #With RTMLib: HALPE_26 (body and feet, default), COCO_133 (body, feet, hands), COCO_17 (body)
# #/!\ Only RTMPose is natively embeded in Pose2Sim. For all other pose estimation methods, you will have to run them yourself, and then refer to the documentation to convert the output files if needed
# #With MMPose: HALPE_26, COCO_133, COCO_17, CUSTOM. See CUSTOM example at the end of the file
# #With openpose: BODY_25B, BODY_25, BODY_135, COCO, MPII
# #With mediapipe: BLAZEPOSE
Expand All @@ -46,11 +44,8 @@
# mode = 'balanced' # 'lightweight', 'balanced', 'performance'
# det_frequency = 100 # Run person detection only every N frames, and inbetween track previously detected bounding boxes (keypoint detection is still run on all frames).
# # Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate.
# device = 'auto' # 'auto', 'CPU', 'CUDA', 'MPS', 'ROCM'
# backend = 'auto' # 'auto', 'openvino', 'onnxruntime', 'opencv'

# # overwrite_pose = true # set to false if you don't want to recalculate pose estimation when it has already been done
# display_detection = true
# overwrite_pose = false # set to false if you don't want to recalculate pose estimation when it has already been done
# save_video = 'to_video' # 'to_video' or 'to_images', 'none', or ['to_video', 'to_images']
# output_format = 'openpose' # 'openpose', 'mmpose', 'deeplabcut', 'none' or a list of them # /!\ only 'openpose' is supported for now

Expand Down
10 changes: 3 additions & 7 deletions Pose2Sim/Demo_Batch/Trial_2/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ participant_mass = [70.0, 63.5] # kg # Only used for marker augmentation and sca

# [pose]
# vid_img_extension = 'mp4' # any video or image extension

# pose_model = 'Body_with_feet' #With RTMLib: Body_with_feet (default HALPE_26 model), Whole_body (COCO_133: body + feet + hands), Body (COCO_17)
# # /!\ Only RTMPose is natively embeded in Pose2Sim. For all other pose estimation methods, you will have to run them yourself, and then refer to the documentation to convert the output files if needed
# pose_model = 'HALPE_26' #With RTMLib: HALPE_26 (body and feet, default), COCO_133 (body, feet, hands), COCO_17 (body)
# #/!\ Only RTMPose is natively embeded in Pose2Sim. For all other pose estimation methods, you will have to run them yourself, and then refer to the documentation to convert the output files if needed
# #With MMPose: HALPE_26, COCO_133, COCO_17, CUSTOM. See CUSTOM example at the end of the file
# #With openpose: BODY_25B, BODY_25, BODY_135, COCO, MPII
# #With mediapipe: BLAZEPOSE
Expand All @@ -45,11 +44,8 @@ participant_mass = [70.0, 63.5] # kg # Only used for marker augmentation and sca
# mode = 'balanced' # 'lightweight', 'balanced', 'performance'
# det_frequency = 100 # Run person detection only every N frames, and inbetween track previously detected bounding boxes (keypoint detection is still run on all frames).
# # Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate.
# device = 'auto' # 'auto', 'CPU', 'CUDA', 'MPS', 'ROCM'
# backend = 'auto' # 'auto', 'openvino', 'onnxruntime', 'opencv'

# # overwrite_pose = false # set to false if you don't want to recalculate pose estimation when it has already been done
# display_detection = true
# overwrite_pose = false # set to false if you don't want to recalculate pose estimation when it has already been done
# save_video = 'to_video' # 'to_video' or 'to_images', 'none', or ['to_video', 'to_images']
# output_format = 'openpose' # 'openpose', 'mmpose', 'deeplabcut', 'none' or a list of them # /!\ only 'openpose' is supported for now

Expand Down
7 changes: 1 addition & 6 deletions Pose2Sim/Demo_MultiPerson/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ frame_range = [] # For example [10,300], or [] for all frames.
exclude_from_batch = [] # List of trials to be excluded from batch analysis, ['<participant_dir/trial_dir>', 'etc'].
# e.g. ['S00_P00_Participant/S00_P00_T00_StaticTrial', 'S00_P00_Participant/S00_P00_T01_BalancingTrial']


[pose]
vid_img_extension = 'mp4' # any video or image extension

pose_model = 'Body_with_feet' #With RTMLib: Body_with_feet (default HALPE_26 model), Whole_body (COCO_133: body + feet + hands), Body (COCO_17)
pose_model = 'HALPE_26' #With RTMLib: HALPE_26 (body and feet, default), COCO_133 (body, feet, hands), COCO_17 (body)
# /!\ Only RTMPose is natively embeded in Pose2Sim. For all other pose estimation methods, you will have to run them yourself, and then refer to the documentation to convert the output files if needed
#With MMPose: HALPE_26, COCO_133, COCO_17, CUSTOM. See CUSTOM example at the end of the file
#With openpose: BODY_25B, BODY_25, BODY_135, COCO, MPII
Expand All @@ -46,9 +44,6 @@ pose_model = 'Body_with_feet' #With RTMLib: Body_with_feet (default HALPE_26 mo
mode = 'balanced' # 'lightweight', 'balanced', 'performance'
det_frequency = 1 # Run person detection only every N frames, and inbetween track previously detected bounding boxes (keypoint detection is still run on all frames).
# Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate.
device = 'auto' # 'auto', 'CPU', 'CUDA', 'MPS', 'ROCM'
backend = 'auto' # 'auto', 'openvino', 'onnxruntime', 'opencv'

display_detection = true
overwrite_pose = false # set to false if you don't want to recalculate pose estimation when it has already been done
save_video = 'to_video' # 'to_video' or 'to_images', 'none', or ['to_video', 'to_images']
Expand Down
9 changes: 2 additions & 7 deletions Pose2Sim/Demo_SinglePerson/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ frame_range = [] # For example [10,300], or [] for all frames.
exclude_from_batch = [] # List of trials to be excluded from batch analysis, ['<participant_dir/trial_dir>', 'etc'].
# e.g. ['S00_P00_Participant/S00_P00_T00_StaticTrial', 'S00_P00_Participant/S00_P00_T01_BalancingTrial']


[pose]
vid_img_extension = 'mp4' # any video or image extension

pose_model = 'Body_with_feet' #With RTMLib: Body_with_feet (default HALPE_26 model), Whole_body (COCO_133: body + feet + hands), Body (COCO_17)
pose_model = 'HALPE_26' #With RTMLib: HALPE_26 (body and feet, default), COCO_133 (body, feet, hands), COCO_17 (body)
# /!\ Only RTMPose is natively embeded in Pose2Sim. For all other pose estimation methods, you will have to run them yourself, and then refer to the documentation to convert the output files if needed
#With MMPose: HALPE_26, COCO_133, COCO_17, CUSTOM. See CUSTOM example at the end of the file
#With openpose: BODY_25B, BODY_25, BODY_135, COCO, MPII
Expand All @@ -46,9 +44,6 @@ pose_model = 'Body_with_feet' #With RTMLib: Body_with_feet (default HALPE_26 mo
mode = 'balanced' # 'lightweight', 'balanced', 'performance'
det_frequency = 1 # Run person detection only every N frames, and inbetween track previously detected bounding boxes (keypoint detection is still run on all frames).
# Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate.
device = 'auto' # 'auto', 'CPU', 'CUDA', 'MPS', 'ROCM'
backend = 'auto' # 'auto', 'openvino', 'onnxruntime', 'opencv'

display_detection = true
overwrite_pose = false # set to false if you don't want to recalculate pose estimation when it has already been done
save_video = 'to_video' # 'to_video' or 'to_images', 'none', or ['to_video', 'to_images']
Expand Down Expand Up @@ -186,7 +181,7 @@ make_c3d = true # save triangulated data in c3d format in addition to trc


[kinematics]
use_augmentation = false # true or false (lowercase) # Set to true if you want to use the model with augmented markers
use_augmentation = true # true or false (lowercase) # Set to true if you want to use the model with augmented markers
right_left_symmetry = true # true or false (lowercase) # Set to false only if you have good reasons to think the participant is not symmetrical (e.g. prosthetic limb)

remove_individual_scaling_setup = true # true or false (lowercase) # If true, the individual scaling setup files are removed to avoid cluttering
Expand Down
16 changes: 4 additions & 12 deletions Pose2Sim/kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,16 +734,8 @@ def kinematics_all(config_dict):
# if single trial
session_dir = session_dir if 'Config.toml' in os.listdir(session_dir) else os.getcwd()
use_augmentation = config_dict.get('kinematics').get('use_augmentation')
if use_augmentation:
model_name = 'LSTM'
else:
model_name = config_dict.get('pose').get('pose_model').upper()
if model_name.upper() == 'BODY_WITH_FEET': model_name = 'HALPE_26'
elif model_name.upper() == 'WHOLE_BODY': model_name = 'COCO_133'
elif model_name.upper() == 'BODY': model_name = 'COCO_17'
else:
raise ValueError(f"Invalid model_type: {model_name}. Must be 'HALPE_26', 'COCO_133', or 'COCO_17'. Use another network (MMPose, DeepLabCut, OpenPose, AlphaPose, BlazePose...) and convert the output files if you need another model. See documentation.")

if use_augmentation: model_name = 'LSTM'
else: model_name = config_dict.get('pose').get('pose_model').upper()
right_left_symmetry = config_dict.get('kinematics').get('right_left_symmetry')
subject_height = config_dict.get('project').get('participant_height')
subject_mass = config_dict.get('project').get('participant_mass')
Expand Down Expand Up @@ -804,13 +796,13 @@ def kinematics_all(config_dict):
for p, trc_file in enumerate(trc_files):
logging.info(f"Processing TRC file: {trc_file.resolve()}")

logging.info("\nScaling...")
logging.info("Scaling...")
perform_scaling(trc_file, kinematics_dir, osim_setup_dir, model_name, right_left_symmetry=right_left_symmetry, subject_height=subject_height[p], subject_mass=subject_mass[p],
remove_scaling_setup=remove_scaling_setup, fastest_frames_to_remove_percent=fastest_frames_to_remove_percent, large_hip_knee_angles=large_hip_knee_angles, trimmed_extrema_percent=trimmed_extrema_percent,close_to_zero_speed_m=close_to_zero_speed_m)
logging.info(f"\tDone. OpenSim logs saved to {opensim_logs_file.resolve()}.")
logging.info(f"\tScaled model saved to {(kinematics_dir / (trc_file.stem + '_scaled.osim')).resolve()}")

logging.info("\nInverse Kinematics...")
logging.info("Inverse Kinematics...")
perform_IK(trc_file, kinematics_dir, osim_setup_dir, model_name, remove_IK_setup=remove_IK_setup)
logging.info(f"\tDone. OpenSim logs saved to {opensim_logs_file.resolve()}.")
logging.info(f"\tJoint angle data saved to {(kinematics_dir / (trc_file.stem + '.mot')).resolve()}\n")
7 changes: 0 additions & 7 deletions Pose2Sim/personAssociation.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,14 +664,7 @@ def associate_all(config_dict):

# selection of tracked keypoint id
try: # from skeletons.py
if pose_model.upper() == 'BODY_WITH_FEET': pose_model = 'HALPE_26'
elif pose_model.upper() == 'WHOLE_BODY': pose_model = 'COCO_133'
elif pose_model.upper() == 'BODY': pose_model = 'COCO_17'
else:
raise ValueError(f"Invalid model_type: {pose_model}. Must be 'HALPE_26', 'COCO_133', or 'COCO_17'. Use another network (MMPose, DeepLabCut, OpenPose, AlphaPose, BlazePose...) and convert the output files if you need another model. See documentation.")

model = eval(pose_model)

except:
try: # from Config.toml
model = DictImporter().import_(config_dict.get('pose').get(pose_model))
Expand Down
Loading

0 comments on commit 1baf7a5

Please sign in to comment.