sicxu / Deep3dPortrait

Deep 3D Portrait from a Single Image
MIT License
384 stars 72 forks source link

Landmark detection #9

Closed cravisjan97 closed 4 years ago

cravisjan97 commented 4 years ago

I am currently using the https://github.com/1adrianb/face-alignment for 2D landmark detection. I am running the following code snippet:

import face_alignment
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=False)
img = cv2.imread('./examples/1_1234.jpg')
preds = fa.get_landmarks(img)[0] # (68,2)

But the 2D landmark points I get are very different from the ones in the ./examples/1_1234_landmark.txt. Am I using the right landmark package for this model?

Thanks in advance

sicxu commented 4 years ago

Hi, could you provide more details about the differences ?

cravisjan97 commented 4 years ago

@sicxu Thank you for the reply!!!

The difference is as follows:

snapshot00

The above snapshot is obtained using your example mask(./examples/1_1234.mat) and example landmark(./examples/1_1234_landmark.txt) files

snapshot00

The above snapshot is obtained using your example mask ('./examples/1_1234.mat) and the landmark detection generated from the above code snippet.

There is a clear change in the quality of the 3D models generated.

sicxu commented 4 years ago

Sorry for the missing description, the provided landmarks in ./examples are defined in 3D sapce coordinates (X-Y plane). You can apply the following tranform to Bulat et al.'s results. Also, the landmarks should be 3D definition for better performance. https://github.com/sicxu/Deep3dPortrait/blob/fad83d78cea303eb3da24afd59fac960eb3f6f38/utils/preprocess.py#L150

image The differece between two kinds of coordinates. Red points: draw the landmark in ./examples directly onto image plane; Blue points: after apply the transform.

cravisjan97 commented 4 years ago

Thanks a lot @sicxu. Now it works!!!

jly0810 commented 2 years ago

非常感谢@sicxu。现在它起作用了!!!

I want to use my photos to generate a 3D portrait model.I have generated the landmark.txt file according to your method .And I'd like to ask you how to generate the detection.txt files and the .mat file?