-
Notifications
You must be signed in to change notification settings - Fork 3
/
cli.py
66 lines (56 loc) · 2.23 KB
/
cli.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
import sys
if __name__ == '__main__':
if (len(sys.argv) == 1):
print("Use cli.py -h to get more help")
exit()
import argparse
from usps import config
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("--main",
"-m",
action='store_true',
help="minimal test")
arg_parser.add_argument("--usps-test",
"-test",
action='store_true',
help="start usps test")
arg_parser.add_argument("--usps-train",
"-train",
action='store_true',
help="start usps train")
arg_parser.add_argument("--usps-simplify",
"-s",
action='store_true',
help="simplify usps weights")
arg_parser.add_argument("--usps-preview",
"-p",
action='store_true',
help="preview usps realtime predict result")
arg_parser.add_argument("--usps-preview-file-name",
"-pf",
type=str,
default="",
help=f"usps realtime predict image name, default: {config.default_img_name}")
arg_parser.add_argument("--pycharm",
"-pycharm",
action='store_true',
help="pycharm preview mode")
opt = arg_parser.parse_args()
if opt.main:
import main
main.run()
elif opt.usps_preview or (opt.usps_preview_file_name != ""):
from usps import realtime_predict
realtime_predict.run(opt.usps_preview_file_name, opt.pycharm)
elif opt.usps_train:
from usps import train
import multiprocessing as mp
mp.freeze_support()
train.run(True)
elif opt.usps_test and not opt.usps_simplify:
from usps import train
train.run(False)
if opt.usps_simplify:
from usps import weights_simplify
weights_simplify.run()
print("Simplifying weights finished")