-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgen_all_pass2.py
59 lines (55 loc) · 2.64 KB
/
gen_all_pass2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Take reference from https://github.com/DmitryUlyanov/deep-image-prior
import os
import math
numImgs = 35
# numGpus = 16
numGpus = 1
if os.path.exists('output') == 0:
os.mkdir('output')
N = int(math.ceil(float(numImgs)/numGpus))
for j in range(1, numGpus+1):
cmd = ''
for i in range(1, N+1):
idx = (i-1) * numGpus + (j-1)
if idx >= 0 and idx < numImgs:
print('Working on image idx = ', idx)
if idx in [0, 2, 4, 9, 14, 26, 18, 24]:
part_cmd2 =' python3 pass2.py '\
' -content_image data/' + str(idx) + '_naive.jpg '\
' -style_image data/' + str(idx) + '_target.jpg '\
' -tight_mask data/' + str(idx) + '_c_mask.jpg '\
' -dilated_mask data/' + str(idx) + '_c_mask_dilated.jpg '\
' -inter_image official_result/' + str(idx) + '_inter_res.jpg ' \
' -gpu cpu ' \
' -output_img output/' + str(idx) + '_final_res.jpg '\
' -output_img_size 710 ' \
' -n_iter 3000 ' \
' -lr 3e-1 ' \
' -style_layers relu1_1,relu2_1,relu3_1,relu4_1 '\
' -content_layers relu4_1 ' \
' -histogram_layers relu1_1,relu4_1 ' \
' -histogram_weight 1 ' \
' -verbose ' \
' -print_interval 10 -save_img_interval 10 &&'
else:
part_cmd2 =' python3 pass2.py '\
' -content_image data/' + str(idx) + '_naive.jpg '\
' -style_image data/' + str(idx) + '_target.jpg '\
' -tight_mask data/' + str(idx) + '_c_mask.jpg '\
' -dilated_mask data/' + str(idx) + '_c_mask_dilated.jpg '\
' -inter_image official_result/' + str(idx) + '_inter_res.jpg ' \
' -gpu cpu ' \
' -output_img output/' + str(idx) + '_final_res.jpg '\
' -output_img_size 710 ' \
' -n_iter 3000 ' \
' -lr 3e-1 ' \
' -style_layers relu1_1,relu2_1,relu3_1,relu4_1 '\
' -content_layers relu4_1 ' \
' -histogram_layers relu1_1,relu4_1 ' \
' -histogram_weight 1 ' \
' -verbose ' \
' -print_interval 100 -save_img_interval 100 &&'
cmd = cmd + part_cmd2
cmd = cmd[1:len(cmd)-1]
print('#',cmd)
os.system(cmd)