Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

CycleGAN on Art Composition Attributes

Please read the accompanying blog post: https://hollygrimm.com/acan_final

Results when training on Apple2Orange

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

Requirements

Error message 'ValueError: axes don't match array' during load_weights unless older version of Keras and keras-contrib installed. See https://stackoverflow.com/questions/51944836/keras-load-model-valueerror-axes-dont-match-array

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 aws-setup.sh to file in /home/ubuntu and run:

vi aws-setup.sh
chmod +x aws-setup.sh
./aws-setup.sh

Manual Install

keras-contrib install

source activate tensorflow_p36
git clone https://www.github.com/keras-team/keras-contrib.git
cd keras-contrib
python setup.py install

Download Art Composition Attributes Network Weights

Weights can be downloaded with these commands:

wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1A1FvTA-n7EZrtLx7TD9q3KgF5khpAjVW' -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: https://github.com/hollygrimm/art-composition-cnn

Download Dataset

bash download_dataset.sh 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 main.py -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 predict.py -c input_params_predict.json

Run Tests

cd tests
python cyclegan_keras_art_attrs_tests.py

Acknowledgements

About

CycleGAN with Art Composition Attributes

Topics

Resources

License

Releases

No releases published

Packages

No packages published