GenerativeZoo
GenerativeZoo copied to clipboard
Model Zoo for Generative Models.
GenerativeZoo
A collection of generative algorithms and techniques implemented in Python.
This work is part of the Xecs TASTI project, nr. 2022005.
Prerequisites
You will need:
python(seepyproject.tomlfor full version)GitMake- a
.secretsfile with the required secrets and credentials - load environment variables from
.env NVIDIA Drivers(mandatory) andCUDA >= 12.1(mandatory if Docker is not used)Weights & Biasesaccount
Installation
Clone this repository (requires git ssh keys)
git clone --recursive [email protected]:caetas/GenerativeZoo.git
cd generativezoo
Using Docker
Create the image using the provided Dockerfile and then run the container:
docker build --tag generativezoo .
docker create --gpus all --shm-size=1g -i --name generativezoo_container generativezoo
docker start generativezoo_container
To access the shell, please run:
docker exec -it generativezoo_container /bin/bash
Note: Edit the Dockerfile if you want to include data or model checkpoints in your image.
Normal Installation
or if environment already exists
conda env create -f environment.yml
conda activate python3.10
On Linux
And then setup all virtualenv using make file recipe
(python3.10) $ make setup-all
You might be required to run the following command once to setup the automatic activation of the conda environment and the virtualenv:
direnv allow
Feel free to edit the .envrc file if you prefer to activate the environments manually.
On Windows
You can setup the virtualenv by running the following commands:
python -m venv .venv-dev
.venv-dev/Scripts/Activate.ps1
python -m pip install --upgrade pip setuptools
python -m pip install -r requirements/requirements.txt
To run the code please remember to always activate both environments:
conda activate python3.10
.venv-dev/Scripts/Activate.ps1
Models
Implemented Models
The listed models are already implemented and fully integrated in the model zoo. Models with 🚀 support Multi-GPU and Mixed Precision training using Accelerate. Models with 📦 support a latent space implementation with the flag --latent.
VAEs
- Vanilla VAE
Paper|Code1 |Script|Documentation - Conditional VAE
Paper|Code1 |Script|Documentation - Hierarchical VAE
Paper|Code2 |Script|Documentation
GANs
- Adversarial VAE
Paper|Code1 |Script|Documentation - DC-GAN
Paper|Code3 |Script|Documentation - Conditional GAN
Paper|Code3 |Script|Documentation - CycleGAN
Paper|Code4 |Script|Documentation - Prescribed GAN
Paper|Code5 |Script|Documentation - Wasserstein GAN with Gradient Penalty
Paper|Code6 |Script|Documentation
DDPMs
- DDPM🚀📦
Paper|Code7,8,9,21 |Script|Documentation - Conditional DDPM🚀📦
Paper|Code10,21 |Script|Documentation - Diffusion AE
Paper|Code11 |Script|Documentation
Score Matching
Autoregressive
- VQ-VAE + Transformer
Paper|Code11 |Script|Documentation - VQ-GAN + Transformer
Paper|Code11 |Script|Documentation - PixelCNN
Paper|Code14 |Script|Documentation
Normalizing Flows
- Vanilla Flow
Paper|Code14 |Script|Documentation - RealNVP
Paper|Code15 |Script|Documentation - Glow
Paper|Code16 |Script|Documentation - Flow++
Paper|Code17 |Script|Documentation
Flow Matching
- Flow Matching🚀📦
Paper|Code18,21 |Script|Documentation - Conditional Flow Matching🚀📦
Paper|Code18,21 |Script|Documentation - Rectified Flows🚀📦
Paper|Code19 |Script|Documentation
Stable Diffusion
- Stable Diffusion + LoRA🚀
Paper|Code20 |Script|Documentation - ControlNet🚀
Paper|Code20 |Script|Documentation - InstructPix2Pix🚀
Paper|Code20 |Script|Documentation
Multi-GPU support and Mixed Precision
Accelerate should be configured for your hardware setup using:
accelerate config
The models that support these features should be launched with:
accelerate launch --multi_gpu --mixed_precision=fp16 --num_processes=2 {script_name.py} {--arg1} {--arg2} ...
Datasets
The following datasets are ready to be used to train and sample from the provided models. They are automatically downloaded when you try to use them for the first time.
Grayscale
- MNIST
Source - FashionMNIST
Source - ChestMNIST++
Source - OctMNIST++
Source - PneumoniaMNIST++
Source - TissueMNIST++
Source
RGB
- CIFAR-10
Source - CIFAR-100
Source - SVHN
Source - Places365
Source - DTD
Source - TinyImageNet
SourceMANUAL DOWNLOAD REQUIREDLink - Horse2Zebra
SourceMANUAL DOWNLOAD REQUIREDLink - ImageNet-1k
Source
Tracking
The code examples are setup to use Weights & Biases as a tool to track your training runs. Please refer to the full documentation if required or follow the following steps:
-
Create an account in Weights & Biases
-
If you have installed the requirements you can skip this step. If not, activate the conda environment and the virtualenv and run:
pip install wandb -
Run the following command and insert you
API keywhen prompted:wandb login
If you want to fully disable Weights & Biases during training, use the flag --no_wandb.
If you want to turn off syncing with the server but want to retain the local copy, run:
wandb offline
Repository Information
Documentation
Full documentation is available here: docs/.
Dev
See the Developer guidelines for more information.
Contributing
Contributions of any kind are welcome. Please read CONTRIBUTING.md for details and the process for submitting pull requests to us.
Please read MODELRULES.md for details on how you should build your models for this repository.
Security
Thank you for improving the security of the project, please see the Security Policy for more information.
License
This project is licensed under the terms of the CC-BY-4.0 license.
See LICENSE for more details.
References
All the repositories used to generate this code are mentioned in each of the corresponding files and referenced in Implemented Models:
- PyTorch-VAE
- nvae
- conditional-GAN
- PyTorch-GAN
- PresGANs
- wgan-gp
- minDiffusion
- DenoisingDiffusionProbabilisticModels
- ddim
- Conditional_Diffusion_MNIST
- Generative Models
- SGM Tutorial
- score_sde_pytorch
- uvadlc_notebooks
- real-nvp
- Glow-PyTorch
- flowplusplus
- conditional-flow-matching
- minRF
- diffusers
- guided-diffusion
Citation
If you publish work that uses GenerativeZoo, please cite GenerativeZoo as follows:
@misc{GenerativeZoo,
author = {Francisco Caetano},
title = {A collection of generative algorithms and techniques implemented in Python.},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/caetas/GenerativeZoo}},
year = {2024},
}