Welcome to KUNGFU.AI's 2019 SXSW StyleGAN demo. First off much thanks to Dmitry Nikitko (Puzer) from whom we forked the repo. Our demo is mostly focused in the jupyter notebook "StyleGAN demo.ipynb." You might need to edit "aei.py" and point it to the correct directory. Latent codes for a few celebrities along with some supremely handsome KUNGFU.AI employees can be found in /latent_codes (shocker), and the previews of them can be seen in img_gen. If you have questions, concerns, criticisms, or jokes, please open a pull request or issue! Even just adding latent codes would be very welcomed.
The following text is Puzer's README explaining latent code recovery.
These people are real – latent representation of them was found by using perceptual loss trick. Then this representations were moved along "smiling direction" and transformed back into images
Short explanation of encoding approach: 0) Original pre-trained StyleGAN generator is used for generating images
- Pre-trained VGG16 network is used for transforming a reference image and generated image into high-level features space
- Loss is calculated as a difference between them in the features space
- Optimization is performed only for latent representation which we want to obtain.
- Upon completion of optimization you are able to transform your latent vector as you wish. For example you can find a "smiling direction" in your latent space, move your latent vector in this direction and transform it back to image using the generator.
New scripts for finding your own directions will be realised soon. For now you can play with existing ones: smiling, age, gender. More examples you can find in the Jupyter notebook
You can generate latent representations of your own images using two scripts:
- Extract and align faces from images
python align_images.py raw_images/ aligned_images/
- Find latent representation of aligned images
python encode_images.py aligned_images/ generated_images/ latent_representations/
- Then you can play with Jupyter notebook
Feel free to join the research. There is still much room for improvement:
- Better model for perceptual loss
- Is it possible to generate latent representations by using other model instead of direct optimization ? (WIP)
Stay tuned!