Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #usage: ./wav-ns.sh "content image" "comma,separated,style,images"
- CONTENT_IMAGE=$1
- STYLE_IMAGE=$2
- content=$(basename ${1%.*})
- style=$(basename ${2%.*})
- OUT_DIR="out/$content-$style/"
- mkdir -p $OUT_DIR
- SCALE_DOWN=128
- SCALE_UP=1448
- STYLE_WEIGHT=10000
- CONTENT_WEIGHT=100
- WIDTH=`identify $CONTENT_IMAGE | cut -f 3 -d " " | sed s/x.*//`
- HEIGHT=`identify $CONTENT_IMAGE | cut -f 3 -d " " | sed s/.*x//`
- MIN=$(( WIDTH < HEIGHT ? WIDTH : HEIGHT ))
- MAX=$(( WIDTH > HEIGHT ? WIDTH : HEIGHT ))
- SCALE=$(( (1000 * 512 / $MIN) * $MIN / 1000))
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $CONTENT_IMAGE \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image $OUT_DIR/content-hist.png
- convert $OUT_DIR/content-hist.png -resize ${SCALE}x${SCALE} $OUT_DIR/in.png
- PREV=$OUT_DIR/in.png
- th neural_style_multires.lua \
- -style_image $STYLE_IMAGE \
- -content_image $PREV \
- -output_image $OUT_DIR/$content-$style \
- -num_iterations 1000 \
- -optimizer lbfgs \
- -normalize_gradients \
- -style_scale 1 \
- -content_weight $(( $CONTENT_WEIGHT )) \
- -style_weight $(( $STYLE_WEIGHT )) \
- -image_size 1024 \
- -init image \
- -init_image $PREV \
- -overlap_times 2 \
- -scale_down $( echo $SCALE_DOWN/512 | bc -l ) \
- -scale_up $( echo $SCALE_DOWN/512 | bc -l ) \
- -scale_steps 1
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- for ((n=0;n<$(echo "($( echo "l(512) / l(2) - l($SCALE_DOWN) / l(2)" | bc -l ) + 0.5) / 1" | bc);n++)) do
- th neural_style_multires.lua \
- -style_image $STYLE_IMAGE \
- -content_image $PREV \
- -output_image $OUT_DIR/$content-$style \
- -num_iterations 800 \
- -optimizer lbfgs \
- -normalize_gradients \
- -style_scale 1 \
- -content_weight $CONTENT_WEIGHT \
- -style_weight $STYLE_WEIGHT \
- -image_size 1024 \
- -init image \
- -init_image $PREV \
- -overlap_times 2 \
- -scale_down 2 \
- -scale_up 2 \
- -scale_steps 1
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- done
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- for ((n=-1;n<=$(echo "($( echo "l($SCALE_UP) / l( sqrt(2) ) - l(1024) / l( sqrt(2) )" | bc -l ) + 0.5) / 1" | bc);n++)) do
- th neural_style_multires.lua \
- -style_image $STYLE_IMAGE \
- -content_image $PREV \
- -output_image $OUT_DIR/$content-$style \
- -num_iterations 600 \
- -optimizer lbfgs \
- -normalize_gradients \
- -style_scale 1 \
- -content_weight $CONTENT_WEIGHT \
- -style_weight $STYLE_WEIGHT \
- -image_size 1024 \
- -init image \
- -init_image $PREV \
- -overlap_times 2 \
- -scale_down 1.414 \
- -scale_up 1.414 \
- -scale_steps 1
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- done
- STYLE_WEIGHT=1000
- STYLE_SCALE=1
- CONTENT_WEIGHT=0
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- th neural_style.lua \
- -style_image $STYLE_IMAGE \
- -style_weight $STYLE_WEIGHT \
- -style_scale $STYLE_SCALE \
- -content_image $CONTENT_IMAGE \
- -content_weight $CONTENT_WEIGHT \
- -output_image $OUT_DIR/X4.png \
- -num_iterations 600 \
- -model_file models/channel_pruning.caffemodel \
- -proto_file models/channel_pruning.prototxt \
- -optimizer adam \
- -print_iter 300 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 1600 \
- -original_colors 0 \
- -normalize_gradients
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- th neural_style.lua \
- -style_image $STYLE_IMAGE \
- -style_weight $STYLE_WEIGHT \
- -style_scale $STYLE_SCALE \
- -content_image $CONTENT_IMAGE \
- -content_weight $CONTENT_WEIGHT \
- -output_image $OUT_DIR/X5.png \
- -model_file models/nin_imagenet_conv.caffemodel \
- -proto_file models/train_val.prototxt \
- -num_iterations 200 \
- -content_layers relu0,relu1,relu2,relu3,relu5,relu6,relu7,relu8 \
- -style_layers relu0,relu1,relu2,relu3,relu5,relu6,relu7,relu8 \
- -optimizer adam \
- -print_iter 100 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 2550 \
- -original_colors 0 \
- -normalize_gradients
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- STYLE_WEIGHT=1000
- STYLE_SCALE=1
- CONTENT_WEIGHT=0
- th neural_style.lua \
- -style_image $STYLE_IMAGE \
- -style_weight $STYLE_WEIGHT \
- -style_scale $STYLE_SCALE \
- -content_image $CONTENT_IMAGE \
- -content_weight $CONTENT_WEIGHT \
- -output_image $OUT_DIR/X6.png \
- -model_file models/nin_imagenet_conv.caffemodel \
- -proto_file models/train_val.prototxt \
- -num_iterations 200 \
- -content_layers relu0,relu1,relu2,relu3,relu5,relu6 \
- -style_layers relu0,relu1,relu2,relu3,relu5,relu6 \
- -optimizer adam \
- -print_iter 100 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 2700 \
- -original_colors 0 \
- -normalize_gradients
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- th neural_style.lua \
- -style_image $STYLE_IMAGE \
- -style_weight $STYLE_WEIGHT \
- -style_scale $STYLE_SCALE \
- -content_image $CONTENT_IMAGE \
- -content_weight $CONTENT_WEIGHT \
- -output_image $OUT_DIR/X7.png \
- -model_file models/nin_imagenet_conv.caffemodel \
- -proto_file models/train_val.prototxt \
- -num_iterations 200 \
- -content_layers relu0,relu1,relu2,relu3,relu5,relu6,relu7,relu8 \
- -style_layers relu0,relu1,relu2,relu3,relu5,relu6,relu7,relu8 \
- -optimizer adam \
- -print_iter 100 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 2900 \
- -original_colors 0 \
- -normalize_gradients
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- th neural_style.lua \
- -style_image $STYLE_IMAGE \
- -style_weight $STYLE_WEIGHT \
- -style_scale $STYLE_SCALE \
- -content_image $CONTENT_IMAGE \
- -content_weight $CONTENT_WEIGHT \
- -output_image $OUT_DIR/X8.png \
- -model_file models/nin_imagenet_conv.caffemodel \
- -proto_file models/train_val.prototxt \
- -num_iterations 200 \
- -content_layers relu0,relu1 \
- -style_layers relu0,relu1 \
- -optimizer adam \
- -print_iter 100 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 4000 \
- -original_colors 0 \
- -normalize_gradients
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- STYLE_SCALE=0.5
- th neural_style.lua \
- -style_image $STYLE_IMAGE \
- -content_image $CONTENT_IMAGE \
- -output_image $OUT_DIR/$content-$style.png \
- -model_file models/nin_imagenet_conv.caffemodel \
- -proto_file models/train_val.prototxt \
- -num_iterations 20 \
- -content_layers relu0,relu1 \
- -style_layers relu0,relu1 \
- -optimizer adam \
- -print_iter 50 \
- -tv_weight 0 \
- -style_scale $STYLE_SCALE \
- -backend cudnn \
- -content_weight $CONTENT_WEIGHT \
- -style_weight $STYLE_WEIGHT \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 5000 \
- -original_colors 0
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --output_image "${PREV%.*}"-hist.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- python ../Neural-Tools/lum-transfer.py \
- --output_lum2 $PREV \
- --org_content $OUT_DIR/content-hist.png \
- --cp_mode lum2 \
- --output_image "${PREV%-hist.*}"-lum1.png
- python ../Neural-Tools/lum-transfer.py \
- --output_lum2 $PREV \
- --org_content $CONTENT_IMAGE \
- --cp_mode lum2 \
- --output_image "${PREV%-hist.*}"-lum2.png
- python ../Neural-Tools/lum-transfer.py \
- --output_lum2 $PREV \
- --org_content "$OUT_DIR/$content-$style-1024.png" \
- --cp_mode lum2 \
- --output_image "${PREV%-hist.*}"-match.png
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement