In this project I will implement a DCGAN to see if I can generate handbag designs.
To accomplish this I'm using 3,000 handbag images from Imagenet. These are sample images:
DCGANs were introduced by Alec Radford, Luke Metz and Soumith Chintala in 2016 (paper: https://arxiv.org/pdf/1511.06434.pdf). The following diagram explains the architecture of a DCGAN:
In the paper, the role of the Generator is explained as follows: "A 100 dimensional uniform distribution Z is projected to a small spatial extent convolutional representation with many feature maps. A series of four fractionally-strided convolutions then convert this high level representation into a 64 × 64 pixel image."
After 450 epochs of training, here we can see some handbags created by our DCGAN:
Certainly, GPU saves a lot of time training neural networks, so I had to spend some time to setup a virtual machine in Google Cloud to have access to GPU computing. Given that I didn't find a compehensive tutorial for Windows users, I will share what worked for me.
1. To setup my virtual machine in Google Cloud, I borrowed a virtual machine image from Stanford’s Convolutional Neural Networks course that installs Anaconda, Pytorch and other useful libraries (thanks guys!). I followed this tutorial: http://cs231n.github.io/gce-tutorial/ .
Be careful to select the number of GPUs that you need in order to have access to GPU computing. In my case, I selected 1 NVIDIA Tesla K80 GPU.After finishing the setup of your virtual machine you will get an error message because you don’t have a GPU quota assigned to your virtual machine.
To solve this, you have to go IAM & admin->Quotas in the Google Cloud console, find and select the NVIDIA K80 GPU of your corresponding zone, click “EDIT QUOTAS” and then request access to the number of GPUs that you selected previously (1 in my case).
In my case, it took almost 24 hours to get my quota increased. After that, you are ready to go with your virtual machine!
2. Following the previous tutorial, it is important that you open the terminal:
and make sure to run the following command for the first time setup:
$ /home/shared/setup.sh && source ~/.bashrc
3. Install PuTTY to generate a private key: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
4. Open PuTTY key generator and create a private key:
Make sure to put your Google Cloud username in “Key comment”. After this, save the private key (I saved the key in a file named gcloud_instance_2.ppk)
5. Go to the virtual machine in the Google Cloud console, make sure it is stopped, and click it:
Then click “EDIT”:
And go to SSH Keys and click “Add item” then copy and paste the key generated in the previous step:
Finally, save changes:
6. Download WinSCP: https://winscp.net/eng/download.php to transfer files between local and virtual machine.
To connect, use the external IP of the instance, the user name (prodillo) and in Advanced Settings->SSH-> Authenticate, select the private key file created in the previous step.
7. Finally, if you need to install python libraries, open a SSH terminal as shown in step 2 and type:
$ sudo su root
$ conda install [package name]
For example, I installed the tqdm package typing:
$ conda install tqdm