-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconvert_single_image.py
More file actions
50 lines (43 loc) · 1.85 KB
/
convert_single_image.py
File metadata and controls
50 lines (43 loc) · 1.85 KB
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
import sys
import os
from argparse import ArgumentParser
from os.path import basename
from src.inference.convertor import *
from src.model.load_pretrained_model import *
def build_parser():
parser = ArgumentParser()
parser.add_argument('--png_path', type=str,
dest='png_path', help='png filepath to convert into HTML',
required=True)
parser.add_argument('--output_folder', type=str,
dest='output_folder', help='dir to save generated gui and html',
required=True)
parser.add_argument('--vocab_path', type=str,
dest='vocab_path', help='directory containing vocabulary',
required=True)
parser.add_argument('--model_json_file', type=str,
dest='model_json_file', help='trained model json file',
required=True)
parser.add_argument('--model_weights_file', type=str,
dest='model_weights_file', help='trained model weights file', required=True)
parser.add_argument('--style', type=str,
dest='style', help='style to use for generation', default='default')
return parser
def main():
parser = build_parser()
options = parser.parse_args()
png_path = options.png_path
output_folder = options.output_folder
model_json_file = options.model_json_file
model_weights_file = options.model_weights_file
vocab_path = options.vocab_path
style = options.style
if not os.path.exists(output_folder):
os.makedirs(output_folder)
load_model = load_pretrained_model()
model = load_model.load_model(model_json_file, model_weights_file)
convert = convertor(vocab_path)
convert.convert_single_image(png_path,model,output_folder, style=style)
print("Converted sucessfully")
if __name__ == "__main__":
main()