cleardusk/3DDFA_V2

How to use 300W-LP GT to this project?

Joyako opened this issue · 3 comments

Hi , thanks for your excellent project ! I want to re-train this project, but I found the 300W-LP's GT can't use directly, for example ,
the Shape_Para of value is so large, how to process it ?

When I visualize it according to the code below, the displayed result is wrong.

def vis_gt():
    tri = sio.loadmat("./train.configs/tri.mat")["tri"].transpose(1, 0).astype("int32")
    label = sio.loadmat('./300W_LP/AFW/AFW_134212_1_0.mat')
    scale = label['Pose_Para'][:, 6]
    R = cv2.Rodrigues(label['Pose_Para'][:, :3])[0]
    # R = np.linalg.inv(R)
    offset = label['Pose_Para'][:, 3:6].transpose(1, 0)
    # R = np.column_stack([R, offset])
    alpha_shp = label['Shape_Para'][:40]
    alpha_exp = label['Exp_Para'][:10]

    img_name = "./300W_LP/AFW/AFW_134212_1_0.jpg"
    img = cv2.imread(img_name, cv2.IMREAD_COLOR)

    # param = np.concatenate([R.reshape(-1, 1), alpha_shp, alpha_exp]).astype('float32').ravel()
    # R, offset, alpha_shp, alpha_exp = _parse_param(param)
    vertex = R @ (u + w_shp @ alpha_shp + w_exp @ alpha_exp).reshape(3, -1, order='F') + offset
    # vertex = reconstruct_vertex(param, whitening=False, dense=True, transform=False)
    # vertex = R @ (u + w_shp @ alpha_shp + w_exp @ alpha_exp).reshape(3, -1, order='F') + offset
    vertex = vertex.astype('float32')
    # vertex[1, :] = 1 - vertex[1, :]

    wfp = "examples/results/test.png"
    render(img, [vertex], tri, alpha=0.6, show_flag=False, wfp=wfp)

    return vertex

The results as fllows:
test

You can reference main_show_with_model.m in 300W_LP/Code/ to use the gt.
(1) The R matrix is not used opencv API;
(2) need to multiply scale

You can reference main_show_with_model.m in 300W_LP/Code/ to use the gt. (1) The R matrix is not used opencv API; (2) need to multiply scale

Hi @wu1143100799 , thanks for your reply, I will try it

@Joyako Did you learn how to retrain v2?