soubhiksanyal / RingNet

Learning to Regress 3D Face Shape and Expression from an Image without 3D Supervision
https://ringnet.is.tue.mpg.de
MIT License
814 stars 170 forks source link

Mesh from predicted parameters issue #15

Closed apchenstu closed 5 years ago

apchenstu commented 5 years ago

Hi, thanks for this amazing work! I am trying to recover the mesh from the predicted parameters(100 D shape, 50 expression and 6 dimensional pose), and I used a modified version "make_prdicted_mesh_neutral' function(copy flame-fitting project) to do this, it seems the shape and pose is correct, but the expression is wrong. Am I missed something? Thanks a lot.

` def make_prdicted_mesh_neutral_ringnet(predicted_params_path, flame_model_path): params = np.load(predicted_params_path, allow_pickle=True) params = params[()]

pose,betas = np.zeros(15),np.zeros(400)
pose[:3],pose[-3:]= params['pose'][:3],params['pose'][3:]
betas[:params['shape'].shape[0]] = params['shape']
betas[300:300+params['expression'].shape[0]] = params['expression']

flame_genral_model = load_model(flame_model_path)
generated_neutral_mesh = verts_decorated(ch.array([0,0,0]),
                    ch.array(pose),
                    ch.array(flame_genral_model.r),
                    flame_genral_model.J_regressor,
                    ch.array(flame_genral_model.weights),
                    flame_genral_model.kintree_table,
                    flame_genral_model.bs_style,
                    flame_genral_model.f,
                    bs_type=flame_genral_model.bs_type,
                    posedirs=ch.array(flame_genral_model.posedirs),
                    betas=ch.array(betas),#betas=ch.array(np.concatenate((theta[0,75:85], np.zeros(390)))), #
                    shapedirs=ch.array(flame_genral_model.shapedirs),
                    want_Jtr=True)
return generated_neutral_mesh

` 1563679320

apchenstu commented 5 years ago

It should be pose[:3],pose[6:9]= params['pose'][:3],params['pose'][3:]