Download CelebA dataset then crop the image while keeping ratio with here
Create synthesis facemask segmentation dataset on the cropped set with here (orginal code does not provide binary masks, add it yourself)
Folder structure:
this repo
│ train.py
│ trainer.py
│ unet_trainer.py
│
└───configs
│ facemask.yaml
│ segm.yaml
│
└───datasets
│ └───celeba
│ └───images
│ └───celeba512_30k
│ └───celeba512_30k_binary
│ └───celeba512_30k_masked
│ └───annotations
│ | train.csv
│ | val.csv
Put unmasked images in celeba512_30k
, facemasked images in celeba512_30k_masked
, and binary masks in celeba512_30k_binary
Split train/validation then save filepaths to .csv. Example:
,img_name,mask_name
0,celeba512_30k_masked\012653_masked.jpg,celeba512_30k_binary\012653_binary.jpg
1,celeba512_30k_masked\016162_masked.jpg,celeba512_30k_binary\016162_binary.jpg
2,celeba512_30k_masked\011913_masked.jpg,celeba512_30k_binary\011913_binary.jpg
Edit configs on both segm.yaml and facemask.yaml
Follow the same steps above when applying custom dataset
python train.py segm --resume=<resume checkpoint>
python train.py facemask --resume=<resume checkpoint>
Inpainting results on Masked CelebA-512 (from left to right: FaceMasked - Segmented - Inpainted - Ground Truth)
Free-Form Inpainting results on Places365-256 (from left to right: Ground Truth - Masked - Inpainted )