Skip to content
CycleGAN with Art Composition Attributes
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

CycleGAN on Art Composition Attributes

Please read the accompanying blog post:

Results when training on Apple2Orange

1 2
python -c params/harmony/analogous.json python -c params/harmony/complementary.json
Color Harmony Analogous Color Harmony Complementary
python -c params/variety_color/1.json python -c params/variety_color/10.json
Variety of Color 1 Variety of Color 10
python -c params/variety_texture/1.json python -c params/variety_texture/10.json
Variety of Texture 1 Variety of Texture 10
python -c params/variety_shape/1.json python -c params/variety_shape/10.json
Variety of Shape 1 Variety of Shape 10
python -c params/variety_size/1.json python -c params/variety_size/10.json
Variety of Size 1 Variety of Size 10
python -c params/contrast/1.json python -c params/contrast/10.json
Contrast 1 Contrast 10
python -c params/repetition/1.json python -c params/repetition/10.json
Repetition 1 Repetition 10
python -c params/pri_color/blue-cyan.json python -c params/pri_color/yellow.json
Primary Color Blue-Cyan Primary Color Yellow


Error message 'ValueError: axes don't match array' during load_weights unless older version of Keras and keras-contrib installed. See

AWS Install

  • Select Deep Learning AMI (Ubuntu) Version 14.0
  • Instance Type GPU Compute such as p2.xlarge
  • 125GB sda1

Connect to instance, copy contents of to file in /home/ubuntu and run:

chmod +x

Manual Install

keras-contrib install

source activate tensorflow_p36
git clone
cd keras-contrib
python install

Download Art Composition Attributes Network Weights

Weights can be downloaded with these commands:

wget --load-cookies /tmp/cookies.txt "$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate '' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1A1FvTA-n7EZrtLx7TD9q3KgF5khpAjVW" -O art_composition_cnn_weights.hdf5 && rm -rf /tmp/cookies.txt

sha256sum d922aa82e6e67177915895e34f02e03e89a902d7a15914edcee0c3056f285d24

Or train your own weights using this repository:

Download Dataset

bash apple2orange

Minimum image size for training or predicting is 16x16 pixels (size of Patch-GAN patch). When training your own dataset, the number of images in the trainA folder, should be equal to or less than the number of images in trainB folder.

With a batch size of 1, here are the maximum image sizes that train on various GPU sizes:

GPU Img Size Trains?
2 GiB 320x320 No, OOM
2 GiB 256x256 Yes
12 GiB 1024x1024 No, OOM
12 GiB 768x768 Yes
16 GiB 1280x1280 No, OOM
16 GiB 1024x1024 Yes

When running prediction, here are the maximum predict image sizes for various GPU sizes:

GPU Predict Img Size Predicts?
2 GiB 1408x1408 No, OOM
2 GiB 1344x1344 Yes
12 GiB 4096x4096 No, OOM
12 GiB 4032x4032 Yes
16 GiB 4832x4832 No, OOM
16 GiB 4816x4816 Yes (a or b, not both)
16 GiB 4800x4800 Yes (both)

Run Training

source activate tensorflow_p36
cd cyclegan-keras-art-attrs/
python -c input_params.json

Run Predict

after training, update weights_path in input_params_predict.json

source activate tensorflow_p36
cd cyclegan-keras-art-attrs/
python -c input_params_predict.json

Run Tests

cd tests


You can’t perform that action at this time.