-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (31 loc) · 1.35 KB
/
Copy pathmain.py
File metadata and controls
38 lines (31 loc) · 1.35 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
38
# -*- coding:utf-8 -*-
import time, sys
import h5py
import numpy as np
from datetime import datetime
import engine, utility
if __name__ == "__main__":
# load config
if (len(sys.argv) <= 1):
raise Exception("configure file must be specified!")
args = utility.load_params(json_file=sys.argv[1])
print('------------------------------------------------------------')
print('Model: ' + args['model']['arch'])
print('Target: ' + str(args['model']['target']))
print('BatchNorm: ' + str(args['model']['use_bn']))
print('Optimizer: ' + args['model']['optimizer'])
print('Activation: ' + args['model']['activation'])
print('Resume: ' + str(args['model']['resume']))
print('Batch Size: ' + str(args['data']['train']['batch_size']))
print('Patch Size: ' + str(args['data']['train']['patch_size']))
print('------------------------------------------------------------')
checkpoint_dir = '/mnt/pami/zhouqi/checkpoint/' + str(args['model']['target']) + '/' + datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
utility.save_args(checkpoint_dir, args)
logger = utility.Tee(checkpoint_dir + '/log.txt', 'a')
runner = engine.Engine(args, checkpoint_dir)
num_epoches = int(args['model']['epochs'])
test_freq = args['model']['test_freq']
for e in range(runner.epoch, num_epoches):
runner.train_pyramid_epoch()
if (e+1) % test_freq == 0:
runner.validate_pyramid_epoch()