Skip to content

Instantly share code, notes, and snippets.

@anowell
Created December 18, 2016 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anowell/386035fede097e4aa505102481f00517 to your computer and use it in GitHub Desktop.
Save anowell/386035fede097e4aa505102481f00517 to your computer and use it in GitHub Desktop.
For a single image, generate every DeepFilter style transfer variant of that image
#!/bin/bash
set -e
function die {
echo >&2 $1
exit 1
}
command -v algo >/dev/null 2>&1 || die "Have you installed the Algorithmia CLI"
ALGO_PROFILE="${ALGO_PROFILE:-default}"
PROFILE_ARGS="--profile $ALGO_PROFILE"
IMAGE=$1
test -n "$IMAGE" || die "Usage: $0 IMAGE_PATH_OR_URL"
FNAME=$(basename $IMAGE)
# If it's a local file, upload it and use that
if [[ -f $IMAGE ]]; then
algo cp $PROFILE_ARGS "$IMAGE" data://.my/temp/$FNAME
IMAGE="data://.my/temp/$FNAME"
fi
# Now loop through filters
FILTERS="alien_goggles aqua blue_brush blue_granite bright_sand cinnamon_rolls clean_view colorful_blocks \
colorful_dream crafty_painting creativity crunch_paper dark_rain dark_soul deep_connections dry_skin \
far_away gan_vogh gred_mash green_zuma hot_spicy neo_instinct oily_mcoilface plentiful post_modern \
purp_paper purple_pond purple_storm rainbow_festival really_hot sand_paper smooth_ride space_pizza \
spagetti_accident sunday yellow_collage yellow_paper"
for filter in $FILTERS; do
echo "Rendering with $filter filter..."
savePath="data://.my/temp/${FNAME%.*}-$filter.jpg"
algo run $PROFILE_ARGS deeplearning/DeepFilter/0.1.9 -d "{\"images\": \"$IMAGE\", \"savePaths\": \"$savePath\", \"filterName\": \"$filter\"}"
algo cp $PROFILE_ARGS $savePath .
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment