Skip to content

Instantly share code, notes, and snippets.

@ProGamerGov
Last active October 6, 2018 18:56
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 ProGamerGov/f62e28cfa4017ff97b75cc588b9816c3 to your computer and use it in GitHub Desktop.
Save ProGamerGov/f62e28cfa4017ff97b75cc588b9816c3 to your computer and use it in GitHub Desktop.

Multiscale Resolution Scripts

Setup

First download the linear-color-transfer.py, and lum-transfer.py scripts from Neural-Tools:

wget -c https://raw.githubusercontent.com/ProGamerGov/Neural-Tools/master/linear-color-transfer.py

wget -c https://raw.githubusercontent.com/ProGamerGov/Neural-Tools/master/lum-transfer.py

Usage

By default these scripts likely won't produce good results, so you are encouraged to modify the script parameters to you liking. Though there are some things to keep in mind:

  • For the step 1 image size, keep in mind that the amount of change is related to how close the image size is to the size of the images used to train the model (ex: 224, 512).

  • As per Justin Johnson (creator of Neural-Style)'s suggestions, setting -tv_weight to 0 can improve results when using a multiscale resolution script like this. Though this dependent on what you want the output to look like.

  • More steps seem to let smaller details develop more than when just simply using as few steps as possible.

  • These scripts are designed to use jcjohnson's neural-style, neural-style-pt, and any similar style transfer scripts.

To run the scripts, you can use:

sh multires_style2content_hist.sh
sh multires_style2content.sh
sh multires_style2content_hist_large_cp.sh
sh multires_content2style.sh
sh multires_style2content_large.sh
sh multires_seg.sh
sh multires_seg_large_cp.sh

Troubleshooting

You can easily fix permission errors using chmod like this:

