tr3e / InterGen

[IJCV 2024] InterGen: Diffusion-based Multi-human Motion Generation under Complex Interactions
https://tr3e.github.io/intergen-page/
208 stars 10 forks source link

Weird visualization from 6D rotation representation. #24

Open WindVChen opened 9 months ago

WindVChen commented 9 months ago

I'm trying to visualize the human motions with the given 6D rotation representations in "motions_processed" folder. However, with the following code, the visualization result is quite weird.

Could you provide some guidance?

    from human_body_prior.body_model.body_model import BodyModel
    import numpy as np
    from pytorch3d import transforms
    from common.quaternion import *

    imw, imh = 800, 800
    mv = MeshViewer(width=imw, height=imh, use_offscreen=False)

    bm_fname = '/smplh/neutral/model.npz'
    bm = BodyModel(bm_fname=bm_fname, num_betas=10)

    data1 = np.load("./data/motions_processed/person1/6035.npy")

    rot_6d = data1[..., 62 * 3:62 * 3 + 21 * 6]

    rot_matrix = cont6d_to_matrix(torch.from_numpy(rot_6d.reshape(-1, 6)))
    rot_axis_angle = transforms.matrix_to_axis_angle(rot_matrix).view(-1, 63)

    body_pose_beta = bm(pose_body=rot_axis_angle)
    for fId in tqdm.tqdm(range(body_pose_beta.v.shape[0])):
        body_mesh = trimesh.Trimesh(vertices=convert(body_pose_beta.v[fId]), faces=bm.f, vertex_colors=np.tile(colors['grey'], (6890, 1)))
        mv.viewer.render_lock.acquire()
        mv.set_static_meshes([body_mesh])
        mv.viewer.render_lock.release()
        plt.pause(1)

微信截图_20240130001623

TLDX-XIONG commented 6 months ago

I'm trying to visualize the human motions with the given 6D rotation representations in "motions_processed" folder. However, with the following code, the visualization result is quite weird.

Could you provide some guidance?

    from human_body_prior.body_model.body_model import BodyModel
    import numpy as np
    from pytorch3d import transforms
    from common.quaternion import *

    imw, imh = 800, 800
    mv = MeshViewer(width=imw, height=imh, use_offscreen=False)

    bm_fname = '/smplh/neutral/model.npz'
    bm = BodyModel(bm_fname=bm_fname, num_betas=10)

    data1 = np.load("./data/motions_processed/person1/6035.npy")

    rot_6d = data1[..., 62 * 3:62 * 3 + 21 * 6]

    rot_matrix = cont6d_to_matrix(torch.from_numpy(rot_6d.reshape(-1, 6)))
    rot_axis_angle = transforms.matrix_to_axis_angle(rot_matrix).view(-1, 63)

    body_pose_beta = bm(pose_body=rot_axis_angle)
    for fId in tqdm.tqdm(range(body_pose_beta.v.shape[0])):
        body_mesh = trimesh.Trimesh(vertices=convert(body_pose_beta.v[fId]), faces=bm.f, vertex_colors=np.tile(colors['grey'], (6890, 1)))
        mv.viewer.render_lock.acquire()
        mv.set_static_meshes([body_mesh])
        mv.viewer.render_lock.release()
        plt.pause(1)

微信截图_20240130001623

hello, do you solve the problem?

WindVChen commented 6 months ago

Hi @TLDX-XIONG ,

Yes, I did manage to solve the problem. However, it's been a while since I worked on it, so I don't recall all the specifics of the correct visualization method. From what I remember, the issue with the visualization script above was related to the Rotation 6D representation. You might want to try visualizing it by taking the 6D as either columns or rows of the rotation matrix. One of these approaches should yield the correct visualization.