diff --git a/appendix/train_upconv_7_art.sh b/appendix/train_upconv_7_art.sh new file mode 100755 index 0000000..a9a7786 --- /dev/null +++ b/appendix/train_upconv_7_art.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# convert data +th convert_data.lua -max_training_image_size 1600 + +# scale +th train.lua -save_history 1 -inner_epoch 1 -epoch 100 -scale 2 -model upconv_7 -method scale -model_dir models/test/upconv_7_rev3 -downsampling_filters "Box,Sinc" -test query/scale_test.png -backend cudnn -thread 4 + +# noise_scale +th train.lua -save_history 1 -model upconv_7 -method noise_scale -noise_level 0 -model_dir models/test/yuv420_rev2 -downsampling_filters "Box,Sinc" -test query/noise_test.jpg -backend cudnn -thread 4 -resume models/test/upconv_7_rev3/scale2.0x_model.t7 -style art +th train.lua -save_history 1 -model upconv_7 -method noise_scale -noise_level 1 -model_dir models/test/yuv420_rev2 -downsampling_filters "Box,Sinc" -test query/noise_test.jpg -backend cudnn -thread 4 -resume models/test/upconv_7_rev3/scale2.0x_model.t7 -style art +th train.lua -save_history 1 -model upconv_7 -method noise_scale -noise_level 2 -model_dir models/test/yuv420_rev2 -downsampling_filters "Box,Sinc" -test query/noise_test.jpg -backend cudnn -thread 4 -resume models/test/upconv_7_rev3/scale2.0x_model.t7 -style art +th train.lua -save_history 1 -model upconv_7 -method noise_scale -noise_level 3 -model_dir models/test/yuv420_rev2 -downsampling_filters "Box,Sinc" -test query/noise_test.jpg -backend cudnn -thread 4 -resume models/test/upconv_7_rev3/scale2.0x_model.t7 -style art -nr_rate 1 + +# noise +th train.lua -save_history 1 -model vgg_7 -method noise -noise_level 0 -model_dir models/test/yuv420_rev2 -test query/noise_test.jpg -backend cudnn -thread 4 -style art -crop_size 32 +th train.lua -save_history 1 -model vgg_7 -method noise -noise_level 1 -model_dir models/test/yuv420_rev2 -test query/noise_test.jpg -backend cudnn -thread 3 -style art -crop_size 32 +th train.lua -save_history 1 -model vgg_7 -method noise -noise_level 2 -model_dir models/test/yuv420_rev2 -test query/noise_test.jpg -backend cudnn -thread 3 -style art -crop_size 32 +th train.lua -save_history 1 -model vgg_7 -method noise -noise_level 3 -model_dir models/test/yuv420_rev2 -test query/noise_test.jpg -backend cudnn -thread 3 -style art -crop_size 32 -nr_rate 1 diff --git a/appendix/train_upconv_7_photo.sh b/appendix/train_upconv_7_photo.sh new file mode 100755 index 0000000..eec1189 --- /dev/null +++ b/appendix/train_upconv_7_photo.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# convert data +th convert_data.lua -style photo -data_dir ./data/photo -max_training_image_size 1600 + +# scale +th train.lua -save_history 1 -model upconv_7 -downsampling_filters "Box,Sinc,Catrom" -style photo -data_dir ./data/photo -model_dir models/test/new_photo -test query/machine.png -color rgb -random_unsharp_mask_rate 0.3 -thread 3 -backend cudnn + +# noise_scale +th train.lua -save_history 1 -model upconv_7 -downsampling_filters "Box,Sinc,Catrom" -style photo -method noise_scale -noise_level 0 -data_dir ./data/photo -model_dir models/test/new_photo -test query/bsd500.jpg -color rgb -random_unsharp_mask_rate 0.5 -thread 3 -backend cudnn -nr_rate 0.3 -resume models/test/new_photo/scale2.0x_model.t7 -oracle_rate 0.0 -active_cropping_rate 0 -resize_blur_min 1 -resize_blur_max 1 +th train.lua -save_history 1 -model upconv_7 -downsampling_filters "Box,Sinc,Catrom" -style photo -method noise_scale -noise_level 1 -data_dir ./data/photo -model_dir models/test/new_photo -test query/bsd500.jpg -color rgb -random_unsharp_mask_rate 0.5 -thread 3 -backend cudnn -nr_rate 0.3 -resume models/test/new_photo/scale2.0x_model.t7 -oracle_rate 0.0 -active_cropping_rate 0 -resize_blur_min 1 -resize_blur_max 1 +th train.lua -save_history 1 -model upconv_7 -downsampling_filters "Box,Sinc,Catrom" -style photo -method noise_scale -noise_level 2 -data_dir ./data/photo -model_dir models/test/new_photo -test query/bsd500.jpg -color rgb -random_unsharp_mask_rate 0.5 -thread 3 -backend cudnn -nr_rate 0.6 -resume models/test/new_photo/scale2.0x_model.t7 -oracle_rate 0.0 -active_cropping_rate 0 -resize_blur_min 1 -resize_blur_max 1 +th train.lua -save_history 1 -model upconv_7 -downsampling_filters "Box,Sinc,Catrom" -style photo -method noise_scale -noise_level 3 -data_dir ./data/photo -model_dir models/test/new_photo -test query/bsd500.jpg -color rgb -random_unsharp_mask_rate 0.5 -thread 3 -backend cudnn -nr_rate 1 -resume models/test/new_photo/scale2.0x_model.t7 -oracle_rate 0.0 -active_cropping_rate 0 -resize_blur_min 1 -resize_blur_max 1 + +# noise +th train.lua -save_history 1 -model vgg_7 -style photo -method noise -noise_level 0 -data_dir ./data/photo -model_dir models/test/new_photo -test query/bsd500.jpg -color rgb -random_unsharp_mask_rate 0.5 -thread 3 -backend cudnn -nr_rate 0.3 -oracle_rate 0.0 -active_cropping_rate 0 -resize_blur_min 1 -resize_blur_max 1 -crop_size 32 +th train.lua -save_history 1 -model vgg_7 -style photo -method noise -noise_level 1 -data_dir ./data/photo -model_dir models/test/new_photo -test query/bsd500.jpg -color rgb -random_unsharp_mask_rate 0.5 -thread 3 -backend cudnn -nr_rate 0.3 -oracle_rate 0.0 -active_cropping_rate 0 -resize_blur_min 1 -resize_blur_max 1 -crop_size 32 +th train.lua -save_history 1 -model vgg_7 -style photo -method noise -noise_level 2 -data_dir ./data/photo -model_dir models/test/new_photo -test query/bsd500.jpg -color rgb -random_unsharp_mask_rate 0.5 -thread 3 -backend cudnn -nr_rate 0.6 -oracle_rate 0.0 -active_cropping_rate 0 -resize_blur_min 1 -resize_blur_max 1 -crop_size 32 +th train.lua -save_history 1 -model vgg_7 -style photo -method noise -noise_level 3 -data_dir ./data/photo -model_dir models/test/new_photo -test query/bsd500.jpg -color rgb -random_unsharp_mask_rate 0.5 -thread 3 -backend cudnn -nr_rate 1 -oracle_rate 0.0 -active_cropping_rate 0 -resize_blur_min 1 -resize_blur_max 1 -crop_size 32 diff --git a/tools/export.sh b/tools/export.sh deleted file mode 100755 index 460c7c7..0000000 --- a/tools/export.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -x - -export_model() { - if [ -f models/${1}/scale2.0x_model.t7 ] && [ ! -h models/${1}/scale2.0x_model.t7 ] ; then - th tools/export_model.lua -i models/${1}/scale2.0x_model.t7 -o models/${1}/scale2.0x_model.json - fi - if [ -f models/${1}/noise1_model.t7 ] && [ ! -h models/${1}/noise1_model.t7 ]; then - th tools/export_model.lua -i models/${1}/noise1_model.t7 -o models/${1}/noise1_model.json - fi - if [ -f models/${1}/noise2_model.t7 ] && [ ! -h models/${1}/noise2_model.t7 ]; then - th tools/export_model.lua -i models/${1}/noise2_model.t7 -o models/${1}/noise2_model.json - fi - if [ -f models/${1}/noise3_model.t7 ] && [ ! -h models/${1}/noise3_model.t7 ]; then - th tools/export_model.lua -i models/${1}/noise3_model.t7 -o models/${1}/noise3_model.json - fi -} -export_model vgg_7/art -export_model vgg_7/art_y -export_model vgg_7/photo -export_model vgg_7/ukbench -export_model upconv_7/art diff --git a/tools/export_all.sh b/tools/export_all.sh new file mode 100755 index 0000000..d3e44b3 --- /dev/null +++ b/tools/export_all.sh @@ -0,0 +1,37 @@ +#!/bin/sh -x + +export_model() { + if [ -f models/${1}/scale2.0x_model.t7 ] && [ ! -h models/${1}/scale2.0x_model.t7 ] ; then + th tools/export_model.lua -i models/${1}/scale2.0x_model.t7 -o models/${1}/scale2.0x_model.json + fi + + if [ -f models/${1}/noise0_model.t7 ] && [ ! -h models/${1}/noise0_model.t7 ]; then + th tools/export_model.lua -i models/${1}/noise0_model.t7 -o models/${1}/noise0_model.json + fi + if [ -f models/${1}/noise1_model.t7 ] && [ ! -h models/${1}/noise1_model.t7 ]; then + th tools/export_model.lua -i models/${1}/noise1_model.t7 -o models/${1}/noise1_model.json + fi + if [ -f models/${1}/noise2_model.t7 ] && [ ! -h models/${1}/noise2_model.t7 ]; then + th tools/export_model.lua -i models/${1}/noise2_model.t7 -o models/${1}/noise2_model.json + fi + if [ -f models/${1}/noise3_model.t7 ] && [ ! -h models/${1}/noise3_model.t7 ]; then + th tools/export_model.lua -i models/${1}/noise3_model.t7 -o models/${1}/noise3_model.json + fi + + if [ -f models/${1}/noise0_scale2.0x_model.t7 ] && [ ! -h models/${1}/noise0_scale2.0x_model.t7 ]; then + th tools/export_model.lua -i models/${1}/noise0_scale2.0x_model.t7 -o models/${1}/noise0_scale2.0x_model.json + fi + if [ -f models/${1}/noise1_scale2.0x_model.t7 ] && [ ! -h models/${1}/noise1_scale2.0x_model.t7 ]; then + th tools/export_model.lua -i models/${1}/noise1_scale2.0x_model.t7 -o models/${1}/noise1_scale2.0x_model.json + fi + if [ -f models/${1}/noise2_scale2.0x_model.t7 ] && [ ! -h models/${1}/noise2_scale2.0x_model.t7 ]; then + th tools/export_model.lua -i models/${1}/noise2_scale2.0x_model.t7 -o models/${1}/noise2_scale2.0x_model.json + fi + if [ -f models/${1}/noise3_scale2.0x_model.t7 ] && [ ! -h models/${1}/noise3_scale2.0x_model.t7 ]; then + th tools/export_model.lua -i models/${1}/noise3_scale2.0x_model.t7 -o models/${1}/noise3_scale2.0x_model.json + fi +} +export_model vgg_7/art +export_model upconv_7/art +export_model vgg_7/photo +export_model upconv_7/photo diff --git a/tools/rebuild.sh b/tools/rebuild.sh deleted file mode 100755 index ad7c518..0000000 --- a/tools/rebuild.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -x - -# maybe you should backup models - -rebuild() { - if [ -f models/${1}/scale2.0x_model.t7 ] && [ ! -h models/${1}/scale2.0x_model.t7 ] ; then - th tools/rebuild_model.lua -i models/${1}/scale2.0x_model.t7 -o models/${1}/scale2.0x_model.t7 -backend cunn -model $2 - fi - if [ -f models/${1}/noise1_model.t7 ] && [ ! -h models/${1}/noise1_model.t7 ]; then - th tools/rebuild_model.lua -i models/${1}/noise1_model.t7 -o models/${1}/noise1_model.t7 -backend cunn -model $2 - fi - if [ -f models/${1}/noise2_model.t7 ] && [ ! -h models/${1}/noise2_model.t7 ]; then - th tools/rebuild_model.lua -i models/${1}/noise2_model.t7 -o models/${1}/noise2_model.t7 -backend cunn -model $2 - fi - if [ -f models/${1}/noise3_model.t7 ] && [ ! -h models/${1}/noise3_model.t7 ]; then - th tools/rebuild_model.lua -i models/${1}/noise3_model.t7 -o models/${1}/noise3_model.t7 -backend cunn -model $2 - fi -} -rebuild vgg_7/art vgg_7 -rebuild vgg_7/art_y vgg_7 -rebuild vgg_7/photo vgg_7 -rebuild vgg_7/ukbench vgg_7 -rebuild upconv_7/art upconv_7 diff --git a/tools/rebuild_all.sh b/tools/rebuild_all.sh new file mode 100755 index 0000000..458aaf7 --- /dev/null +++ b/tools/rebuild_all.sh @@ -0,0 +1,39 @@ +#!/bin/sh -x + +# you should backup models + +rebuild() { + if [ -f models/${1}/scale2.0x_model.t7 ] && [ ! -h models/${1}/scale2.0x_model.t7 ] ; then + th tools/rebuild_model.lua -i models/${1}/scale2.0x_model.t7 -o models/${1}/scale2.0x_model.t7 -backend cunn -model $2 + fi + + if [ -f models/${1}/noise0_model.t7 ] && [ ! -h models/${1}/noise0_model.t7 ]; then + th tools/rebuild_model.lua -i models/${1}/noise0_model.t7 -o models/${1}/noise0_model.t7 -backend cunn -model $2 + fi + if [ -f models/${1}/noise1_model.t7 ] && [ ! -h models/${1}/noise1_model.t7 ]; then + th tools/rebuild_model.lua -i models/${1}/noise1_model.t7 -o models/${1}/noise1_model.t7 -backend cunn -model $2 + fi + if [ -f models/${1}/noise2_model.t7 ] && [ ! -h models/${1}/noise2_model.t7 ]; then + th tools/rebuild_model.lua -i models/${1}/noise2_model.t7 -o models/${1}/noise2_model.t7 -backend cunn -model $2 + fi + if [ -f models/${1}/noise3_model.t7 ] && [ ! -h models/${1}/noise3_model.t7 ]; then + th tools/rebuild_model.lua -i models/${1}/noise3_model.t7 -o models/${1}/noise3_model.t7 -backend cunn -model $2 + fi + + if [ -f models/${1}/noise0_scale2.0x_model.t7 ] && [ ! -h models/${1}/noise0_scale2.0x_model.t7 ]; then + th tools/rebuild_model.lua -i models/${1}/noise1_scale2.0x_model.t7 -o models/${1}/noise1_scale2.0x_model.t7 -backend cunn -model $2 + fi + if [ -f models/${1}/noise1_scale2.0x_model.t7 ] && [ ! -h models/${1}/noise1_scale2.0x_model.t7 ]; then + th tools/rebuild_model.lua -i models/${1}/noise1_scale2.0x_model.t7 -o models/${1}/noise1_scale2.0x_model.t7 -backend cunn -model $2 + fi + if [ -f models/${1}/noise2_scale2.0x_model.t7 ] && [ ! -h models/${1}/noise2_scale2.0x_model.t7 ]; then + th tools/rebuild_model.lua -i models/${1}/noise2_scale2.0x_model.t7 -o models/${1}/noise2_scale2.0x_model.t7 -backend cunn -model $2 + fi + if [ -f models/${1}/noise3_scale2.0x_model.t7 ] && [ ! -h models/${1}/noise3_scale2.0x_model.t7 ]; then + th tools/rebuild_model.lua -i models/${1}/noise3_scale2.0x_model.t7 -o models/${1}/noise3_scale2.0x_model.t7 -backend cunn -model $2 + fi +} +rebuild upconv_7/art upconv_7 +rebuild vgg_7/art vgg_7 +rebuild upconv_7/photo upconv_7 +rebuild vgg_7/photo vgg_7 diff --git a/train.sh b/train.sh deleted file mode 100755 index 96a7951..0000000 --- a/train.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -th convert_data.lua - -th train.lua -method scale -downsampling_filters "Box,Box,Blackman,Sinc,Lanczos" -model_dir models/anime_style_art_rgb -test images/miku_small.png # -thread 4 -backend cudnn -th train.lua -method noise -noise_level 1 -style art -model_dir models/anime_style_art_rgb -test images/miku_noisy.png -th train.lua -method noise -noise_level 2 -style art -model_dir models/anime_style_art_rgb -test images/miku_noisy.png -th train.lua -method noise -noise_level 3 -style art -model_dir models/anime_style_art_rgb -test images/miku_noisy.png -nr_rate 1 diff --git a/train_photo.sh b/train_photo.sh deleted file mode 100755 index 763f28b..0000000 --- a/train_photo.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -th convert_data.lua -style photo -data_dir ./data/photo -model_dir models/photo - -th train.lua -style photo -method scale -data_dir ./data/photo -model_dir models/photo -test work/scale_test_photo.png -color rgb -random_unsharp_mask_rate 0.1 #-thread 4 -backend cudnn -th train.lua -style photo -method noise -noise_level 1 -data_dir ./data/photo -model_dir models/photo -test work/noise_test_photo.jpg -color rgb -random_unsharp_mask_rate 0.5 -nr_rate 0.6 -th train.lua -style photo -method noise -noise_level 2 -data_dir ./data/photo -model_dir models/photo -test work/noise_test_photo.jpg -color rgb -random_unsharp_mask_rate 0.5 -nr_rate 0.8 -th train.lua -style photo -method noise -noise_level 3 -data_dir ./data/photo -model_dir models/photo -test work/noise_test_photo.jpg -color rgb -random_unsharp_mask_rate 0.5 -nr_rate 1