-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
63 lines (49 loc) · 1.52 KB
/
run.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
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 10 01:13:44 2021
@author: wasil
"""
import os
import argparse
import yaml
def parse_args():
"""Parse input arguments"""
parser = argparse.ArgumentParser(description='Experiment Args')
parser.add_argument(
'--RUN_MODE', dest='RUN_MODE',
choices=['DATA_PROCESSING', 'TRAIN'],
help='{Data Preprocessing, training}',
type=str, required=True
)
#parser.add_argument(
# '--CPU', dest='CPU',
# help='use CPU instead of GPU',
# action='store_true'
#)
#parser.add_argument(
# '--MODEL', dest='MODEL',
# help='upload trained model',
# type=int
#)
args = parser.parse_args()
return args
class MainExec(object):
def __init__(self, configs):
#self.args = args
self.cfgs = configs
#if self.args.CPU:
# self.device = torch.device("cpu")
#else:
# self.device = torch.device(
# "cuda" if torch.cuda.is_available() else "cpu"
# ) # for failsafe
#if self.args.RUN_MODE == 'test' or self.args.RUN_MODE =='bleu':
# if self.args.MODEL == None:
# raise Exception('Add a model number you need to evaluate, e.g Model_8.pickle, then pass 8 as an argument')
print(self.cfgs['DATA'])
if __name__ == "__main__":
args = parse_args()
with open('./config.yml', 'r') as f:
model_config = yaml.safe_load(f)
exec = MainExec( model_config)
#exec.run(args.RUN_MODE)