This is the source code for the paper Generative Ratio Matching Networks.
You can check our experiment logs at https://app.wandb.ai/xukai92/gram-public, which are logged by WeightsAndBiasLogger.jl, a Julia interface for Weights & Biases.
- Install Julia and make
juliaavailable in your executable path.- This code was developed using Julia 1.3.1 and we suggest using the same version.
- Download the code in a location which we will refer as
GRAM_DIR. - Start a Julia REPL by entering
juliain your terminal.- Press
]button to enter the package manager. - Install DrWatson and PyCall by
add DrWatson PyCall.- Input
using PyCallto start install Python depedencies. - Input
PyCall.Conda.add("matplotlib")to install matplotlib. - Input
PyCall.Conda.add("tikzplotlib")to install tikzplotlib. - Input
PyCall.Conda.add("wandb")to install wandb.
- Input
- Activate the project environment by
activate $GRAM_DIR. - Install all dependencies by
instantiate. - Exit the REPL.
- Press
- Do
julia $GRAM_DIR/scripts/master.jl --exp 1- This will produce Figure 1 (and Figure 6 & 9 in the appendix).
- To produce other plots, change the argument to
--exp 2for Figure 2 (and Figure 7 in the appendix), or--exp 3for Figure 8 in the appendix.
- You can also adjust the parameter sweep in
master.jlby yourself. - If you want to run multiple trainings in parallel, please append
JULIA_NUM_THREADS=$N_PARALLELto the beginning of the command (with a space), whereN_PARALLELis the number of parallel trainings you want to run.- By default the script uses 2 GPUs for parallelism. You can add
--n_gpus $N_GPUSto the command to control the number.
- By default the script uses 2 GPUs for parallelism. You can add
You can also modify the arguments in scripts/gram.jl and run the file on its own by julia $GRAM_DIR/scripts/gram.jl
Our code by default logs all the training details using Weights & Biases,
please install W&B and set it up following here.
Or if you don't want to log things, add --nowandb.
We provide a pre-trained model using this Julia version of GRAM networks at demo/cifar10-gramnet.bson.
You can use the provided Jupyter notebook at demo/interact.ipynb to interact with our pre-trained GRAM network.
NOTE: This is NOT the exact code we used for the CIFAR10 experiment in our paper. For reproducibility of paper on those experiments, please check GRAMFlow.
We generated 50 images from our GRAM network and mixed them with 50 real images. Can you tell the generated ones from sampled ones?
Click here to see the answers. How many mistakes did you make?
| Maintainer |
|---|
| Kai Xu |
