cleardusk / 3DDFA_V2

The official PyTorch implementation of Towards Fast, Accurate and Stable 3D Dense Face Alignment, ECCV 2020.
MIT License
2.88k stars 510 forks source link

The tri.pkl seems not correspond to bfm_noneck_v3.pkl well #106

Closed wasahaiah closed 2 years ago

wasahaiah commented 2 years ago

The tri.pkl seems not corespond to bfm_noneck_v3.pkl. I obtain the mean face and the triangle index , by the following code: bfm.py:

def exp_base_write(self, obj): for i in range(1): object_name = obj + str(i) + ".obj" write_obj(object_name, self.u, self.w_exp[:,0], self.tri, self.bfm_param_mean, self.bfm_param_std)

tddfa_util.py:

def write_obj(obj_name, u_base, vertices, faces, param_mean, param_std): if obj_name.split('.')[-1] != 'obj': obj_name = obj_name + '.obj' faces = faces.copy()

vertices = vertices * param_mean[52:] + param_std[52:]

with open(obj_name, 'w') as f:
    for i in np.arange(0, vertices.shape[0], 3):
        f.write('v {} {} {}\n'.format(u_base[i,0], u_base[i+1,0], u_base[i+2,0]))
        if u_base[i+2] == 0:
            print("i: ", i)
    for j in np.arange(faces.shape[0]):
        f.write('f {}/{} {}/{} {}/{}\n'.format(
            faces[j, 0], faces[j, 0],
            faces[j, 1], faces[j, 1],
            faces[j, 2], faces[j, 2]))

I get the obj file that seems not right which maybe caused by the file tri.pk 6342103889423

1

wasahaiah commented 2 years ago

The problem is solved