This is a PyTorch implementation of DCGAN and SimpleGAN that can generate handwritten digits similar to that of a human's.
You can install the required dependency with
pip install -r requirements.txt
And you can just run below to train
python main.py
I've tested on Python 3.7 on Ubuntu, but should work on both Windows and MacOS with most recent versions of Python & Pytorch.
Note, training GANs can take a very long time especially if you're running it on CPU, although it is supported.
With GTX 1660Ti, it took me about 20 minutes of training for simpleGAN with 200 epochs & 128 batch size.
The final model weights are saved in "model_weights" folder after training. I've already included my model weights for both DCGAN and SimpleGAN if you just want to use the model for generating the digits.
Generated images are saved under 'images' folder. Generally, DCGAN outperforms a simple GAN using linear layers, but that can be further improved with more training and fine-tuning of the parameters.
As you train, it would save the generated image from the generator progressively, so you can compare how it has improved over the epochs.
Human digits
SimpleGAN output
DCGAN output
Could still use some work, but not too bad! :)
- Add image generation mode separate from training
- Richie Youm
This project was inspired by deeplearning.ai specialization for GANs. I have referenced their model parameters and visualization techniques for convenience.