Official repository for the paper DCFace: Synthetic Face Generation with Dual Condition Diffusion Model (CVPR 2023).
install.sh
If above fails, then
pip install -r requirements.txt
# and download model weights from the link below
We provide the sample code to generate images with the pretrained weights. The sample aligned images are provided in the repository.
pretrained_models
directory under dcface
(same level as src
)cd dcface/src
python synthesis.py --id_images_root sample_images/id_images/sample_57.png --style_images_root sample_images/style_images/woman
One can also generate new subject images and prepare custom style images.
Unconditional ID image generation is done in dcface/stage1/unconditional_generation
Take a look at the README.md
in that directory for instructions on how to generate new ID images.
Any aligned images can serve as style images. We provive some sample images in sample_images/style_images
directory.
For anyone who wants to use their own style images, one should align the images first.
Take a look at the README.md
in dcface/stage1/style_bank
directory for instructions on how to align images.
Assuming that you followed 1. and 2. you will have an id_image
and style_images
directory.
For the sake of explaination, let's say
<Project_root>/dcface/stage1/unconditional_generation/unconditional_samples_aligned/00011.png
<Project_root>/dcface/stage1/style_bank/style_images/raw_aligned
Then to combine these run by pointing at these paths,
cd dcface/src
python synthesis.py \
--id_images_root <Project_root>/dcface/stage1/unconditional_generation/unconditional_samples_aligned/00011.png \
--style_images_root <Project_root>/dcface/stage1/style_bank/style_images/raw_aligned
The result will be saved at <Project_root>/dcface/generated_images/
$DATA_ROOT
(ex: /data/
). /data/faces_webface_112x112
pretrained_models
directory under dcface
(same level as src
)cd dcface/src/
bash train.sh
DCFace synthetic dataset can be downloaded from link
The format of the downloaded file is in rec
format.
png
using the script. cd dcface/convert
python record.py --rec_path <path_to_rec_file> --save_path <path_to_save_png>
# ex
# <path_to_rec_file> : dcface_0.5m_oversample_xid/record
# <path_to_save_png> : dcface_0.5m_oversample_xid/images