Draw 2nd person in correct colors

This commit is contained in:
kijai
2025-12-15 00:52:25 +02:00
parent b3cdd86997
commit 096f04d164
2 changed files with 18 additions and 7 deletions
+13 -5
View File
@@ -256,10 +256,8 @@ def render_nlf_as_images(smpl_poses, dw_poses, height, width, video_length, intr
return frames_np_rgba
def render_multi_nlf_as_images(data, dw_poses, intrinsic_matrix=None, draw_2d=True):
""" return a list of images """
height, width = data[0]['video_height'], data[0]['video_width']
video_length = len(data)
def render_multi_nlf_as_images(smpl_poses, dw_poses, height, width, video_length, intrinsic_matrix=None, draw_2d=True, draw_face=True, draw_hands=True):
second_person_base_colors_255_dict = {
# Warm Colors for Right Side (R.) - Red, Orange, Yellow
@@ -368,8 +366,18 @@ def render_multi_nlf_as_images(data, dw_poses, intrinsic_matrix=None, draw_2d=Tr
colors_first = [[c / 300 + 0.15 for c in color_rgb] + [0.8] for color_rgb in ordered_colors_255_list[0]]
colors_second = [[c / 300 + 0.15 for c in color_rgb] + [0.8] for color_rgb in ordered_colors_255_list[1]]
smpl_poses_first, smpl_poses_second = collect_smpl_poses_samurai(data)
smpl_poses_first = []
smpl_poses_second = []
for i in range(video_length):
if len(smpl_poses[i]) >= 1:
smpl_poses_first.append([smpl_poses[i][0]]) # First person
else:
smpl_poses_first.append([torch.zeros((24, 3), dtype=torch.float32)])
if len(smpl_poses[i]) >= 2:
smpl_poses_second.append([smpl_poses[i][1]]) # Second person
else:
smpl_poses_second.append([torch.zeros((24, 3), dtype=torch.float32)])
if intrinsic_matrix is None:
intrinsic_matrix = intrinsic_matrix_from_field_of_view((height, width))
+5 -2
View File
@@ -176,7 +176,7 @@ class RenderNLFPoses:
def predict(self, nlf_poses, width, height, dw_poses=None, ref_dw_pose=None, draw_face=True, draw_hands=True):
from .NLFPoseExtract.nlf_render import render_nlf_as_images, shift_dwpose_according_to_nlf, process_data_to_COCO_format, intrinsic_matrix_from_field_of_view
from .NLFPoseExtract.nlf_render import render_nlf_as_images, render_multi_nlf_as_images, shift_dwpose_according_to_nlf, process_data_to_COCO_format, intrinsic_matrix_from_field_of_view
from .NLFPoseExtract.align3d import solve_new_camera_params_central, solve_new_camera_params_down
if isinstance(nlf_poses, dict):
@@ -230,7 +230,10 @@ class RenderNLFPoses:
else:
intrinsic_matrix = ori_camera_pose
frames_np = render_nlf_as_images(pose_input, dw_pose_input, height, width, len(pose_input), intrinsic_matrix=intrinsic_matrix, draw_face=draw_face, draw_hands=draw_hands)
if pose_input[0].shape[0] > 1:
frames_np = render_multi_nlf_as_images(pose_input, dw_pose_input, height, width, len(pose_input), intrinsic_matrix=intrinsic_matrix, draw_face=draw_face, draw_hands=draw_hands)
else:
frames_np = render_nlf_as_images(pose_input, dw_pose_input, height, width, len(pose_input), intrinsic_matrix=intrinsic_matrix, draw_face=draw_face, draw_hands=draw_hands)
frames_tensor = torch.from_numpy(np.stack(frames_np, axis=0)).contiguous() / 255.0
frames_tensor, mask = frames_tensor[..., :3], frames_tensor[..., -1] > 0.5