smooshie

Modified Volta

Oct 19th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.91 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. CONTENT_IMAGE=$1
  4. STYLE_IMAGE=$2
  5. CONTENT_WEIGHT=$3
  6. STYLE_WEIGHT=$4
  7. STYLE_SCALE=$5
  8. ORIGINAL_COLORS=$6
  9. multipleimages=false
  10.  
  11. if [[ $2 = *","* ]];
  12. then
  13.     multipleimages=true
  14. else
  15.     multipleimages=false
  16. fi
  17.  
  18. X2_SIZE=800
  19.  
  20. content=$(basename ${1%.*})
  21. style=$(basename ${2%.*})
  22. cw=$(basename ${3%.*})
  23. sw=$(basename ${4%.*})
  24. scale=$(basename ${5%.*})
  25. oc=$(basename ${6%.*})
  26.  
  27. OUT_DIR="$content-$style-$3-$4-$5-$6-large/"
  28. mkdir -p $OUT_DIR
  29.  
  30. th neural_style_dir_rng_fix.lua \
  31. -style_image $STYLE_IMAGE \
  32. -style_weight $STYLE_WEIGHT \
  33. -style_scale $STYLE_SCALE \
  34. -content_image $CONTENT_IMAGE \
  35. -content_weight $CONTENT_WEIGHT \
  36. -print_iter 100 \
  37. -save_iter 100 \
  38. -image_size 256 \
  39. -num_iterations 1000 \
  40. -model_file models/nyud-fcn32s-color-heavy.caffemodel \
  41. -proto_file models/nyud-fcn32s-color-heavy-trainval.prototxt \
  42. -content_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
  43. -style_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
  44. -optimizer lbfgs \
  45. -output_image $OUT_DIR/X0.png \
  46. -tv_weight 0.00001 \
  47. -original_colors $ORIGINAL_COLORS \
  48. -backend cudnn \
  49. -init random
  50.  
  51. PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  52.  
  53. if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
  54. then
  55.  
  56.     python3 ../Neural-Tools/linear-color-transfer.py \
  57.     --target_image $PREV \
  58.     --source_image ${STYLE_IMAGE##*,} \
  59.     --mode chol \
  60.     --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
  61.  
  62.     PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  63.  
  64. fi
  65.  
  66. th neural_style_dir_rng_fix.lua \
  67. -style_image $STYLE_IMAGE \
  68. -style_weight $STYLE_WEIGHT \
  69. -style_scale $STYLE_SCALE \
  70. -content_image $CONTENT_IMAGE \
  71. -content_weight $CONTENT_WEIGHT \
  72. -init image \
  73. -init_image $PREV \
  74. -save_iter 100 \
  75. -image_size 512 \
  76. -num_iterations 1000 \
  77. -model_file models/nyud-fcn32s-color-heavy.caffemodel \
  78. -proto_file models/nyud-fcn32s-color-heavy-trainval.prototxt \
  79. -content_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
  80. -style_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
  81. -optimizer lbfgs \
  82. -output_image $OUT_DIR/X1.png \
  83. -tv_weight 0.00001 \
  84. -original_colors $ORIGINAL_COLORS \
  85. -backend cudnn \
  86.  
  87. PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  88.  
  89. if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
  90. then
  91.  
  92.     python3 ../Neural-Tools/linear-color-transfer.py \
  93.     --target_image $PREV \
  94.     --source_image ${STYLE_IMAGE##*,} \
  95.     --mode chol \
  96.     --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
  97.  
  98.     PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  99.  
  100. fi
  101.  
  102. cp -b $PREV ~/mygoogledrive
  103.  
  104. CONTENT_WEIGHT=$(bc <<< "scale=2;$CONTENT_WEIGHT/5")
  105. STYLE_WEIGHT=$(bc <<< "scale=2;$STYLE_WEIGHT/10")
  106.  
  107. th neural_style_dir_rng_fix.lua \
  108. -style_image $STYLE_IMAGE \
  109. -style_weight $STYLE_WEIGHT \
  110. -style_scale $STYLE_SCALE \
  111. -content_image $CONTENT_IMAGE \
  112. -content_weight $CONTENT_WEIGHT \
  113. -init image \
  114. -init_image $PREV \
  115. -image_size $X2_SIZE \
  116. -num_iterations 1500 \
  117. -save_iter 250 \
  118. -model_file models/nyud-fcn32s-color-heavy.caffemodel \
  119. -proto_file models/nyud-fcn32s-color-heavy-trainval.prototxt \
  120. -content_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
  121. -style_layers relu1_1,relu2_1,relu3_1,relu4_1,relu5_1 \
  122. -optimizer lbfgs \
  123. -output_image $OUT_DIR/X2.png \
  124. -tv_weight 0.00001 \
  125. -original_colors $ORIGINAL_COLORS \
  126. -normalize_gradients \
  127. -backend cudnn
  128.  
  129. PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  130.  
  131. if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
  132. then
  133.  
  134.     python3 ../Neural-Tools/linear-color-transfer.py \
  135.     --target_image $PREV \
  136.     --source_image ${STYLE_IMAGE##*,} \
  137.     --mode chol \
  138.     --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
  139.  
  140.     PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  141.  
  142. fi
  143.  
  144. cp -b $PREV ~/mygoogledrive
  145.  
  146. STYLE_WEIGHT=1000
  147. CONTENT_WEIGHT=0
  148.  
  149. th neural_style_dir_rng_fix.lua \
  150. -style_image $STYLE_IMAGE \
  151. -style_weight $STYLE_WEIGHT \
  152. -style_scale $STYLE_SCALE \
  153. -content_image $CONTENT_IMAGE \
  154. -content_weight $CONTENT_WEIGHT \
  155. -output_image $OUT_DIR/X3.png \
  156. -num_iterations 200 \
  157. -model_file models/nyud-fcn32s-color-heavy.caffemodel \
  158. -proto_file models/nyud-fcn32s-color-heavy-trainval.prototxt \
  159. -optimizer adam \
  160. -save_iter 0 \
  161. -tv_weight 0 \
  162. -backend cudnn \
  163. -init image \
  164. -init_image $PREV \
  165. -learning_rate 1 \
  166. -image_size 1148 \
  167. -original_colors $ORIGINAL_COLORS \
  168. -normalize_gradients \
  169.  
  170. PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  171.  
  172. if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
  173. then
  174.  
  175.     python3 ../Neural-Tools/linear-color-transfer.py \
  176.     --target_image $PREV \
  177.     --source_image ${STYLE_IMAGE##*,} \
  178.     --mode chol \
  179.     --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
  180.  
  181.     PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  182.  
  183. fi
  184.  
  185. cp -b $PREV ~/mygoogledrive
  186.  
  187.  
  188. th neural_style_dir_rng_fix.lua \
  189. -style_image $STYLE_IMAGE \
  190. -style_weight $STYLE_WEIGHT \
  191. -style_scale $STYLE_SCALE \
  192. -content_image $CONTENT_IMAGE \
  193. -content_weight $CONTENT_WEIGHT \
  194. -output_image $OUT_DIR/X4.png \
  195. -num_iterations 600 \
  196. -model_file models/channel_pruning.caffemodel \
  197. -proto_file models/channel_pruning.prototxt \
  198. -optimizer adam \
  199. -save_iter 0 \
  200. -tv_weight 0 \
  201. -backend cudnn \
  202. -init image \
  203. -init_image $PREV \
  204. -learning_rate 1 \
  205. -image_size 1800 \
  206. -original_colors $ORIGINAL_COLORS \
  207. -normalize_gradients \
  208.  
  209. PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  210.  
  211. if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
  212. then
  213.  
  214.     python3 ../Neural-Tools/linear-color-transfer.py \
  215.     --target_image $PREV \
  216.     --source_image ${STYLE_IMAGE##*,} \
  217.     --mode chol \
  218.     --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
  219.  
  220.     PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  221.  
  222. fi
  223.  
  224. cp -b $PREV ~/mygoogledrive
  225.  
  226. #Insert
  227.  
  228.  
  229. th neural_style_dir_rng_fix.lua \
  230. -style_image $STYLE_IMAGE \
  231. -style_weight $STYLE_WEIGHT \
  232. -style_scale $STYLE_SCALE \
  233. -content_image $CONTENT_IMAGE \
  234. -content_weight $CONTENT_WEIGHT \
  235. -output_image $OUT_DIR/X5.png \
  236. -model_file models/nin_imagenet_conv.caffemodel \
  237. -proto_file models/train_val.prototxt \
  238. -num_iterations 200 \
  239. -content_layers relu0,relu1,relu2,relu3,relu5,relu6,relu7,relu8 \
  240. -style_layers relu0,relu1,relu2,relu3,relu5,relu6,relu7,relu8 \
  241. -optimizer adam \
  242. -save_iter 0 \
  243. -tv_weight 0 \
  244. -backend cudnn \
  245. -init image \
  246. -init_image $PREV \
  247. -learning_rate 1 \
  248. -image_size 2550 \
  249. -original_colors $ORIGINAL_COLORS \
  250. -normalize_gradients \
  251.  
  252. PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  253.  
  254. if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
  255. then
  256.  
  257.     python3 ../Neural-Tools/linear-color-transfer.py \
  258.     --target_image $PREV \
  259.     --source_image ${STYLE_IMAGE##*,} \
  260.     --mode chol \
  261.     --output_image "${PREV%.*}-$content-$style-$cw-$sw"-histfinal.png
  262.  
  263.     PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  264.  
  265. fi
  266.  
  267. cp -b $PREV ~/mygoogledrive
  268.  
  269. STYLE_WEIGHT=1000
  270. CONTENT_WEIGHT=0
  271.  
  272. th neural_style_dir_rng_fix.lua \
  273. -style_image $STYLE_IMAGE \
  274. -style_weight $STYLE_WEIGHT \
  275. -style_scale $STYLE_SCALE \
  276. -content_image $CONTENT_IMAGE \
  277. -content_weight $CONTENT_WEIGHT \
  278. -output_image $OUT_DIR/X6.png \
  279. -model_file models/nin_imagenet_conv.caffemodel \
  280. -proto_file models/train_val.prototxt \
  281. -num_iterations 200 \
  282. -content_layers relu0,relu1,relu2,relu3,relu5,relu6 \
  283. -style_layers relu0,relu1,relu2,relu3,relu5,relu6 \
  284. -optimizer adam \
  285. -save_iter 0 \
  286. -tv_weight 0 \
  287. -backend cudnn \
  288. -init image \
  289. -init_image $PREV \
  290. -learning_rate 1 \
  291. -image_size 2700 \
  292. -original_colors $ORIGINAL_COLORS \
  293. -normalize_gradients \
  294.  
  295. PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  296.  
  297. if [ $ORIGINAL_COLORS == 0 -a $multipleimages == false ];
  298. then
  299.  
  300.     python3 ../Neural-Tools/linear-color-transfer.py \
  301.     --target_image $PREV \
  302.     --source_image ${STYLE_IMAGE##*,} \
  303.     --mode chol \
  304.     --output_image "${PREV%.*}-$content-$style-$cw-$sw-$oc"-histfinal.png
  305.  
  306.     PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  307.     cp -b $PREV ~/mygoogledrive
  308. else
  309.     cp -b $OUT_DIR/X6.png ~/mygoogledrive/"X6-$content-$style-$cw-$sw-$oc-final".png
  310. fi
  311.  
  312. th neural_style_dir_rng_fix.lua \
  313. -style_image $STYLE_IMAGE \
  314. -style_weight $STYLE_WEIGHT \
  315. -style_scale $STYLE_SCALE \
  316. -content_image $CONTENT_IMAGE \
  317. -content_weight $CONTENT_WEIGHT \
  318. -output_image $OUT_DIR/X7.png \
  319. -model_file models/nin_imagenet_conv.caffemodel \
  320. -proto_file models/train_val.prototxt \
  321. -num_iterations 200 \
  322. -content_layers relu0,relu1,relu2,relu3,relu5,relu6,relu7,relu8 \
  323. -style_layers relu0,relu1,relu2,relu3,relu5,relu6,relu7,relu8 \
  324. -optimizer adam \
  325. -save_iter 0 \
  326. -tv_weight 0 \
  327. -backend cudnn \
  328. -init image \
  329. -init_image $PREV \
  330. -learning_rate 1 \
  331. -image_size 2900 \
  332. -original_colors $ORIGINAL_COLORS \
  333. -normalize_gradients \
  334.  
  335. PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  336.  
  337. if [ $multipleimages == false ];
  338. then
  339.  
  340.     python3 ../Neural-Tools/linear-color-transfer.py \
  341.     --target_image $PREV \
  342.     --source_image ${STYLE_IMAGE##*,} \
  343.     --mode chol \
  344.     --output_image "${PREV%.*}-$content-$style-$cw-$sw-$oc"-histfinal.png
  345.  
  346.     PREV=$OUT_DIR/$(ls -t $OUT_DIR | head -n1)
  347.     cp -b $PREV ~/mygoogledrive
  348. else
  349.     cp -b $OUT_DIR/X7.png ~/mygoogledrive/"X7-$content-$style-$cw-$sw-$oc-final".png
  350. fi
Advertisement
Add Comment
Please, Sign In to add comment