chmod u+x ./multires_style2content_hist.sh
chmod u+x ./multires_style2content_hist_large_cp.sh
chmod u+x ./multires_style2content.sh
chmod u+x ./multires_content2style.sh
chmod u+x ./multires_style2content_large.sh
chmod u+x ./multires_seg.sh
chmod u+x ./multires_seg_large_cp.sh
chmod u+x ./lum-transfer.py
chmod u+x ./linear-color-transfer.py
CONTENT_IMAGE=content_image.jpg
STYLE_IMAGE=style_image.png
INTERPRETER=python
NEURAL_STYLE=neural_style.py
# Histogram Matching from content image to style image
python linear-color-transfer.py --target_image $STYLE_IMAGE --source_image $CONTENT_IMAGE --output_image style_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE \
-style_image style_colored_pca.png \
-init image \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out1.png \
-image_size 640 \
-num_iterations 1500
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE \
-style_image style_colored_pca.png \
-init image -init_image out1.png \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out2.png \
-image_size 768 \
-num_iterations 1000
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE \
-style_image style_colored_pca.png \
-init image -init_image out2.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1024 \
-num_iterations 500 \
-output_image out3.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE \
-style_image style_colored_pca.png \
-init image -init_image out3.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1152 \
-num_iterations 200 \
-output_image out4.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE \
-style_image style_colored_pca.png \
-init image -init_image out4.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1536 \
-num_iterations 200 \
-output_image out5.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE \
-style_image style_colored_pca.png \
-init image -init_image out5.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1664 \
-num_iterations 200 \
-output_image out6.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE \
-style_image style_colored_pca.png \
-init image -init_image out6.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 1920 \
-num_iterations 200 \
-output_image out7.png
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE \
-style_image style_colored_pca.png \
-init image -init_image out7.png \
-tv_weight 0 -seed 876 -save_iter 100 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2125 \
-num_iterations 200 \
-output_image out8.png
# Luminance Transfer from original content image, to the final output
python lum-transfer.py --output_lum2 out8.png --cp_mode lum2 --output_image out8_final.png --org_content $CONTENT_IMAGE
# This variant of multires uses this modified version of Neural-Style: https://gist.github.com/ProGamerGov/bcbd27a3d2e431adb73ef158d9990d93
CONTENT_IMAGE=content_image.jpg
STYLE_IMAGE=style_image.png
CONTENT_MASK=content_mask.jpg
STYLE_MASK=style_mask.png
INTERPRETER=th
NEURAL_STYLE=neural_style_seg.lua
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -color_codes blue,green,black,white,red,yellow,grey,lightblue,purple \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out1.png \
-image_size 640 \
-num_iterations 1500
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out1.png -color_codes blue,green,black,white,red,yellow,grey,lightblue,purple \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out2.png \
-image_size 768 \
-num_iterations 1000
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out2.png -color_codes blue,green,black,white,red,yellow,grey,lightblue,purple \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1024 \
-num_iterations 500 \
-output_image out3.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out3.png -color_codes blue,green,black,white,red,yellow,grey,lightblue,purple \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1152 \
-num_iterations 200 \
-output_image out4.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out4.png -color_codes blue,green,black,white,red,yellow,grey,lightblue,purple \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1536 \
-num_iterations 200 \
-output_image out5.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out5.png -color_codes blue,green,black,white,red,yellow,grey,lightblue,purple \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1664 \
-num_iterations 200 \
-output_image out6.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out6.png -color_codes blue,green,black,white,red,yellow,grey,lightblue,purple \
-tv_weight 0 -seed 876 -save_iter 100 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 1920 \
-num_iterations 200 \
-output_image out7.png
# This variant of multires uses this modified version of Neural-Style: https://gist.github.com/ProGamerGov/bcbd27a3d2e431adb73ef158d9990d93
# You can download it via:
# wget https://gist.githubusercontent.com/ProGamerGov/bcbd27a3d2e431adb73ef158d9990d93/raw/1e7ecd1c9aecaead0d92e3eb0027baa3fa2c4f31/neural_style_seg.lua
# The channel prunning can be donwloaded via:
# wget https://github.com/yihui-he/channel-pruning/releases/download/channel_pruning_5x/channel_pruning.caffemodel
# wget https://github.com/yihui-he/channel-pruning/releases/download/channel_pruning_5x/channel_pruning.prototxt
CONTENT_IMAGE=content_image.jpg
STYLE_IMAGE=style_image.png
CONTENT_MASK=content_mask.jpg
STYLE_MASK=style_mask.png
INTERPRETER=th
NEURAL_STYLE=neural_style_seg.lua
# Remove color(s) not used in the content mask
COLOR_CODES="blue,green,black,white,red,yellow,grey,lightblue,purple"
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out1.png \
-image_size 640 \
-num_iterations 1500
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out1.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out2.png \
-image_size 768 \
-num_iterations 1000
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out2.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1024 \
-num_iterations 500 \
-output_image out3.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out3.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1152 \
-num_iterations 200 \
-output_image out4.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out4.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1536 \
-num_iterations 200 \
-output_image out5.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out5.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 1664 \
-num_iterations 200 \
-output_image out6.png \
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out6.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 1920 \
-num_iterations 200 \
-output_image out7.png
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out7.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2048 \
-num_iterations 200 \
-output_image out8.png
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out8.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2432 \
-num_iterations 200 \
-output_image out9.png
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out9.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2560 \
-num_iterations 200 \
-output_image out10.png
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out10.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2816 \
-num_iterations 200 \
-output_image out11.png
$INTERPRETER $NEURAL_STYLE \
-content_image $CONTENT_IMAGE -content_seg $CONTENT_MASK \
-style_image $STYLE_IMAGE -style_seg $STYLE_MASK \
-init image -init_image out11.png -color_codes $COLOR_CODES \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2944 \
-num_iterations 200 \
-output_image out12.png
CONTENT_IMAGE=content_image.jpg
STYLE_IMAGE=style_image.png
INTERPRETER=python
NEURAL_STYLE=neural_style.py
# Histogram Matching from style image to content image
python linear-color-transfer.py --target_image $CONTENT_IMAGE --source_image $STYLE_IMAGE --output_image content_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out1.png \
-image_size 640 \
-num_iterations 1500
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out1.png \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out2.png \
-image_size 768 \
-num_iterations 1000
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out2.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1024 \
-num_iterations 500 \
-output_image out3.png \
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out3.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1152 \
-num_iterations 200 \
-output_image out4.png \
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out4.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1536 \
-num_iterations 200 \
-output_image out5.png \
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out5.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1664 \
-num_iterations 200 \
-output_image out6.png \
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out6.png \
-tv_weight 0 -seed 876 -save_iter 100 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 1920 \
-num_iterations 200 \
-output_image out7.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out7.png \
-tv_weight 0 -seed 876 -save_iter 100 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2125 \
-num_iterations 200 \
-output_image out8.png
# Luminance Transfer from histogram matched content image, to the final output
python lum-transfer.py --output_lum2 out8.png --cp_mode lum2 --output_image out8_final.png --org_content content_colored_pca.png
# Luminance Transfer from unmodified content image, to the final output
python lum-transfer.py --output_lum2 out8.png --cp_mode lum2 --output_image out8_final_2.png --org_content $CONTENT_IMAGE
CONTENT_IMAGE=content_image.jpg
STYLE_IMAGE=style_image.png
INTERPRETER=python
NEURAL_STYLE=neural_style.py
# Histogram Matching from style image to content image
python linear-color-transfer.py --target_image $CONTENT_IMAGE --source_image $STYLE_IMAGE --output_image content_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out1.png \
-image_size 640 \
-num_iterations 1500
python linear-color-transfer.py --target_image out1.png --source_image $STYLE_IMAGE --output_image out1_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out1_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out2.png \
-image_size 768 \
-num_iterations 1000
python linear-color-transfer.py --target_image out2.png --source_image $STYLE_IMAGE --output_image out2_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out2_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1024 \
-num_iterations 500 \
-output_image out3.png \
python linear-color-transfer.py --target_image out3.png --source_image $STYLE_IMAGE --output_image out3_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out3_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1152 \
-num_iterations 200 \
-output_image out4.png \
python linear-color-transfer.py --target_image out4.png --source_image $STYLE_IMAGE --output_image out4_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out4_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1536 \
-num_iterations 200 \
-output_image out5.png \
python linear-color-transfer.py --target_image out5.png --source_image $STYLE_IMAGE --output_image out5_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out5_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1664 \
-num_iterations 200 \
-output_image out6.png \
python linear-color-transfer.py --target_image out6.png --source_image $STYLE_IMAGE --output_image out6_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out6_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 100 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 1920 \
-num_iterations 200 \
-output_image out7.png
python linear-color-transfer.py --target_image out7.png --source_image $STYLE_IMAGE --output_image out7_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out7_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 100 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2125 \
-num_iterations 200 \
-output_image out8.png
python linear-color-transfer.py --target_image out8.png --source_image $STYLE_IMAGE --output_image out8_hist_colored_pca.png
# Luminance Transfer from histogram matched content image, to the final output
python lum-transfer.py --output_lum2 out8.png --cp_mode lum2 --output_image out8_final.png --org_content content_colored_pca.png
# Luminance Transfer from unmodified content image, to the final output
python lum-transfer.py --output_lum2 out8.png --cp_mode lum2 --output_image out8_final_2.png --org_content $CONTENT_IMAGE
# The channel prunning can be donwloaded via:
# wget https://github.com/yihui-he/channel-pruning/releases/download/channel_pruning_5x/channel_pruning.caffemodel
# wget https://github.com/yihui-he/channel-pruning/releases/download/channel_pruning_5x/channel_pruning.prototxt
CONTENT_IMAGE=content_image.jpg
STYLE_IMAGE=style_image.png
INTERPRETER=python
NEURAL_STYLE=neural_style.py
# Histogram Matching from style image to content image
python linear-color-transfer.py --target_image $CONTENT_IMAGE --source_image $STYLE_IMAGE --output_image content_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out1.png \
-image_size 640 \
-num_iterations 1500
python linear-color-transfer.py --target_image out1.png --source_image $STYLE_IMAGE --output_image out1_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out1_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out2.png \
-image_size 768 \
-num_iterations 1000
python linear-color-transfer.py --target_image out2.png --source_image $STYLE_IMAGE --output_image out2_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out2_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1024 \
-num_iterations 500 \
-output_image out3.png \
python linear-color-transfer.py --target_image out3.png --source_image $STYLE_IMAGE --output_image out3_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out3_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1152 \
-num_iterations 200 \
-output_image out4.png \
python linear-color-transfer.py --target_image out4.png --source_image $STYLE_IMAGE --output_image out4_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out4_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1536 \
-num_iterations 200 \
-output_image out5.png \
python linear-color-transfer.py --target_image out5.png --source_image $STYLE_IMAGE --output_image out5_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out5_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1664 \
-num_iterations 200 \
-output_image out6.png \
python linear-color-transfer.py --target_image out6.png --source_image $STYLE_IMAGE --output_image out6_hist_colored_pca.png
# Use the channel pruning model in this step if the image dimensions are too large
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out6_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 100 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 1920 \
-num_iterations 200 \
-output_image out7.png
python linear-color-transfer.py --target_image out7.png --source_image $STYLE_IMAGE --output_image out7_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out7_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2048 \
-num_iterations 200 \
-output_image out8.png
python linear-color-transfer.py --target_image out8.png --source_image $STYLE_IMAGE --output_image out8_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out8_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2432 \
-num_iterations 200 \
-output_image out9.png
python linear-color-transfer.py --target_image out9.png --source_image $STYLE_IMAGE --output_image out9_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out9_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2560 \
-num_iterations 200 \
-output_image out10.png
python linear-color-transfer.py --target_image out10.png --source_image $STYLE_IMAGE --output_image out10_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out10_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2816 \
-num_iterations 200 \
-output_image out11.png
python linear-color-transfer.py --target_image out11.png --source_image $STYLE_IMAGE --output_image out11_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out11_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2944 \
-num_iterations 200 \
-output_image out12.png
python linear-color-transfer.py --target_image out12.png --source_image $STYLE_IMAGE --output_image out12_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out12_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 3328 \
-num_iterations 200 \
-output_image out13.png
python linear-color-transfer.py --target_image out13.png --source_image $STYLE_IMAGE --output_image out13_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out13_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -proto_file models/channel_pruning.prototxt -model_file models/channel_pruning.caffemodel -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 3400 \
-num_iterations 200 \
-output_image out14.png
python linear-color-transfer.py --target_image out14.png --source_image $STYLE_IMAGE --output_image out14_hist_colored_pca.png
# Luminance Transfer from histogram matched content image, to the final output
python lum-transfer.py --output_lum2 out12.png --cp_mode lum2 --output_image out12_final.png --org_content content_colored_pca.png
# Luminance Transfer from unmodified content image, to the final output
python lum-transfer.py --output_lum2 out12.png --cp_mode lum2 --output_image out12_final_2.png --org_content $CONTENT_IMAGE
# This variant of multires was used with 8 Tesla K80 11GB GPUs. The script may need to be adjusted depending on the content image size.
CONTENT_IMAGE=content_image.jpg
STYLE_IMAGE=style_image.png
INTERPRETER=th
NEURAL_STYLE=neural_style.lua
#Histogram Matching from style image to content image:
python linear-color-transfer.py --target_image $CONTENT_IMAGE --source_image $STYLE_IMAGE --output_image content_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out1.png \
-image_size 640 \
-num_iterations 1500
python linear-color-transfer.py --target_image out1.png --source_image $STYLE_IMAGE --output_image out1_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out1_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 500 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-output_image out2.png \
-image_size 768 \
-num_iterations 1000
python linear-color-transfer.py --target_image out2.png --source_image $STYLE_IMAGE --output_image out2_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out2_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1024 \
-num_iterations 500 \
-output_image out3.png \
python linear-color-transfer.py --target_image out3.png --source_image $STYLE_IMAGE --output_image out3_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out3_hist_colored_pca.png \
-tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1152 \
-num_iterations 200 \
-output_image out4.png \
python linear-color-transfer.py --target_image out4.png --source_image $STYLE_IMAGE --output_image out4_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out4_hist_colored_pca.png \
-gpu 0,1,2,3,4,5,6,7 -multigpu_strategy 3,6,12,15,20,26,31 -tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1536 \
-num_iterations 200 \
-output_image out5.png \
python linear-color-transfer.py --target_image out5.png --source_image $STYLE_IMAGE --output_image out5_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out5_hist_colored_pca.png \
-gpu 0,1,2,3,4,5,6,7 -multigpu_strategy 3,6,12,15,20,26,31 -tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1664 \
-num_iterations 200 \
-output_image out6.png \
python linear-color-transfer.py --target_image out6.png --source_image $STYLE_IMAGE --output_image out6_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out6_hist_colored_pca.png \
-gpu 0,1,2,3,4,5,6,7 -multigpu_strategy 3,6,12,15,20,26,31 -tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune \
-image_size 1920 \
-num_iterations 200 \
-output_image out7.png
python linear-color-transfer.py --target_image out7.png --source_image $STYLE_IMAGE --output_image out7_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out7_hist_colored_pca.png \
-gpu 0,1,2,3,4,5,6,7 -multigpu_strategy 3,6,12,15,20,26,31 -tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2048 \
-num_iterations 200 \
-output_image out8.png
python linear-color-transfer.py --target_image out8.png --source_image $STYLE_IMAGE --output_image out8_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out8_hist_colored_pca.png \
-gpu 0,1,2,3,4,5,6,7 -multigpu_strategy 3,6,12,15,20,26,31 -tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2432 \
-num_iterations 200 \
-output_image out9.png
python linear-color-transfer.py --target_image out9.png --source_image $STYLE_IMAGE --output_image out9_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out9_hist_colored_pca.png \
-gpu 0,1,2,3,4,5,6,7 -multigpu_strategy 3,6,12,15,20,26,31 -tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2560 \
-num_iterations 200 \
-output_image out10.png
python linear-color-transfer.py --target_image out10.png --source_image $STYLE_IMAGE --output_image out10_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out10_hist_colored_pca.png \
-gpu 0,1,2,3,4,5,6,7 -multigpu_strategy 3,6,12,15,20,26,31 -tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2816 \
-num_iterations 200 \
-output_image out11.png
python linear-color-transfer.py --target_image out11.png --source_image $STYLE_IMAGE --output_image out11_hist_colored_pca.png
$INTERPRETER $NEURAL_STYLE \
-content_image content_colored_pca.png \
-style_image $STYLE_IMAGE \
-init image -init_image out11_hist_colored_pca.png \
-gpu 0,1,2,3,4,5,6,7 -multigpu_strategy 3,6,12,15,20,26,31 -tv_weight 0 -seed 876 -save_iter 0 -print_iter 50 -init image -backend cudnn -cudnn_autotune -optimizer adam \
-image_size 2944 \
-num_iterations 200 \
-output_image out12.png
python linear-color-transfer.py --target_image out12.png --source_image $STYLE_IMAGE --output_image out12_hist_colored_pca.png
# Luminance Transfer from histogram matched content image, to the final output:
python lum-transfer.py --output_lum2 out12.png --cp_mode lum2 --output_image out12_final.png --org_content content_colored_pca.png
# Luminance Transfer from unmodified content image, to the final output:
python lum-transfer.py --output_lum2 out12.png --cp_mode lum2 --output_image out12_final_2.png --org_content $CONTENT_IMAGE
@ProGamerGov
Copy link
Author

This project has been continued here: https://github.com/ProGamerGov/Multiscale-Resolution-Scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment