-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (32 loc) · 1.24 KB
/
main.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
import argparse
from src.trainer import SimCLRTrainer, ClassificationTrainer, ConditionalGeneratorTrainer
from src.utils import get_config
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--mode',
type=str,
help='mode to run',
choices=['train', 'evaluate'])
parser.add_argument('-t', '--task',
type=str,
help='task to run',
choices=['encoder', 'generation', 'classification'])
parser.add_argument('-c', '--config',
type=str,
help='path to config file')
args = parser.parse_args()
config_path = args.config
config = get_config(config_path)
mode = args.mode
task = args.task
if task == 'encoder':
trainer = SimCLRTrainer(config_path, config)
elif task == 'classification':
trainer = ClassificationTrainer(config_path, config)
elif task == 'generation':
trainer = ConditionalGeneratorTrainer(config_path, config)
if mode == 'train':
trainer.train()
elif mode == 'evaluate':
if task == 'generation':
trainer.evaluate()