forked from yeungchenwa/FontDiffuser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_all.py
120 lines (112 loc) · 4.03 KB
/
run_all.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import subprocess
import argparse
import os
from utils_2 import fix_one_pic
def run(opt):
input_style_path = opt.input_path
gen_output_path = os.path.basename(os.path.normpath(input_style_path))
subprocess.run(
[
"python",
"batch_gen.py",
"--ckpt_dir=ckpt/",
f"--content_image_dir={opt.basic_path}",
# "--content_image_dir=data_examples/basic/test/",
f"--style_image_dir={opt.input_path}",
f"--save_image_dir=outputs/{gen_output_path}/",
f"--device={opt.cuda}",
"--algorithm_type=dpmsolver++",
"--guidance_type=classifier-free",
"--guidance_scale=7.5",
"--num_inference_steps=20",
"--method=multistep",
]
)
print(f"输出图片路径:outputs/{gen_output_path}/")
# fix_one_pic(opt.ttf_name)
# 目标路径
if not os.path.exists("svg_separate/"):
os.makedirs(f"svg_separate/")
if not os.path.exists(f"svg_separate_{gen_output_path}/"):
os.makedirs(f"svg_separate_{gen_output_path}/")
print(f"makedir:svg_separate,svg_separate_{gen_output_path}")
subprocess.run(["rm", f"svg_separate_{gen_output_path}/*"])
subprocess.run(["rm", f"pico_{gen_output_path}/*"])
subprocess.run(["rm", "svg_separate/*"])
subprocess.run(["rm", "pico/*"])
subprocess.run(
[
"node",
"potrace.js",
f"outputs/{gen_output_path}/",
f"svg_separate_{gen_output_path}/",
]
)
print(f"svg_separate路径:svg_separate_{gen_output_path}")
subprocess.run(
[
"node",
"run_pico.js",
f"svg_separate_{gen_output_path}/",
f"pico_{gen_output_path}/",
]
)
print(f"pico路径:pico_{gen_output_path}/")
subprocess.run(
[
"/usr/bin/python3",
"to_ttf.py",
"--input",
f"pico_{gen_output_path}/",
"--name",
f"{opt.ttf_name}_adjust_before",
"--v",
f"{opt.version}",
]
)
print(f"{opt.ttf_name}_adjust_before.ttf")
subprocess.run(
[
"/usr/bin/python3",
"adjust_ttf.py",
"--input_ttf",
f"{opt.ttf_name}_adjust_before.ttf",
"--out_name",
f"{opt.ttf_name}",
"--version",
f"{opt.version}",
"--output_path",
f"./",
]
)
print("\n\n\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n\n\n")
print(f"输出图片路径:outputs/{gen_output_path}/")
print(f"svg_separate路径:svg_separate_{gen_output_path}")
print(f"pico路径:pico_{gen_output_path}/")
print(f"初步字体:{opt.ttf_name}_adjust_before.ttf")
print(f"结果字体:{opt.ttf_name}.ttf")
if __name__ == "__main__":
"""
source activate fontdiffuser
cd /mnt/data/llch/FontDiffuser
python run_all.py --input data_examples/test_diff/ --name test --v v1.0 --cuda cuda:2
python run_all.py --input data_examples/test_style/fzfs_ai/ --name fzfs --v v1.1 --cuda cuda:0
python run_all.py --input data_examples/test_style/FZZCHJW_ai/ --name FZZCHJW --v v1.1 --cuda cuda:1
python run_all.py --input data_examples/test_style/cpp_ai/ --name 火炬_cpp1.0 --v v1.1 --cuda cuda:2
python run_all.py --input data_examples/test_style/crh_ai/ --name 火炬_crh1.0 --v v1.1 --cuda cuda:3
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"--input", dest="input_path", default="pic/cpp/ans", help="风格图片地址"
)
parser.add_argument("--name", dest="ttf_name", default="cpp", help="字体名字")
parser.add_argument("--v", dest="version", default="v1.0", help="字体版本")
parser.add_argument("--cuda", dest="cuda", default="cuda:0", help="gpu指定")
parser.add_argument(
"--basic_path",
dest="basic_path",
default="data_examples/basic/LXGWWenKaiGB-Light/",
help="basic图片地址",
)
opt = parser.parse_args()
run(opt)