Skip to content

ashzblum/streamlit_tl_gan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is the repository for Streamlit’s FaceGAN demo, built on Shaobo Guan’s TL-GAN project for image synthesis of faces with controllable parameters like gender, age, baldness, skin tone, and smile.

1. Introduction

Progressively Growing Generative Adversarial Networks (PG-GANs) are a cutting edge method for creating random synthetic images. Examples of amazingly realistic faces generated from a PG-GAN trained on celebrities can be seen in NVidia's PG-GAN demo. For each random vector in the generative network's latent space, it outputs a different face. Shaobo Guan's TL-GAN project uses automated face categorizers to identify directions in the latent space that correspond to desired modifications of the generated image, making it older, balder, more female, or dozens of other possible transformations. Streamlit gives us a rapidfire way to explore TL-GAN in an interactive web app. Using @st-cache with the hash_funcs variable, we can make sure that our TensorFlow session and trained GAN model are preserved each time the app re-runs, making for snappy, responsive execution even when we're hacking away at the code.

2. Instructions for running locally

This demo requires a CUDA-compatible GPU and Python 3.6 (TensorFlow is not yet compatible with Python 3.7 or 3.8).

2.1 Install the code, dependencies, and models

  1. Clone this repository: git clone https://github.com/streamlit/streamlit_tl_gan_demo.git
  2. Create a new Python 3.6 virtual environment using venv, virtualenv, pyenv, or conda
  3. From the project’s root directory, install dependencies: pip install -r requirements.txt
  4. Download Nvidia's pre-trained pg-GAN model and Shao Bo's pre-fitted feature model
  5. Decompress in the project's root directory: tar xvzf asset_model.tar.gz; tar xzvf asset_results.tar.gz

2.2 Run the demo using Streamlit

  1. From the project's root directory, type streamlit run src/tl_gan/streamlit_tl_demo.py

  2. Your default web browser should pop up with an interactive app that will let you play with the model.

  3. Have fun! Notice that faces you've seen before generate faster, thanks to Streamlit's handy built-in cache.

3. More Background

Generative Adversarial Networks, or GANs, are one of the most exciting recent developments in machine learning. In order for a generative neural network to learn how to generate random samples from a complicated distribution---for instance, photorealistic images of human faces---the network is pitted in competition against a discriminative network which gets better and better at distinguishing the generative network's fakes from the real thing. NVidia recently extended the GAN framework with Progressively-Growing GAN, or PG-GAN, training networks on very low-resolution images at first and then incrementally extending them to higher resolutions.

About

Use Streamlit to explore Shaobo Guan's TL-GAN method for image synthesis and control

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 96.6%
  • Jupyter Notebook 3.4%