Our method takes in one or a few hand-drawn sketches and customizes an off-the-shelf GAN to match the input sketch. While our new model changes an object’s shape and pose, other visual cues such as color, texture, background, are faithfully preserved after the modification.
Sheng-Yu Wang1, David Bau2, Jun-Yan Zhu1.
CMU1, MIT CSAIL2
In ICCV, 2021.
Training code, evaluation code, and datasets will be released soon.
Our method can customize a pre-trained GAN to match input sketches.
Interpolation using our customized models. Latent space interpolation is smooth with our customized models.
Image 1 |
Interoplation |
Image 2 |
Image editing using our customized models. Given a real image (a), we project it to the original model's latent space z using Huh et al. (b). (c) We then feed the projected z to the our standing cat model trained on sketches. (d) Finally, we showed edit the image with add fur
operation using GANSpace.
Failure case. Our method is not capable of generating images to match the Attneave’s cat sketch or the horse sketch by Picasso. We note that Attneave’s cat depicts a complex pose, and Picasso’s sketches are drawn with a distinctive style, both of which make our method struggle.
git clone git@github.com:PeterWang512/GANSketching.git
cd GANSketching
- Install PyTorch (version >= 1.6.0) (pytorch.org)
pip install -r requirements.txt
- Run
bash weights/download_weights.sh
This command runs the customized model specified by ckpt
, and generates samples to save_dir
.
# generates samples from the "standing cat" model.
python generate.py --ckpt weights/photosketch_standing_cat_noaug.pth --save_dir output/samples_standing_cat
# generates samples from the cat face model in Figure. 1 of the paper.
python generate.py --ckpt weights/by_author_cat_aug.pth --save_dir output/samples_teaser_cat
Our model preserves the latent space editability of the original model. Our models can apply the same edits using the latents reported in Härkönen et.al. (GANSpace).
# add fur to the standing cats
python ganspace.py --obj cat --comp_id 27 --scalar 50 --layers 2,4 --ckpt weights/photosketch_standing_cat_noaug.pth --save_dir output/ganspace_fur_standing_cat
# close the eyes of the standing cats
python ganspace.py --obj cat --comp_id 45 --scalar 60 --layers 5,7 --ckpt weights/photosketch_standing_cat_noaug.pth --save_dir output/ganspace_eye_standing_cat
This repository borrows partially from SPADE, stylegan2-pytorch, PhotoSketch, GANSpace, and data-efficient-gans.
If you find this useful for your research, please cite the following work.
@inproceedings{wang2021sketch,
title={Sketch Your Own GAN},
author={Wang, Sheng-Yu and Bau, David and Zhu, Jun-Yan},
booktitle={Proceedings of the IEEE International Conference on Computer Vision},
year={2021}
}
Feel free to contact us with any comments or feedback.