-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathmain.py
37 lines (33 loc) · 1.06 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
# 2021.05.07-Changed for IPT
# Huawei Technologies Co., Ltd. <foss@huawei.com>
from option import args
import torch
import utility
import data
import loss
from trainer import Trainer
import warnings
warnings.filterwarnings('ignore')
import os
os.system('pip install einops')
import model
torch.manual_seed(args.seed)
checkpoint = utility.checkpoint(args)
def main():
global model
if checkpoint.ok:
loader = data.Data(args)
_model = model.Model(args, checkpoint)
if args.pretrain != "":
if 's3' in args.pretrain:
import moxing as mox
mox.file.copy_parallel(args.pretrain,"/cache/models/ipt.pt")
args.pretrain = "/cache/models/ipt.pt"
state_dict = torch.load(args.pretrain)
_model.model.load_state_dict(state_dict,strict = False)
_loss = loss.Loss(args, checkpoint) if not args.test_only else None
t = Trainer(args, loader, _model, _loss, checkpoint)
t.test()
checkpoint.done()
if __name__ == '__main__':
main()