forked from jiangsutx/SRN-Deblur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_model.py
50 lines (42 loc) · 2.08 KB
/
run_model.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
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import argparse
import tensorflow as tf
# import models.model_gray as model
# import models.model_color as model
import models.model as model
def parse_args():
parser = argparse.ArgumentParser(description='deblur arguments')
parser.add_argument('--phase', type=str, default='test', help='determine whether train or test')
parser.add_argument('--datalist', type=str, default='./datalist_gopro.txt', help='training datalist')
parser.add_argument('--model', type=str, default='color', help='model type: [lstm | gray | color]')
parser.add_argument('--batch_size', help='training batch size', type=int, default=16)
parser.add_argument('--epoch', help='training epoch number', type=int, default=4000)
parser.add_argument('--lr', type=float, default=1e-4, dest='learning_rate', help='initial learning rate')
parser.add_argument('--gpu', dest='gpu_id', type=str, default='0', help='use gpu or cpu')
parser.add_argument('--height', type=int, default=720,
help='height for the tensorflow placeholder, should be multiples of 16')
parser.add_argument('--width', type=int, default=1280,
help='width for the tensorflow placeholder, should be multiple of 16 for 3 scales')
parser.add_argument('--input_path', type=str, default='./testing_set',
help='input path for testing images')
parser.add_argument('--output_path', type=str, default='./testing_res',
help='output path for testing images')
args = parser.parse_args()
return args
def main(_):
args = parse_args()
# set gpu/cpu mode
if int(args.gpu_id) >= 0:
os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu_id
else:
os.environ['CUDA_VISIBLE_DEVICES'] = ''
# set up deblur models
deblur = model.DEBLUR(args)
if args.phase == 'test':
deblur.test(args.height, args.width, args.input_path, args.output_path)
elif args.phase == 'train':
deblur.train()
else:
print('phase should be set to either test or train')
if __name__ == '__main__':
tf.app.run()