diff --git a/.gitignore b/.gitignore index 7ebcf69..70009fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,19 @@ *.swp out*.png -*.png -*.jpg *.prototxt* *.caffemodel models/ !models/download_models.sh + + +output/*.jpg +output/final/*.jpg +output/gif/*.gif +content_incoming +!content_incoming/.NOTE.md +content_complete +!content_complete/.NOTE.md +all_styles +!all_styles/.NOTE.md +active_styles +!active_styles/.NOTE.md diff --git a/active_styles/.NOTE.md b/active_styles/.NOTE.md new file mode 100644 index 0000000..cd7cfe1 --- /dev/null +++ b/active_styles/.NOTE.md @@ -0,0 +1 @@ +Style images in this directory (or symlinked here) will be applied diff --git a/all_content_incoming.sh b/all_content_incoming.sh new file mode 100644 index 0000000..a0d8fbe --- /dev/null +++ b/all_content_incoming.sh @@ -0,0 +1 @@ +for file in content_incoming/*; do sh one_content_multi_styles.sh "$(basename $file)"; done diff --git a/all_styles/.NOTE.md b/all_styles/.NOTE.md new file mode 100644 index 0000000..52d9f28 --- /dev/null +++ b/all_styles/.NOTE.md @@ -0,0 +1 @@ +Keep all styles here diff --git a/all_styles/alex_gray_diamond_being.jpg b/all_styles/alex_gray_diamond_being.jpg new file mode 100644 index 0000000..b7a59bb Binary files /dev/null and b/all_styles/alex_gray_diamond_being.jpg differ diff --git a/all_styles/autumn_leaves.jpg b/all_styles/autumn_leaves.jpg new file mode 100644 index 0000000..9f73c7d Binary files /dev/null and b/all_styles/autumn_leaves.jpg differ diff --git a/all_styles/batik.jpg b/all_styles/batik.jpg new file mode 100644 index 0000000..2e814e2 Binary files /dev/null and b/all_styles/batik.jpg differ diff --git a/all_styles/bryce_hudson.jpg b/all_styles/bryce_hudson.jpg new file mode 100644 index 0000000..8452914 Binary files /dev/null and b/all_styles/bryce_hudson.jpg differ diff --git a/all_styles/drseusssketch.jpg b/all_styles/drseusssketch.jpg new file mode 100644 index 0000000..4d689dc Binary files /dev/null and b/all_styles/drseusssketch.jpg differ diff --git a/all_styles/escher_sphere.jpg b/all_styles/escher_sphere.jpg new file mode 100644 index 0000000..9918cf4 Binary files /dev/null and b/all_styles/escher_sphere.jpg differ diff --git a/all_styles/frida_kahlo.jpg b/all_styles/frida_kahlo.jpg new file mode 100644 index 0000000..e4dae25 Binary files /dev/null and b/all_styles/frida_kahlo.jpg differ diff --git a/all_styles/guernica.jpg b/all_styles/guernica.jpg new file mode 100644 index 0000000..54ca5f3 Binary files /dev/null and b/all_styles/guernica.jpg differ diff --git a/all_styles/kiddyppumpkins.jpg b/all_styles/kiddyppumpkins.jpg new file mode 100644 index 0000000..c75eb2d Binary files /dev/null and b/all_styles/kiddyppumpkins.jpg differ diff --git a/all_styles/manet_flowers.jpg b/all_styles/manet_flowers.jpg new file mode 100644 index 0000000..5c30a11 Binary files /dev/null and b/all_styles/manet_flowers.jpg differ diff --git a/all_styles/marijuana_collage.jpg b/all_styles/marijuana_collage.jpg new file mode 100644 index 0000000..1789e56 Binary files /dev/null and b/all_styles/marijuana_collage.jpg differ diff --git a/all_styles/picasso_selfport1907.jpg b/all_styles/picasso_selfport1907.jpg new file mode 100644 index 0000000..e608782 Binary files /dev/null and b/all_styles/picasso_selfport1907.jpg differ diff --git a/all_styles/pollock.jpg b/all_styles/pollock.jpg new file mode 100644 index 0000000..5b11654 Binary files /dev/null and b/all_styles/pollock.jpg differ diff --git a/all_styles/renandstimpy.jpg b/all_styles/renandstimpy.jpg new file mode 100644 index 0000000..71a86ac Binary files /dev/null and b/all_styles/renandstimpy.jpg differ diff --git a/all_styles/seated_nude.jpg b/all_styles/seated_nude.jpg new file mode 100644 index 0000000..6a40b37 Binary files /dev/null and b/all_styles/seated_nude.jpg differ diff --git a/all_styles/seurat_grand_jatte.jpg b/all_styles/seurat_grand_jatte.jpg new file mode 100644 index 0000000..cbdabef Binary files /dev/null and b/all_styles/seurat_grand_jatte.jpg differ diff --git a/all_styles/shipwreck.jpg b/all_styles/shipwreck.jpg new file mode 100644 index 0000000..73ecd1c Binary files /dev/null and b/all_styles/shipwreck.jpg differ diff --git a/all_styles/snow_scene.jpg b/all_styles/snow_scene.jpg new file mode 100644 index 0000000..519f314 Binary files /dev/null and b/all_styles/snow_scene.jpg differ diff --git a/all_styles/spring_flowers.jpg b/all_styles/spring_flowers.jpg new file mode 100644 index 0000000..dded4cd Binary files /dev/null and b/all_styles/spring_flowers.jpg differ diff --git a/all_styles/starry_night.jpg b/all_styles/starry_night.jpg new file mode 100644 index 0000000..d4db3c8 Binary files /dev/null and b/all_styles/starry_night.jpg differ diff --git a/all_styles/summer_beach.jpg b/all_styles/summer_beach.jpg new file mode 100644 index 0000000..47cee50 Binary files /dev/null and b/all_styles/summer_beach.jpg differ diff --git a/all_styles/the_scream.jpg b/all_styles/the_scream.jpg new file mode 100644 index 0000000..ab54066 Binary files /dev/null and b/all_styles/the_scream.jpg differ diff --git a/all_styles/warhol_monroe.jpg b/all_styles/warhol_monroe.jpg new file mode 100644 index 0000000..593cbef Binary files /dev/null and b/all_styles/warhol_monroe.jpg differ diff --git a/all_styles/woman_with_hat_matisse.jpg b/all_styles/woman_with_hat_matisse.jpg new file mode 100644 index 0000000..a4675c7 Binary files /dev/null and b/all_styles/woman_with_hat_matisse.jpg differ diff --git a/content_complete/.NOTE.md b/content_complete/.NOTE.md new file mode 100644 index 0000000..b4c1ea6 --- /dev/null +++ b/content_complete/.NOTE.md @@ -0,0 +1 @@ +Content images are moved here after being styled diff --git a/content_incoming/.NOTE.md b/content_incoming/.NOTE.md new file mode 100644 index 0000000..61e2eb9 --- /dev/null +++ b/content_incoming/.NOTE.md @@ -0,0 +1 @@ +Files here will be pulled by shell script diff --git a/make_gif.py b/make_gif.py new file mode 100644 index 0000000..839c5f0 --- /dev/null +++ b/make_gif.py @@ -0,0 +1,34 @@ +import argparse +import glob + +import images2gif +from PIL import Image + + +def main(): + parser = argparse.ArgumentParser(description='Start and end for primary key') + parser.add_argument('--direction', '-d', type=str, nargs='?', default='backwards') + parser.add_argument('--prefix', '-p', type=str) + parser.add_argument('--output', '-o', type=str, nargs='?', default=None) + parser.add_argument('--original', '-r', type=str, nargs='?', default=None) + + namespace = parser.parse_args() + prefix = namespace.prefix + original = namespace.original + direction = namespace.direction + output = namespace.output or 'output/gifs/{0}.gif'.format(prefix.split('/')[-1]+'_'+direction) + + images = [Image.open(i) for i in glob.glob(prefix+'*')] + images = images[1:] + [images[0]] # hack bc final iteration has no number + if original: + original_raw = Image.open(original) + original_resized = original_raw.resize(images[0].size) + images.append(original_resized) + # name reflects iteration direction. backwards is normal to weird. forwards is weird to normal + if direction == 'backwards': + images = images[::-1] + + images2gif.writeGif(output, images, duration=.2) # TODO: maybe pause at the end? use duration=[list] to change + +if __name__ == '__main__': + main() diff --git a/one_content_multi_styles.sh b/one_content_multi_styles.sh new file mode 100644 index 0000000..27a6f7a --- /dev/null +++ b/one_content_multi_styles.sh @@ -0,0 +1,19 @@ +#!/bin/bash +SCRIPT=$0 +CONTENT_IMAGE=$1 +STYLES_DIR=active_styles +CONTENT_INCOMING_DIR=content_incoming +CONTENT_COMPLETE_DIR=content_complete + +for i in $( ls $STYLES_DIR); do + DEST_IMAGE=output/${CONTENT_IMAGE%????}__$i + if [ ! -f "$DEST_IMAGE" ]; then + echo attempting to apply $STYLES_DIR/$i to $CONTENT_IMAGE and save into $DEST_IMAGE + th neural_style.lua -gpu 0 -backend cudnn -style_image $STYLES_DIR/$i -content_image $CONTENT_INCOMING_DIR/$CONTENT_IMAGE -output_image $DEST_IMAGE + else + echo "skipping bc $DEST_IMAGE already exists" + fi + # python make_gif.py -p ${DEST_IMAGE%????} -r $CONTENT_INCOMING_DIR/$CONTENT_IMAGE -o output/gif/${CONTENT_IMAGE%????}__${i%????}.gif + cp $DEST_IMAGE output/final/ +done +mv $CONTENT_INCOMING_DIR/$CONTENT_IMAGE $CONTENT_COMPLETE_DIR/ diff --git a/output/.NOTE.md b/output/.NOTE.md new file mode 100644 index 0000000..d204ecf --- /dev/null +++ b/output/.NOTE.md @@ -0,0 +1 @@ +Output files go here. Including progress pics diff --git a/output/final/.NOTE.md b/output/final/.NOTE.md new file mode 100644 index 0000000..fb72736 --- /dev/null +++ b/output/final/.NOTE.md @@ -0,0 +1 @@ +Output files go here. Just final copies diff --git a/output/gif/.NOTE.md b/output/gif/.NOTE.md new file mode 100644 index 0000000..23758b8 --- /dev/null +++ b/output/gif/.NOTE.md @@ -0,0 +1 @@ +Animated gifs! Hard g diff --git a/python_requirements.txt b/python_requirements.txt new file mode 100644 index 0000000..cf8f64c --- /dev/null +++ b/python_requirements.txt @@ -0,0 +1,2 @@ +images2gif-Pillow +Pillow