Coder Social home page Coder Social logo

ml-lab / gan_steerability Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ali-design/gan_steerability

0.0 2.0 0.0 283 KB

On the "steerability" of generative adversarial networks

Home Page: https://ali-design.github.io/gan_steerability/

Python 72.14% Jupyter Notebook 27.47% Shell 0.39%

gan_steerability's Introduction

GAN steerability

Project Page | Paper

On the "steerability" of generative adversarial networks.
Ali Jahanian*, Lucy Chai*, Phillip Isola

Prerequisites

  • Linux
  • Python 3
  • CPU or NVIDIA GPU + CUDA CuDNN

Setup

  • Clone this repo:
git clone https://github.com/ali-design/gan_steerability.git
  • Install dependencies:
    • we provide a Conda environment.yml file listing the dependencies. You can create a Conda environment with the dependencies using:
conda env create -f environment.yml
  • Download resources:
    • we provide a script for downloading associated resources (e.g. stylegan). Fetch these by running:
bash  resources/download_resources.sh

Training walks

  • The current implementation covers these variants:
    • models: biggan, stylegan
    • transforms: color, colorlab, shiftx, shifty, zoom, rotate2d, rotate3d
    • walk_type: linear, NNz
    • losses: l2, lpips
  • Some examples of commands for training walks:
# train a biggan NN walk for shiftx with lpips loss
python train.py --model biggan --transform shiftx --num_samples 20000 --learning_rate 0.0001 \
	--walk_type NNz --loss lpips --gpu 0 --eps 25 --num_steps 5

# train a stylegan linear walk with l2 loss using the w latent space
python train.py --model stylegan --transform color --num_samples 2000 --learning_rate 0.0001 \
	--walk_type linear --loss l2 --gpu 0 --latent w --model_save_freq 100
  • Alternatively you can train using a config yml file, for example:
python train.py --config_file config/biggan_color_linear.yml
  • Each training run will save a config file called opt.yml in the same directory as the weights, which can be used for rerunning experiments with the same settings. You may need to use the flag --overwrite_config for overwriting existing weights and config files.

  • Run python train.py -h to list available training options

Visualize walks

  • Run python vis_image.py -h to list available visualization options. The key things to provide are a model checkpoint and a config yml file. For example:
python vis_image.py \
	models/biggan_zoom_linear_lr0.0001_l2/model_20000_final.ckpt \
	models/biggan_zoom_linear_lr0.0001_l2/opt.yml \
	--gpu 0 --num_samples 50 --noise_seed 20 --truncation 0.5 --category 207

python vis_image.py \
        models/stylegan_color_linear_lr0.0001_l2_cats_w/model_2000_final.ckpt \
        models/stylegan_color_linear_lr0.0001_l2_cats_w/opt.yml \
        --gpu 1 --num_samples 10 --noise_seed 20 
  • By default this will save generated images to <output_dir>/images specified in the config yml, unless overwritten with the --output_dir option

Notebooks

  • We provide some examples of jupyter notebooks illustrating the full training pipeline. See notebooks.
  • It might be easiest to start here if you want to try your own transformations! The key things to modify are get_target_np and to scale alpha appropriately when feeding to graph.
  • If using the provided conda environment, you'll need to add it to the jupyter kernel:
source activate gan_steerability
python -m ipykernel install --user --name gan_steerability

Visualizing Distributions

These will be coming soon!

Citation

If you use this code for your research, please cite our paper:

@article{gansteerability,
  title={On the "steerability" of generative adversarial networks},
  author={Jahanian, Ali and Chai, Lucy and Isola, Phillip},
  journal={arXiv preprint arXiv:1907.07171},
  year={2019}
}

gan_steerability's People

Contributors

ali-design avatar chail avatar

Watchers

 avatar  avatar

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.