-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_final.py
More file actions
37 lines (34 loc) · 1.03 KB
/
test_final.py
File metadata and controls
37 lines (34 loc) · 1.03 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
from tensorboard_logger import Logger
from option import args
import torch
import utility
import data
import loss
from trainer_final import Trainer
import warnings
warnings.filterwarnings('ignore')
import model
torch.manual_seed(args.seed)
checkpoint = utility.checkpoint(args)
import os
scale = 0
def main():
global model
if checkpoint.ok:
loader = data.Data(args)
_model = model.Model(args, checkpoint)
if args.pretrain != "":
state_dict = torch.load(args.pretrain)
model_dict = _model.model.state_dict()
total = 0
for (k,v) in state_dict.items():
if k in model_dict.keys():
total += 1
model_dict[k] = v
_model.model.load_state_dict(model_dict,strict = True)
_loss = loss.Loss(args, checkpoint) if not args.test_only else None
t = Trainer(args, loader, _model, _loss, checkpoint)
print('test')
t.test2()
if __name__ == '__main__':
main()