https://github.com/grohith327/simplegan
Tensorflow-based framework to ease training of generative models
https://github.com/grohith327/simplegan
computer-vision deep-learning gan generative-adversarial-network generative-model neural-networks python-library python3 tensorflow
Last synced: 11 months ago
JSON representation
Tensorflow-based framework to ease training of generative models
- Host: GitHub
- URL: https://github.com/grohith327/simplegan
- Owner: grohith327
- License: mit
- Created: 2020-02-17T04:37:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-12T23:56:42.000Z (almost 6 years ago)
- Last Synced: 2025-04-08T18:54:54.432Z (11 months ago)
- Topics: computer-vision, deep-learning, gan, generative-adversarial-network, generative-model, neural-networks, python-library, python3, tensorflow
- Language: Python
- Homepage: https://simplegan.readthedocs.io
- Size: 4.28 MB
- Stars: 19
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleGAN
[](LICENSE) [](https://simplegan.readthedocs.io/en/latest/?badge=latest) [](https://pepy.tech/project/simplegan) [](https://pepy.tech/project/simplegan/month) [](https://github.com/psf/black)
**Framework to ease training of generative models**
SimpleGAN is a framework based on [TensorFlow](https://www.tensorflow.org/) to make training of generative models easier. SimpleGAN provides high level APIs with customizability options to user which allows them to train a generative models with few lines of code or the user can reuse modules from the exisiting architectures to run custom training loops and experiments.
### Requirements
Make sure you have the following packages installed
- [tensorflow](https://www.tensorflow.org/install)
- [tqdm](https://github.com/tqdm/tqdm#latest-pypi-stable-release)
- [imagio](https://pypi.org/project/imageio/)
- [opencv](https://pypi.org/project/opencv-python/)
- [tensorflow-datasets](https://www.tensorflow.org/datasets/overview#installation)
### Installation
Latest stable release:
```bash
$ pip install simplegan
```
Latest Development release:
```bash
$ pip install git+https://github.com/grohith327/simplegan.git
```
### Getting Started
##### DCGAN
```python
from simplegan.gan import DCGAN
## initialize model
gan = DCGAN()
## load train data
train_ds = gan.load_data(use_mnist = True)
## get samples from the data object
samples = gan.get_sample(train_ds, n_samples = 5)
## train the model
gan.fit(train_ds = train_ds)
## get generated samples from model
generated_samples = gan.generate_samples(n_samples = 5)
```
##### Custom training loops for GANs
```python
from simplegan.gan import Pix2Pix
## initialize model
gan = Pix2Pix()
## get generator module of Pix2Pix
generator = gan.generator() ## A tf.keras model
## get discriminator module of Pix2Pix
discriminator = gan.discriminator() ## A tf.keras model
## training loop
with tf.GradientTape() as tape:
""" Custom training loops """
```
##### Convolutional Autoencoder
```python
from simplegan.autoencoder import ConvolutionalAutoencoder
## initialize autoencoder
autoenc = ConvolutionalAutoencoder()
## load train and test data
train_ds, test_ds = autoenc.load_data(use_cifar10 = True)
## get sample from data object
train_sample = autoenc.get_sample(data = train_ds, n_samples = 5)
test_sample = autoenc.get_sample(data = test_ds, n_samples = 1)
## train the autoencoder
autoenc.fit(train_ds = train_ds, epochs = 5, optimizer = 'RMSprop', learning_rate = 0.002)
## get generated test samples from model
generated_samples = autoenc.generate_samples(test_ds = test_ds.take(1))
```
To have a look at more examples in detail, check [here](examples)
### Documentation
Check out the [docs page](https://simplegan.readthedocs.io/en/latest/)
### Provided models
| Model | Generated Images |
| :------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: |
| Vanilla Autoencoder | None |
| Convolutional Autoencoder |  |
| Variational Autoencoder [[Paper](https://arxiv.org/abs/1312.6114)] |  |
| Vector Quantized - Variational Autoencoder [[Paper](https://arxiv.org/abs/1711.00937)] |  |
| Vanilla GAN [[Paper](https://arxiv.org/abs/1406.2661)] |  |
| DCGAN [[Paper](https://arxiv.org/abs/1511.06434)] |  |
| WGAN [[Paper](https://arxiv.org/abs/1701.07875)] |  |
| CGAN [[Paper](https://arxiv.org/abs/1411.1784)] |  |
| InfoGAN [[Paper](https://arxiv.org/abs/1606.03657)] |  |
| Pix2Pix [[Paper](https://arxiv.org/abs/1611.07004)] |  |
| CycleGAN [[Paper](https://arxiv.org/abs/1703.10593)] |  |
| 3DGAN(VoxelGAN) [[Paper](http://3dgan.csail.mit.edu/papers/3dgan_nips.pdf)] |  |
| Self-Attention GAN(SAGAN) [[Paper](https://arxiv.org/pdf/1805.08318.pdf)] |  |
### Contributing
We appreciate all contributions. If you are planning to perform bug-fixes, add new features or models, please file an issue and discuss before making a pull request.
### Citation
```
@software{simplegan,
author = {{Rohith Gandhi et al.}},
title = {simplegan},
url = {https://simplegan.readthedocs.io},
version = {0.2.9},
}
```
### Contributors
- [Rohith Gandhi](https://github.com/grohith327)
- [Prem Kumar](https://github.com/Prem-kumar27)