Giter Club home page Giter Club logo

lag's Introduction

LAG: Latent Adversarial Generator

Code for the paper: "Creating High Resolution Images with a Latent Adversarial Generator" by David Berthelot, Peyman Milanfar, and Ian Goodfellow.

This is not an officially supported Google product.

Setup

Important: ML_DATA is a shell environment variable that should point to the location where the datasets are installed. See the Install datasets section for more details.

Install dependencies

sudo apt install python3-dev python3-virtualenv python3-tk imagemagick virtualenv
virtualenv -p python3 --system-site-packages ~/env3
~/env3/bin/pip install -r requirements.txt

To use virtualenv, when starting a new shell, always run the following lines first:

. ~/env3/bin/activate
export PYTHONPATH=$PYTHONPATH:.

Install datasets

Directory for storing training data

# You can define ML_DATA to whatever path you like.
export ML_DATA="path to where you want the datasets saved"
mkdir $ML_DATA $ML_DATA/Models

Download vgg19.npy from https://github.com/machrisaa/tensorflow-vgg to $ML_DATA/Models.

Download datasets

# Important ML_DATA and PYTONPATH must be defined (see previous sections).
scripts/create_datasets.py

Alternatively you can download just some selected datasets to save space and time, for example:

scripts/create_datasets.py celeba svhn

The supported datasets are (%s represents the image size, when present it can be replaced by 32, 64, 128 or 256):

celeba%s, cifar10, mnist, svhn,

lsun_bedroom%s, lsun_bridge%s, lsun_church_outdoor%s, lsun_classroom%s,
lsun_conference_room%s, lsun_dining_room%s, lsun_kitchen%s, lsun_living_room%s,
lsun_restaurant%s, lsun_tower%s

Running

Setup

All commands must be ran from the project root. The following environment variables must be defined:

export ML_DATA="path to where you want the datasets saved"
export PYTHONPATH=$PYTHONPATH:.

Example

For example, training lag for a 32x zoom using CelebA128:

CUDA_VISIBLE_DEVICES=0 python lag.py --dataset=celeba128 --scale=32

Multi-GPU training

Just pass more GPUs and the code automatically scales to them, here we assign GPUs 4-7 to the program:

CUDA_VISIBLE_DEVICES=4,5,6,7 python lag.py --dataset=celeba128 --scale=32

Flags

python lag.py --help
# The following option might be too slow to be really practical.
# python lag.py --helpfull
# So instead I use this hack to find the flags:
fgrep -R flags.DEFINE libml lag.py

Monitoring training progress

You can point tensorboard to the training folder (by default it is --train_dir=./experiments) to monitor the training process:

tensorboard --logdir experiments
# And point your browser the link printed when tensorboard starts.

Generating samples

Following the previous example, for a LAG model trained on CelebA128, the ckpt is the folder where the model was trained:

python scripts/lag_generate_candidates.py\
 --dataset=celeba128\
 --samples 0,3,4,6,8,9,12,13,15\
 --ckpt experiments/celeba128/average32X/LAG_batch16_blocks8_filters256_filters_min64_lod_min1_lr0.001_mse_weight10.0_noise_dim64_training_kimg2048_transition_kimg2048_ttur4_wass_target1.0_weight_avg0.999/

Citing this work

@article{berthelot2020creating,
  title={Creating High Resolution Images with a Latent Adversarial Generator},
  author={Berthelot, David and Milanfar, Peyman and Goodfellow, Ian},
  journal={arXiv preprint arXiv:2003.02365},
  year={2020}
}

lag's People

Contributors

david-berthelot avatar singhaditya28 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lag's Issues

how to create and train my own dataset ?

thank you for your work
i try to use your work to train my own dataset ,include two steps ;
1,create tfrecord
2,train the gan

but ,the code is so complicated , would you like to give some introduces ?
thanks

one question about how to install&run the code

in the webpage the commands read like 'sudo apt install python3-dev python3-virtualenv python3-tk imagemagick virtualenv','scripts/create_datasets.py celeba svhn'and so on;while in the readme.md which from the code.zip the commands look like'bash sudo apt install python3-dev python3-virtualenv python3-tk imagemagick virtualenv virtualenv -p python3 --system-site-packages ~/env3 ~/env3/bin/pip install -r requirements.txt','bash scripts/create_datasets.py celeba svhn'ande so on .
so what is the meaning of 'bash' using here,which one should I choose to use?

Custom data at test time

Hello,

Thank you so very much for the impressive work and for making it open source.

Out of curiosity I was wondering if you are going to explain how one could get it to work with custom datasets (by that i mean not from the list of supported datasets).

Thank you so very much and best regards,

Pre-trained Weights

Can you please provide the pre-trained weights which can be placed in ckpt folder in order to test the algorithm?

what is the stage motivation?

thank for your work .

i am confused with the stage in lag ,
in the code ,the channels of weight are smaller and amaller along the bigger of stage .

i do not unnderstand the meaning of this operate ?
thanks

Critic inputs

Hello, i have a question about the paper

image

Doesn't this allow the critic to spot the real samples by looking at the 0 ?
This would make its job too easy and it will become too powerful for the generator, especially in the beginning, thus the generator won t be able to keep up.

critic output

lag/lag.py

Line 98 in 03333f5

return y * center

Hello, could you please, explain why multiply y with center at the output of the critic ?

Updating Security Measures

Dear @david-berthelot ,
Hope you're doing well 😄 !

I found out this project and immediately realised its potential. I want to update the project with some secure syntax. Can I get the names of thePython files which are standalone and not being imported to other files so that I can create a dedicated PR ? Thanks in advance 👍

PS :: I will try my best to make this project a success.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.