Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- CONTENT_IMAGE=$1
- STYLE_IMAGE=$2
- CONTENT_WEIGHT=$3
- STYLE_WEIGHT=$4
- STYLE_SCALE=$5
- ORIGINAL_COLORS=$6
- multipleimages=false
- if [[ $2 = *","* ]];
- then
- multipleimages=true
- else
- multipleimages=false
- fi
- X2_SIZE=800
- content=$(basename ${1%.*})
- style=$(basename ${2%.*})
- cw=$(basename ${3%.*})
- sw=$(basename ${4%.*})
- scale=$(basename ${5%.*})
- oc=$(basename ${6%.*})
- OUT_DIR="$content-$style-$3-$4-$5-$6-large/"
- mkdir -p $OUT_DIR
- th neural_style_dir_rng_fix.lua \
- -style_image $STYLE_IMAGE \
- -style_weight $STYLE_WEIGHT \
- -style_scale $STYLE_SCALE \
- -content_image $CONTENT_IMAGE \
- -content_weight $CONTENT_WEIGHT \
- -print_iter 100 \
- -save_iter 100 \
- -image_size 256 \
- -num_iterations 1000 \
- -model_file models/nyud-fcn32s-color-heavy.caffemodel \
- -proto_file models/nyud-fcn32s-color-heavy-trainval.prototxt \
- -content_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
- -style_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
- -optimizer lbfgs \
- -output_image $OUT_DIR/X0.png \
- -tv_weight 0.00001 \
- -original_colors $ORIGINAL_COLORS \
- -backend cudnn \
- -init random
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
- then
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --mode chol \
- --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- fi
- th neural_style_dir_rng_fix.lua \
- -style_image $STYLE_IMAGE \
- -style_weight $STYLE_WEIGHT \
- -style_scale $STYLE_SCALE \
- -content_image $CONTENT_IMAGE \
- -content_weight $CONTENT_WEIGHT \
- -init image \
- -init_image $PREV \
- -save_iter 100 \
- -image_size 512 \
- -num_iterations 1000 \
- -model_file models/nyud-fcn32s-color-heavy.caffemodel \
- -proto_file models/nyud-fcn32s-color-heavy-trainval.prototxt \
- -content_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
- -style_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
- -optimizer lbfgs \
- -output_image $OUT_DIR/X1.png \
- -tv_weight 0.00001 \
- -original_colors $ORIGINAL_COLORS \
- -backend cudnn \
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
- then
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --mode chol \
- --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- fi
- cp -b $PREV ~/mygoogledrive
- CONTENT_WEIGHT=$(bc <<< "scale=2;$CONTENT_WEIGHT/5")
- STYLE_WEIGHT=$(bc <<< "scale=2;$STYLE_WEIGHT/10")
- th neural_style_dir_rng_fix.lua \
- -style_image $STYLE_IMAGE \
- -style_weight $STYLE_WEIGHT \
- -style_scale $STYLE_SCALE \
- -content_image $CONTENT_IMAGE \
- -content_weight $CONTENT_WEIGHT \
- -init image \
- -init_image $PREV \
- -image_size $X2_SIZE \
- -num_iterations 1500 \
- -save_iter 250 \
- -model_file models/nyud-fcn32s-color-heavy.caffemodel \
- -proto_file models/nyud-fcn32s-color-heavy-trainval.prototxt \
- -content_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
- -style_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
- -optimizer lbfgs \
- -output_image $OUT_DIR/X2.png \
- -tv_weight 0.00001 \
- -original_colors $ORIGINAL_COLORS \
- -normalize_gradients \
- -backend cudnn
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
- then
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --mode chol \
- --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- fi
- cp -b $PREV ~/mygoogledrive
- STYLE_WEIGHT=1000
- CONTENT_WEIGHT=0
- th neural_style_dir_rng_fix.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/X3.png \
- -num_iterations 200 \
- -model_file models/nyud-fcn32s-color-heavy.caffemodel \
- -proto_file models/nyud-fcn32s-color-heavy-trainval.prototxt \
- -optimizer adam \
- -save_iter 0 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 1148 \
- -original_colors $ORIGINAL_COLORS \
- -normalize_gradients \
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
- then
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --mode chol \
- --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- fi
- cp -b $PREV ~/mygoogledrive
- th neural_style_dir_rng_fix.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 \
- -save_iter 0 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 1800 \
- -original_colors $ORIGINAL_COLORS \
- -normalize_gradients \
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
- then
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --mode chol \
- --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- fi
- cp -b $PREV ~/mygoogledrive
- #Insert
- th neural_style_dir_rng_fix.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 \
- -save_iter 0 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 2550 \
- -original_colors $ORIGINAL_COLORS \
- -normalize_gradients \
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
- then
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --mode chol \
- --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- fi
- cp -b $PREV ~/mygoogledrive
- STYLE_WEIGHT=1000
- CONTENT_WEIGHT=0
- th neural_style_dir_rng_fix.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 \
- -save_iter 0 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 2700 \
- -original_colors $ORIGINAL_COLORS \
- -normalize_gradients \
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
- then
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --mode chol \
- --output_image "${PREV%.*}-$content-$style-$cw-$sw-$oc"-histfinal.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- cp -b $PREV ~/mygoogledrive
- else
- cp -b $OUT_DIR/X6.png ~/mygoogledrive/"X6-$content-$style-$cw-$sw-$oc-final".png
- fi
- th neural_style_dir_rng_fix.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 \
- -save_iter 0 \
- -tv_weight 0 \
- -backend cudnn \
- -init image \
- -init_image $PREV \
- -learning_rate 1 \
- -image_size 2900 \
- -original_colors $ORIGINAL_COLORS \
- -normalize_gradients \
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- if [ $multipleimages == false ];
- then
- python3 ../Neural-Tools/linear-color-transfer.py \
- --target_image $PREV \
- --source_image ${STYLE_IMAGE##*,} \
- --mode chol \
- --output_image "${PREV%.*}-$content-$style-$cw-$sw-$oc"-histfinal.png
- PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
- cp -b $PREV ~/mygoogledrive
- else
- cp -b $OUT_DIR/X7.png ~/mygoogledrive/"X7-$content-$style-$cw-$sw-$oc-final".png
- fi
Advertisement
Add Comment
Please, Sign In to add comment