This repository implements training and inference methods of GAN with just fc layers on MNIST.
![GAN Tutorial](https://private-user-images.githubusercontent.com/144267687/302553167-3fe95fbd-1340-4396-ae92-66c59b3f0013.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMTI2OTUsIm5iZiI6MTcyNDAxMjM5NSwicGF0aCI6Ii8xNDQyNjc2ODcvMzAyNTUzMTY3LTNmZTk1ZmJkLTEzNDAtNDM5Ni1hZTkyLTY2YzU5YjNmMDAxMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxOFQyMDE5NTVaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05MjhmNDM3YzBiNjRiZTllNzU2MDJjYmJjZjdmN2IwMTJkYjk0MzAxZWVjZDRlYzQ0MThhZDFhMjE5NWQxM2NkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.sGxB5Wtj9WN-HHzTkCn7WCJHKROAmzGVvhQNdrwdd5U)
![](https://private-user-images.githubusercontent.com/144267687/292857810-4e1fd994-6ec0-4e21-aeee-6b054e72ddab.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMTI2OTUsIm5iZiI6MTcyNDAxMjM5NSwicGF0aCI6Ii8x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W16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lYWJkYjBmMTNmZGY3OGQzMjdiYTAzYTU3ZDY4NTM1ZjBkNGZlYmFiZmFjYzRkOWU2NDA4MzM1NzIxY2MwYTQ5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.RXBsBakrlLkt7hA4kresEIhxPzR-MqAgos5B7e8Azu8)
For setting up the mnist dataset:
Follow - https://github.com/explainingai-code/Pytorch-VAE#data-preparation
The directory structure should look like this
$REPO_ROOT
-> data
-> train
-> images
-> 0
*.png
-> 1
...
-> 9
*.png
-> test
-> images
-> 0
*.png
...
-> dataset
-> tools
- Create a new conda environment with python 3.8 then run below commands
git clone https://github.com/explainingai-code/GANs-Pytorch.git
cd GANs-Pytorch
pip install -r requirements.txt
python -m tools.train_gan
for training and saving inference samples
- Ensure dataset is prepared according to the Data Preparation instructions
- Change the
IM_CHANNELS
field to 3 intrain_gan.py
- Uncomment lines 56-59 in the
dataset/mnist_dataset.py
file
- Dump all *.png files(or whatever format images you have) in the path
data/train/images
- Comment https://github.com/explainingai-code/GANs-Pytorch/blob/main/dataset/mnist_dataset.py#L43
- Directory structure should be following:
data
-> train
-> images
*.png
- Change the
IM_PATH
field todata/train
intrain_gan.py
- Change the channels and image sizes accordingly
Outputs will be saved every 50 steps in samples
directory .
During training of GAN the following output will be saved
- Latest Model checkpoints for generator and discriminator in
$REPO_ROOT
directory
During inference every 50 steps the following output will be saved
- Sampled image grid for in
samples/*.png
@misc{goodfellow2014generative,
title={Generative Adversarial Networks},
author={Ian J. Goodfellow and Jean Pouget-Abadie and Mehdi Mirza and Bing Xu and David Warde-Farley and Sherjil Ozair and Aaron Courville and Yoshua Bengio},
year={2014},
eprint={1406.2661},
archivePrefix={arXiv},
primaryClass={stat.ML}
}