Generating photorealistic faces from edge maps using Conditional GANs (Pix2PixHD)
Welcome to the Pix2PixHD: Edges to Faces project! In this repository, I’ve implemented and trained a modified Pix2PixHD model to generate high-resolution (1024x1024) photorealistic face images from edge maps using the CelebA-HQ dataset. This project extends the groundbreaking work presented in “High-Resolution Image Synthesis and Semantic Manipulation with Conditional GANs”, providing an exciting tool for tasks such as sketch-based image synthesis and image editing.
The model takes edge maps as input and generates stunning, realistic face images. Below are some results from Phase 1 of training:
Input (Edge Map) | Output (Generated Image) |
---|---|
These outputs are produced using Global Generator with 512x512 resolution, giving exceptional detail and realism!
This implementation is based on the paper “High-Resolution Image Synthesis and Semantic Manipulation with Conditional GANs” by Ting-Chun Wang, Ming-Yu Liu, Jun-Yan Zhu, and others. Pix2PixHD builds on the standard Pix2Pix architecture to produce images with higher resolutions and fidelity, especially useful for tasks such as semantic image synthesis.
/data
: Contains the dataset preprocessing scripts and edge map generation using Canny edge detection../
: The core PyTorch implementation of Pix2PixHD, including Global Generator, Local Enhancer, and the multi-scale Discriminators./output
: The generated outputs from the model.train.py
: Script for training the model on edge-to-image task.
To get started, make sure you have the following installed:
- Python 3.12.x
- PyTorch 2.4.x with CUDA
- Clone the repository:
git clone https://github.com/inventwithdean/pix2pixhd.git cd pix2pixhd
- Download the CelebA-HQ dataset and place it in the
/data
folder. You can find it here. - Make sure you have all the faces inside
data/faces
folder. And create a directorydata/sketches
. - Generating edge maps:
python create_dataset.py
To train the model on the edge-to-face task, run:
python train.py
Create directories enhanced_checkpoints
and global_checkpoints
for checkpointing.
- High-Resolution Synthesis: Generates 1024x1024 images from edge maps.
- Conditional GAN Architecture: Uses multi-scale discriminators for improved realism.
- Instance-Level Control (WIP): Planned updates for fine-tuning specific features in generated images.
- Instance-wise control for fine-grained editing of facial features.
- Further improvements to training strategies for faster convergence.
- Integration of new datasets for generalization beyond CelebA-HQ.
Feel free to fork this repo, submit issues, or make pull requests. Contributions are always welcome to improve the codebase!
If you have any questions or feedback, feel free to reach out to me via LinkedIn or open an issue on GitHub.
This work is inspired by the original Pix2PixHD implementation by NVIDIA and the creators of the CelebA-HQ dataset.
Enjoy experimenting! If you like the project, don’t forget to give it a ⭐ on GitHub!