forked from arxyzan/data2vec-pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain.py
25 lines (20 loc) · 739 Bytes
/
train.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
import omegaconf
from text.trainer import TextTrainer
from vision.trainer import VisionTrainer
from audio.trainer import AudioTrainer
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--config', type=str, help='path to yaml config file')
args = parser.parse_args()
cfg_path = args.config
cfg = omegaconf.OmegaConf.load(cfg_path)
modality = cfg.modality
trainers_dict = {
'text': TextTrainer,
'vision': VisionTrainer,
'audio': AudioTrainer
}
assert modality in trainers_dict.keys(), f'invalid modality `{cfg.modality}`, expected {list(trainers_dict.keys())}'
trainer = trainers_dict[modality](cfg)
trainer.train()