yinguobing / facial-landmark-detection-hrnet

A TensorFlow implementation of HRNet for facial landmark detection.
GNU General Public License v3.0
157 stars 40 forks source link

asking about dataset creation #4

Closed glmanhtu closed 3 years ago

glmanhtu commented 3 years ago

Hello @yinguobing, thank for your code.

One thing I'm not really understand about the creation of dataset for training. From your description, we need use the code in repository: https://github.com/yinguobing/face-mesh-generator to generate the 'Cropped' images, which is from this line: https://github.com/yinguobing/face-mesh-generator/blob/master/generate_heatmap_dataset.py#L131. So, I need to write some piece of code to save the 'image_resized' and 'mark_resized' somewhere else to constructing the dataset, is it correct ?

I see that you use the cropped and centered images as training data. However, for the real image, the face will not be in the center, therefore, I think this preprocessing will reduce the capability of the model isn't it ?

yinguobing commented 3 years ago

Hi @glmanhtu, glad you find this repo!

For the first question the answer is yes, you need to write some code to save the resized image and marks, and I recommand using FMD's universal format which basicly save the marks in a json file, which is the default format this repo support. You can find out how the training data is constructed here:

https://github.com/yinguobing/facial-landmark-detection-hrnet/blob/db1b0f6b1cd3ec5b189b8b854b0347260afb3e44/dataset.py#L11

And to export marks in an universal format, check out this function:

https://github.com/yinguobing/facial-landmark-detection-hrnet/blob/db1b0f6b1cd3ec5b189b8b854b0347260afb3e44/fmd/mark_dataset/data_pair.py#L70

For the second question, I need to clarify that the model was designed that way. It needs a proper input image to give correct facial landmarks. Most of the time a face detector is required to crop the target face area and send them as inputs for inference. If reading carefully you will find that all input images were randomly scaled, but, as you said they are still 'centered'. So randomly cropping the image as a way of data augmentation is promissing for giving a better model.

glmanhtu commented 3 years ago

Awesome, thank you a lot

yinguobing commented 3 years ago

Tips: anyone interersted in resampling the dataset, please checkout this module:

https://github.com/yinguobing/face-mesh-generator/blob/features/export-for-mark-regression/generate_mesh_dataset.py

Still, you need to write custom code if any preprocessing is required.