-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
64 lines (48 loc) · 1.82 KB
/
main.py
File metadata and controls
64 lines (48 loc) · 1.82 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from src.Utils.imports import os
import sys
PROJECT_PATH = os.getcwd()
def extract_command(command:str):
cmd = command.split(' ')[0]
arguments = command.replace(cmd,'').split(' -')
args = {}
for i in arguments:
try:
tmp = i.replace(' ', '#',1).split('#')
args[tmp[0]] = tmp[1].strip()
except:
pass
return cmd, args
commands = {'exit': {'fnc': sys.exit , 'args':['load_dir', 'num_steps']},
'train': {'fnc': None , 'args':['load_dir', 'num_steps']},
'demo': {'fnc': None, 'args':['model_loc']},
'play': {'fnc': None, 'args':None},
'data': {'fnc': None, 'args':None},
'pretrain': {'fnc': None, 'args':None},
}
def main():
global commands
from src.Utils.imports import AppManager
print(PROJECT_PATH)
iAppManager = AppManager(PROJECT_PATH)
command = input("Input Command w/ Arguments: ")
cmd, args = extract_command(command)
if cmd in commands:
if cmd == 'train':
current_command = commands[cmd]
if 'num_steps' in args and 'load_dir' in args:
iAppManager.Train(int(args['num_steps']), args['load_dir'])
elif len(args) == 0:
iAppManager.Train()
else:
iAppManager.Train(num_steps=int(args['num_steps'])) if 'num_steps' in args else iAppManager.Train(load_dir= args['load_dir'])
elif cmd == 'demo':
current_command = commands[cmd]
elif cmd == 'play':
iAppManager.Run()
elif cmd == 'data':
iAppManager.set_DataCollection()
iAppManager.Run()
elif cmd == 'pretrain':
iAppManager.set_PreTrain()
if __name__ == '__main__':
main()