microsoft / Deep3DFaceReconstruction

Accurate 3D Face Reconstruction with Weakly-Supervised Learning: From Single Image to Image Set (CVPRW 2019)
MIT License
2.18k stars 443 forks source link

Questions about the eyes of the reconstructed faces #144

Open hanssssssss opened 3 years ago

hanssssssss commented 3 years ago

Hi, sorry for bothering you. I found that my trained model can not reconstruct the eyes well(the eyes of each face looked similiar), do you have any idea about it ? Thanks.

image

YuDeng commented 3 years ago

How many iterations have you trained the model? At the beginning of the training, it is normal that the eyes looked the same for each face.

hanssssssss commented 3 years ago

How many iterations have you trained the model? At the beginning of the training, it is normal that the eyes looked the same for each face.

I trained around 100k images and the batchsize was 5. That screenshot was around 100000 iterations. And the picture below is 160400 iterations. image

YuDeng commented 3 years ago

Is it the model trained with the code in this repository? Seems that the identity loss does not work.

hanssssssss commented 3 years ago

Is it the model trained with the code in this repository? Seems that the identity loss does not work.

No, I used pytorch but the algorithms were the same as your paper.The information about the loss(displayed without weights) is below

image

YuDeng commented 3 years ago

Is the input to the face recognition network correct? The perceptual loss seems quite low however the reconstructed faces and real ones are not similar. Seems that there is something wrong with this part.

hanssssssss commented 3 years ago

Is the input to the face recognition network correct? The perceptual loss seems quite low however the reconstructed faces and real ones are not similar. Seems that there is something wrong with this part.

The input of the face recognition network is correct. I will check the network to see if it functions properly. Thanks for your help!

hanssssssss commented 3 years ago

Is the input to the face recognition network correct? The perceptual loss seems quite low however the reconstructed faces and real ones are not similar. Seems that there is something wrong with this part.

Hi ! I found that I didn't use fixed_image_standardization(to constrain the pixel from[-1,1]). After using it, the perceptual loss was bigger than before. But I found that the cosine similarity of two similiar faces can be a negative value(like -0.530), when using (1 - similiarity), the loss can be bigger than those faces which are not similiar. Should I use absolute value for the similarity or that part is still wrong. Thanks.

YuDeng commented 3 years ago

You have to normalize the identity feature before calculating the cosine similarity.

hanssssssss commented 3 years ago

You have to normalize the identity feature before calculating the cosine similarity.

Hi , Do you mean that to normaIize to value of the features between [0,1]. I did use l2normalization to normalize the features. But the result of l2normalization can be negative

YuDeng commented 3 years ago

You should normalize the feature so that its L2 norm equals 1. In this case, the maximum value of the dot product of two features should be 1, then it is impossible that (1-similarity) is a negative value.

hanssssssss commented 3 years ago

You should normalize the feature so that its L2 norm equals 1. In this case, the maximum value of the dot product of two features should be 1, then it is impossible that (1-similarity) is a negative value.

Hi , Thanks for your quick reply. I mean that the cosine similarity of two similiar faces can be a negative value(I think this is becuase the output of the perceptual net contains negative figures), so when doing the (1-similarity), the value(>1) of the loss can be bigger than those faces that are not similiar.Should I use other normalization method to make sure the similarity is a positive value? Thanks again.

def Perceptual_loss(self,id_original,id_output):
    id_original = torch.nn.functional.normalize(id_original)
    id_output = torch.nn.functional.normalize(id_output)
    similarity = torch.cosine_similarity(id_original, id_output, dim=1)
    loss = 1 - similarity
    return loss 
YuDeng commented 3 years ago

Cosine similarity can be negative. It ranges from [-1 to 1]. Negative value indicates that the angle between two features is larger than 90 degrees, which is normal at the beginning of the training.

hanssssssss commented 3 years ago

Cosine similarity can be negative. It ranges from [-1 to 1]. Negative value indicates that the angle between two features is larger than 90 degrees, which is normal at the beginning of the training.

Thanks, I used the modifid perceptual loss and trained my model. However I found the color of the face was strange. image