Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts and stuff #396

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions active_styles/.NOTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Style images in this directory (or symlinked here) will be applied
1 change: 1 addition & 0 deletions all_content_incoming.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
for file in content_incoming/*; do sh one_content_multi_styles.sh "$(basename $file)"; done
1 change: 1 addition & 0 deletions all_styles/.NOTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keep all styles here
Binary file added all_styles/alex_gray_diamond_being.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/autumn_leaves.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/batik.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/bryce_hudson.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/drseusssketch.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/escher_sphere.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/frida_kahlo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/guernica.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/kiddyppumpkins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/manet_flowers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/marijuana_collage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/picasso_selfport1907.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/pollock.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/renandstimpy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/seated_nude.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/seurat_grand_jatte.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/shipwreck.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/snow_scene.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/spring_flowers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/starry_night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/summer_beach.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/the_scream.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/warhol_monroe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added all_styles/woman_with_hat_matisse.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions content_complete/.NOTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content images are moved here after being styled
1 change: 1 addition & 0 deletions content_incoming/.NOTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Files here will be pulled by shell script
34 changes: 34 additions & 0 deletions make_gif.py
Original file line number Diff line number Diff line change
@@ -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()
19 changes: 19 additions & 0 deletions one_content_multi_styles.sh
Original file line number Diff line number Diff line change
@@ -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/
1 change: 1 addition & 0 deletions output/.NOTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Output files go here. Including progress pics
1 change: 1 addition & 0 deletions output/final/.NOTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Output files go here. Just final copies
1 change: 1 addition & 0 deletions output/gif/.NOTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Animated gifs! Hard g
2 changes: 2 additions & 0 deletions python_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
images2gif-Pillow
Pillow