Minimal Example to generate StyleGAN HQ face images deployed using Tensorflowjs-node Framework for offline generation in the browser.
Picture: These people are not real – they were produced by Stylegan generator that allows control over different aspects of the image.
The whole setup was tested on WSL for windows, Microsoft Edge browser with WebGL enabled and NVIDIA Geforce 940MX GPU. The warmup took about 10-15 seconds and subsequent generation takes about 3-4 seconds. Any suggestions regarding optimising the performance is welcome. It wasn't tested on any other platform but chances are the browser will crash (will certainty).
To download the pretrained weights for Pretrained StyleGAN on the dataset Flickr-Faces-HQ run the following python script in an environment supporting tensorflow==1.x
python ModelWeightsSaver.pyTo convert the downloaded weights to tensorflow==2.x format, run the following python script :
python Convertor.pyRun the following commant in bash :
pip install tensorflowjs #ignore if tensorflowjs preinstalled in the environment
tensorflowjs_converter \
--input_format=tf_saved_model \
--output_format=tfjs_graph_model \
--signature_name=serving_default \
--saved_model_tags=serve \
/my_model \
/gan-models/styleganInstall the node app using the following command:
npm install
npm install --global http-serverparcel home.htmlYou have to separately host the model files using http-server using the following command in another terminal:(the default port is 8080 and must be kept as is for the demo to run)
http-server --corsThanking Ibraheem Alhashim @ialhashim for Tensorflow-2 Implementation of StyleGAN.