MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / write_to_poses

Function write_to_poses

tools/preprocess/retarget_pose.py:495–523  ·  view source on GitHub ↗
(data_to_json, none_idx, dst_shape, bone_ratio_list, delta_ground_x, delta_ground_y, rescaled_src_ground_x, body_flag, scale_min)

Source from the content-addressed store, hash-verified

493
494
495def write_to_poses(data_to_json, none_idx, dst_shape, bone_ratio_list, delta_ground_x, delta_ground_y, rescaled_src_ground_x, body_flag, scale_min):
496 outputs = []
497 length = len(data_to_json)
498 for id in tqdm(range(length)):
499 src_height, src_width = data_to_json[id]["height"], data_to_json[id]["width"]
500 width, height = dst_shape
501 keypoints = data_to_json[id]["keypoints_body"]
502 for idx in range(len(keypoints)):
503 if idx in none_idx:
504 keypoints[idx] = None
505 new_keypoints = keypoints.copy()
506
507 # get hand keypoints
508 keypoints_hand = {"left": data_to_json[id]["keypoints_left_hand"], "right": data_to_json[id]["keypoints_right_hand"]}
509 # Normalize hand coordinates to 0-1 range
510 for hand_idx in range(len(data_to_json[id]["keypoints_left_hand"])):
511 data_to_json[id]["keypoints_left_hand"][hand_idx][0] = data_to_json[id]["keypoints_left_hand"][hand_idx][0] / src_width
512 data_to_json[id]["keypoints_left_hand"][hand_idx][1] = data_to_json[id]["keypoints_left_hand"][hand_idx][1] / src_height
513
514 for hand_idx in range(len(data_to_json[id]["keypoints_right_hand"])):
515 data_to_json[id]["keypoints_right_hand"][hand_idx][0] = data_to_json[id]["keypoints_right_hand"][hand_idx][0] / src_width
516 data_to_json[id]["keypoints_right_hand"][hand_idx][1] = data_to_json[id]["keypoints_right_hand"][hand_idx][1] / src_height
517
518 frame_info = get_scaled_pose(
519 (height, width), (src_height, src_width), new_keypoints, keypoints_hand, bone_ratio_list, delta_ground_x, delta_ground_y, rescaled_src_ground_x, body_flag, id, scale_min
520 )
521 outputs.append(frame_info)
522
523 return outputs
524
525
526def calculate_scale_ratio(skeleton, skeleton_edit, scale_ratio_flag):

Callers 1

retarget_poseFunction · 0.85

Calls 3

get_scaled_poseFunction · 0.85
copyMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected