All Projects → wittawatj → Cadgan

wittawatj / Cadgan

Licence: mit
ICML 2019. Turn a pre-trained GAN model into a content-addressable model without retraining.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Cadgan

coursera-gan-specialization
Programming assignments and quizzes from all courses within the GANs specialization offered by deeplearning.ai
Stars: ✭ 277 (+1357.89%)
Mutual labels:  generative-adversarial-network, generative-model
favorite-research-papers
Listing my favorite research papers 📝 from different fields as I read them.
Stars: ✭ 12 (-36.84%)
Mutual labels:  generative-adversarial-network, generative-model
pytorch-GAN
My pytorch implementation for GAN
Stars: ✭ 12 (-36.84%)
Mutual labels:  generative-adversarial-network, generative-model
Wgan
Tensorflow Implementation of Wasserstein GAN (and Improved version in wgan_v2)
Stars: ✭ 228 (+1100%)
Mutual labels:  generative-adversarial-network, generative-model
celeba-gan-pytorch
Generative Adversarial Networks in PyTorch
Stars: ✭ 35 (+84.21%)
Mutual labels:  generative-adversarial-network, generative-model
Sgan
Stacked Generative Adversarial Networks
Stars: ✭ 240 (+1163.16%)
Mutual labels:  generative-adversarial-network, generative-model
GraphCNN-GAN
Graph-convolutional GAN for point cloud generation. Code from ICLR 2019 paper Learning Localized Generative Models for 3D Point Clouds via Graph Convolution
Stars: ✭ 50 (+163.16%)
Mutual labels:  generative-adversarial-network, generative-model
Stylegan2 Pytorch
Simplest working implementation of Stylegan2, state of the art generative adversarial network, in Pytorch. Enabling everyone to experience disentanglement
Stars: ✭ 2,656 (+13878.95%)
Mutual labels:  generative-adversarial-network, generative-model
TriangleGAN
TriangleGAN, ACM MM 2019.
Stars: ✭ 28 (+47.37%)
Mutual labels:  generative-adversarial-network, generative-model
py-msa-kdenlive
Python script to load a Kdenlive (OSS NLE video editor) project file, and conform the edit on video or numpy arrays.
Stars: ✭ 25 (+31.58%)
Mutual labels:  generative-adversarial-network, generative-model
Triple Gan
See Triple-GAN-V2 in PyTorch: https://github.com/taufikxu/Triple-GAN
Stars: ✭ 203 (+968.42%)
Mutual labels:  generative-adversarial-network, generative-model
Alae
[CVPR2020] Adversarial Latent Autoencoders
Stars: ✭ 3,178 (+16626.32%)
Mutual labels:  generative-adversarial-network, generative-model
Neuralnetworks.thought Experiments
Observations and notes to understand the workings of neural network models and other thought experiments using Tensorflow
Stars: ✭ 199 (+947.37%)
Mutual labels:  generative-adversarial-network, generative-model
MMD-GAN
Improving MMD-GAN training with repulsive loss function
Stars: ✭ 82 (+331.58%)
Mutual labels:  generative-adversarial-network, generative-model
Dragan
A stable algorithm for GAN training
Stars: ✭ 189 (+894.74%)
Mutual labels:  generative-adversarial-network, generative-model
simplegan
Tensorflow-based framework to ease training of generative models
Stars: ✭ 19 (+0%)
Mutual labels:  generative-adversarial-network, generative-model
Semantic image inpainting
Semantic Image Inpainting
Stars: ✭ 140 (+636.84%)
Mutual labels:  generative-adversarial-network, generative-model
Conditional Gan
Anime Generation
Stars: ✭ 141 (+642.11%)
Mutual labels:  generative-adversarial-network, generative-model
pytorch-CycleGAN
Pytorch implementation of CycleGAN.
Stars: ✭ 39 (+105.26%)
Mutual labels:  generative-adversarial-network, generative-model
Generative models tutorial with demo
Generative Models Tutorial with Demo: Bayesian Classifier Sampling, Variational Auto Encoder (VAE), Generative Adversial Networks (GANs), Popular GANs Architectures, Auto-Regressive Models, Important Generative Model Papers, Courses, etc..
Stars: ✭ 276 (+1352.63%)
Mutual labels:  generative-adversarial-network, generative-model

Content ADdressable GAN (CADGAN)

Repository containing resources from our paper:

Kernel Mean Matching for Content Addressability of GANs
Wittawat Jitkrittum,*, Patsorn Sangkloy,* Muhammad Waleed Gondal, Amit Raj, James Hays, Bernhard Schölkopf
ICML 2019
(* Equal contribution)
https://arxiv.org/abs/1905.05882
  • Full paper: main text + supplement on arXiv (file size: 36MB)
  • Main text only here (file size: 7.3MB)
  • Supplementary file only here (file size: 32MB)

We propose a novel procedure which adds content-addressability to any given unconditional implicit model e.g., a generative adversarial network (GAN). The procedure allows users to control the generative process by specifying a set (arbitrary size) of desired examples based on which similar samples are generated from the model. The proposed approach, based on kernel mean matching, is applicable to any generative models which transform latent vectors to samples, and does not require retraining of the model. Experiments on various high-dimensional image generation problems (CelebA-HQ, LSUN bedroom, bridge, tower) show that our approach is able to generate images which are consistent with the input set, while retaining the image quality of the original model. To our knowledge, this is the first work that attempts to construct, at test time, a content-addressable generative model from a trained marginal model.

Examples

We consider a GAN model from Mescheder et al., 2018 pretrained on CelebA-HQ. We run our proposed procedure using the three images (with border) at the corners as the input. All images in the triangle are the output from our procedure. Each of the output images is positioned such that the closeness to a corner (an input image) indicates the importance (weight) of the corresponding input image.

Demo

For a simple demo example on MNIST, check out this Colab notebook. No local installation is required.

Code

  • Support Python 3.6+.

  • Require Pytorch 0.4.1. Require a GPU with ideally no less than 4GB of memory.

  • Automatic dependency resolution only works with a new version of pip. First upgrade you pip with pip install --upgrade pip.

  • If you use Anaconda, consider creating a new environment before installing cadgan.

      conda create -n cadgan pytorch=0.4.1
    

    where cadgan in the above command is an arbitrary name for the environment.

  • Activate the environment with conda activate cadgan. You might want to install Jupyter notebook with conda install jupyter.

  • Make you you activate the environment first. Then, install the cadgan package. This repo is set up so that once you clone, you can do

      pip install -e /path/to/the/folder/of/this/repo/
    

    to install as a Python package. In Python, we can then do import cadgan as cdg, and all the code in cadgan folder is accessible through cdg.

Dependency, code structure, sharing resource files

You will need to change values in settings.ini to your local path. This is important since we will be using relative path in the script.

  • Results will be saved in expr_results_path
  • data_path should point to where you store all your input data
  • problem_model_path will be used for storing various pre-trained models (warning: this can be quite large)
  • See comment in settings.ini for more details

We provide an example script to run CADGAN in ex/run_gkmm.py

For example, here is the command to run CADGAN for celebAHQ dataset on Mescheder et al., 2018's pre-trained model:

python3 run_gkmm.py \
    --extractor_type vgg_face \
    --extractor_layers 35 \
    --texture 0\
    --depth_process no \
    --g_path celebAHQ_00/chkpts/model.pt \
    --g_type celebAHQ.yaml \
    --g_min -1.0 \
    --g_max 1.0 \
    --logdir log_celeba_face/ \
    --device gpu \
    --n_sample 1 \
    --n_opt_iter 1000 \
    --lr 5e-2 \
    --seed 99 \
    --img_log_steps 500 \
    --cond_path  celebaHQ/ \
    --kernel imq \
    --kparams -0.5 1e+2 \
    --img_size 224
  • The above command will use all images in [data_path]/celebaHQ/ as conditional images, with the generator from [problem_model_path]/celebAHQ_00/chkpts/model.pt and then store results in [expr_results_path]/log_celeba_face/. When this is run for the first time, the GAN model will be downloaded automatically. The required feature extractor (VGG face, in this case) will also be downloaded automatically. Downloading these models may take some time. The size of each model is roughly 300-600 MB. The results are written to a Tensorboard log folder. Simply use Tensorboard to see the result. This can be done by, for instance,

      ./cadgan/ex/start_tensorboard.sh [expr_results_path]/log_celeba_face/
    
  • Note that possible value of g_type are lsun_bedroom.yaml lsun_bridge.yaml celebAHQ.yaml lsun_tower.yaml mnist_dcgan colormnist_dcgan. If the specified generator doesn't exist yet, the code will download the pre-trained model used in the paper into the specified location.

See run_lars_bedroom.sh, run_lars_bridge.sh, run_lars_tower.sh, run_mnist.sh and run_mnist_color.sh for other model options.

We also provide 2 example images for each of the dataset in data/ that can be used for testing.

In case you want to experiment with the parameters, we use ex/cmd_gkmm.py to generate commands for multiple combinations of parameters. This requires cmdprod package available here: https://github.com/wittawatj/cmdprod .

Contact

If you have questions or comments, please contact Wittawat and Patsorn.

TODO list

  • [x] support running cadgan on celebaHQ
  • [x] support running cadgan on LSUN
  • [x] clean up code & readme
  • [x] test that all script can successfully run
    • [x] run_mnist.sh
    • [x] run_lars_bridge.sh
    • [x] run_lars_bedroom.sh
    • [x] run_lars_tower.sh
    • [x] run_lars_celeba.sh
    • [x] run_mnist_color.sh
  • [x] upload and share data/model files
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].