Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acceleration Error. #91

Open
Songinpyo opened this issue Apr 10, 2024 · 0 comments
Open

Acceleration Error. #91

Songinpyo opened this issue Apr 10, 2024 · 0 comments

Comments

@Songinpyo
Copy link

Songinpyo commented Apr 10, 2024

First of all, thanks for your amazing work.

I have a question about acceleration error of METRO human mesh recovery model.

I calculated that on 3DPW test set.

Although this is actually for image based model ( did not focusing on smoothness over the frames ) the value is too high.
I think I did some mistakes on calculating.

So I would like to ask you about

  1. Did you calculated the accel error of METRO? Is there any codes officialy supporting?
  2. Are my codes snnipets for calcuating accel error is wrong?
def compute_error_accel(joints_gt, joints_pred, vis=None):

    joints_gt = joints_gt[vis == 1]
    # joints_gt = joints_gt[:, :, :-1]
    joints_pred = joints_pred[vis == 1]
    
    gt_pelvis = (joints_gt[:, 2,:] + joints_gt[:, 3,:]) / 2
    joints_gt = joints_gt - gt_pelvis[:, None, :]
    pred_pelvis = (joints_pred[:, 2,:] + joints_pred[:, 3,:]) / 2
    joints_pred = joints_pred - pred_pelvis[:, None, :]
    # (N-2)x14x3
    accel_gt = joints_gt[:-2] - 2 * joints_gt[1:-1] + joints_gt[2:]
    accel_pred = joints_pred[:-2] - 2 * joints_pred[1:-1] + joints_pred[2:]

    normed = np.linalg.norm(accel_pred - accel_gt, axis=2)
   
    return np.mean(normed, axis=1)

And from validate code

    pred_j3ds_all, gt_j3ds_all, vis_j3ds_all = [], [], []
    
    # switch to evaluate mode
    METRO_model.eval()
    smpl.eval()
    with torch.no_grad():
        for i, (img_keys, images, annotations) in enumerate(val_loader):                   
            batch_size = images.size(0)
            # compute output
            images = images.cuda(args.device)
            gt_3d_joints = annotations['joints_3d'].cuda(args.device)
            gt_3d_pelvis = gt_3d_joints[:,cfg.J24_NAME.index('Pelvis'),:3]
            gt_3d_joints = gt_3d_joints[:,cfg.J24_TO_J14,:]
            gt_3d_joints[:,:,:3] = gt_3d_joints[:,:,:3] - gt_3d_pelvis[:, None, :]
            has_3d_joints = annotations['has_3d_joints'].cuda(args.device)

            gt_pose = annotations['pose'].cuda(args.device)
            gt_betas = annotations['betas'].cuda(args.device)
            has_smpl = annotations['has_smpl'].cuda(args.device)

            # generate simplified mesh
            gt_vertices = smpl(gt_pose, gt_betas)
            gt_vertices_sub = mesh_sampler.downsample(gt_vertices)
            gt_vertices_sub2 = mesh_sampler.downsample(gt_vertices_sub, n1=1, n2=2)

            # normalize gt based on smpl pelvis 
            gt_smpl_3d_joints = smpl.get_h36m_joints(gt_vertices)
            gt_smpl_3d_pelvis = gt_smpl_3d_joints[:,cfg.H36M_J17_NAME.index('Pelvis'),:]
            gt_vertices_sub2 = gt_vertices_sub2 - gt_smpl_3d_pelvis[:, None, :] 
            gt_vertices = gt_vertices - gt_smpl_3d_pelvis[:, None, :] 

            # forward-pass
            pred_camera, pred_3d_joints, pred_vertices_sub2, pred_vertices_sub, pred_vertices = METRO_model(images, smpl, mesh_sampler)
            
            # obtain 3d joints from full mesh
            pred_3d_joints_from_smpl = smpl.get_h36m_joints(pred_vertices)

            pred_3d_pelvis = pred_3d_joints_from_smpl[:,cfg.H36M_J17_NAME.index('Pelvis'),:]
            pred_3d_joints_from_smpl = pred_3d_joints_from_smpl[:,cfg.H36M_J17_TO_J14,:]
            pred_3d_joints_from_smpl = pred_3d_joints_from_smpl - pred_3d_pelvis[:, None, :]
            pred_vertices = pred_vertices - pred_3d_pelvis[:, None, :]

            pred_j3ds_all.append(pred_3d_joints_from_smpl.cpu().numpy())
            gt_j3ds_all.append(gt_3d_joints[:,:,:3].cpu().numpy())
            vis_j3ds_all.append(has_3d_joints.cpu().numpy())

    pred_j3ds_all = np.concatenate(pred_j3ds_all)
    gt_j3ds_all = np.concatenate(gt_j3ds_all)
    vis_j3ds_all = np.concatenate(vis_j3ds_all)
    accel_error = compute_error_accel(joints_gt=gt_j3ds_all, joints_pred=pred_j3ds_all, vis=vis_j3ds_all) # m to mm
    mean_accel_error = np.mean(np.concatenate(accel_error))
    print("Mean Accel Error :", mean_accel_error * 1000)

I'll wait for your answering.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant