This is a walkthrough for people new to deep learning and GAN, to learn about and be able to run their own GAN. Disclaimer: All of the below is purely for educational purposes!
For the full blogpost, refer to: https://www.yinglinglow.com/blog/2018/02/13/GAN-walkthrough
Full credits go to Rowel Atienza for DCGAN code and keras-contrib for WGAN-GP code.
Generate new brand logos from logos designed by humans
Download the folder of pictures I used, from logos_originals_1367.zip
.
# to center crop and resize the images
python3 1_5_resize_centre.py --path=/Users/xxx/to_resize/ --size=56
# to convert all pictures to one big array and pickle it
python3 1_6_resize_to_array.py --path=/Users/xxx/resized/ --height=56 --target_path=/Users/xxx/ --augment=True
# optional: to upload to AWS S3 using the AWS CLI
aws s3 cp /Users/xxx/X_train_56_1700.pkl s3://yourbucketname/
Work in progress - DCGAN works fine on both AWS and GCP but WGAN can only run on AWS :(
For AWS
Set up your EC2 (p2x.large) instance using the ami 'ami-ccba4ab4' by Adrian Rosebrock on:
https://www.pyimagesearch.com/2017/09/20/pre-configured-amazon-aws-deep-learning-ami-with-python/
Then, install AWSCLI and pandas.
pip3 install awscli
pip3 install pandas
For GCP
Set up your gcloud compute instance using this: https://medium.com/@howkhang/ultimate-guide-to-setting-up-a-google-cloud-machine-for-fast-ai-version-2-f374208be43
Then, install AWSCLI and Keras.
conda install -c anaconda keras-gpu
conda install -c conda-forge awscli
# git clone everything in
git clone https://github.com/yinglinglow/gan_walkthrough.git
cd gan_walkthrough
mkdir gan
mkdir gan_models
# open tmux
tmux
# change your variables accordingly if necessary
export XTRAIN=X_train_56_1366.pkl
export CODE=WGAN_180218_final
export DATE=210218
# run the model
python3 $CODE.py
To save result files to AWS S3 directly
aws s3 cp gan/* s3://yourbucketname/
aws s3 cp gan_models/* s3://yourbucketname/
To save result files to your local computer
Run the below commands from your LOCAL terminal!!
# for AWS
scp -i yourpemfile.pem -r ubuntu@ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com:~/gan_walkthrough/gan/* .<br>
scp -i yourpemfile.pem -r ubuntu@ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com:~/gan_walkthrough/gan_models/* .
# for GCP
gcloud compute scp yourinstancename:gan_walkthrough/gan/* .
2) WGAN-GP (56x56)
Epoch: 2000
Epoch: 2500
3) WGAN-GP (112x112)
Epoch: 2500