This repo trains a Deep Convolutional Generative Adversarial Network (DCGAN) to generate faces. The motivation for this program was the 4th project in the Udacity Deep Learning Nanodegree.
This project can be executed directly from within the dlnd_face_generation.ipynd Jupyter notebook. Due to the time required to train the model, it is recommended that a GPU is used. The output shown in the report and notebook were generated on AWS' Deep Learning AMI (Ubuntu 18.04) Version 26.0 with a p2.xlarge instance.
-
Launch your AWS instance and ssh into it.
- Remember to add a "Custom TCP Rule" to your security group inbound rules to allow Jupyter notebooks.
-
Configure Jupyter notebook
jupyter notebook --generate-config sed -ie "s/#c.NotebookApp.ip = 'localhost'/#c.NotebookApp.ip = '*'/g" ~/.jupyter/jupyter_notebook_config.py
-
Clone the repo.
git clone https://github.com/daniel-fudge/dlnd-DCGAN-Face-Generation.git
-
Download the input files (you can replaces with your own files) and unzip.
cd dlnd-DCGAN-Face-Generation wget https://s3.amazonaws.com/video.udacity-data.com/topher/2018/November/5be7eb6f_processed-celeba-small/processed-celeba-small.zip unzip processed-celeba-small.zip rm *.zip rm -r __MACOSX
-
Activate Python 3 environment with PyTorch, CUDA 10 and MKL-DNN. Then install cv2.
source activate pytorch_p36 conda install opencv
-
Start Jupyter notebook
jupyter notebook --ip=0.0.0.0 --no-browser
-
Record the long URL generated by the previous command, it should have the format http://[some_ip]:8888/?token=[your_token].
-
Connect to the notebook from your browser by replacing [some_ip] with your instances IPv4 Public IP.
-
Open
dlnd_face_generation.ipynb
. -
Read and/or run the cells at your leisure!! :)
Although it is not recommended to train on a local PC, you may want to run locally to debug.
-
Clone repo to PC.
git clone https://github.com/daniel-fudge/dlnd-DCGAN-Face-Generation.git
-
Download processed-celeba-small.zip and unzip into dlnd-DCGAN-Face-Generation folder.
-
[OPTIONAL] Delete the zip file and any miscellaneous OS X files or folders such as
__MACOSX
or.DS_Store
. -
[OPTIONAL] Install Anaconda3.
-
[OPTIONAL] Create a virtual environment.
conda update conda conda create -n pytorch_p36 python=3.7 conda activate pytorch_p36 conda install pytorch conda install -c pytorch torchvision conda install opencv conda install matplotlib conda install tqdm
-
[OPTIONAL] Activate the virtual environment.
conda activate pytorch_p36
-
Launch Jupyter.
cd dlnd-DCGAN-Face-Generation jupyter notebook
-
Read and/or run the cells at your leisure!! :)
A report was generated from the Jupyter Notebook for those who prefer html files.
This code is copyright under the MIT License.
Please feel free to raise issues against this repo if you have any questions or suggestions for improvement.