-
Notifications
You must be signed in to change notification settings - Fork 3
/
main_eval.py
27 lines (19 loc) · 897 Bytes
/
main_eval.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
import argparse
import torch
from nn import config as nn_config
def main():
parser = argparse.ArgumentParser(description='model evaluation script')
parser.add_argument('model_src_path', type=str, help='model src path')
args = parser.parse_args()
device = 'cuda' if torch.cuda.is_available() else 'cpu'
ckpt = torch.load(args.model_src_path, map_location=device)
usr_configs = ckpt.get('analysis').trainer_usr_configs
usr_configs.train.train_model = False
usr_configs.device.use_gpu = False if device == 'cpu' else True
usr_configs.train.model_src_path = args.model_src_path
trainer_configs = nn_config.TrainerConfigs()
trainer_configs.setup(usr_configs)
trainer = nn_config.get_trainer(usr_configs.train)(trainer_configs)
trainer.eval(trainer.trainer_configs.test_loader, print_acc=True, cfm=False)
if __name__ == '__main__':
main()