face3d icon indicating copy to clipboard operation
face3d copied to clipboard

Not enough randomness in the shape of faces

Open yueqiw opened this issue 6 years ago • 2 comments

Hi,

Great repo, very helpful! One issue I had when generating random faces is that the shapes of random faces are very similar to each other. It'd be great if we can get more diverse faces.

The faces become more diverse after I made the following changes. Basically, I use shape_para * self.model['shapeEV'] rather than shape_para alone in calculating the axis. This is adapted from the Matlab code in the BFM model. (This change somehow breaks the fitting process, though.)

    def get_shape_para(self, type = 'random'):
        if type == 'zero':
            sp = np.zeros((self.n_shape_para, 1))
        elif type == 'random':
            sp = np.random.randn(self.n_shape_para, 1)   # normally distributed random numbers
        return sp

    def generate_vertices(self, shape_para, exp_para):
        
        vertices = self.model['shapeMU'] + \
                    self.model['shapePC'].dot(shape_para * self.model['shapeEV']) + \
                    self.model['expPC'].dot(exp_para)
        vertices = np.reshape(vertices, [int(3), int(len(vertices)/3)], 'F').T
        return vertices

yueqiw avatar Nov 11 '18 08:11 yueqiw

Hi, Have you solve it? I cannot generate face with enough distinction too. They look nearly the same.

xinwen-cs avatar Aug 01 '19 12:08 xinwen-cs

@xinwen-cs The above solution helped to some extent. You can look at the Matlab code from the BFM model to understand how the calculation works.

yueqiw avatar Aug 02 '19 05:08 yueqiw