argument.py 10 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
import argparse


def parse():
    '''
    Add arguments.
    '''
    parser = argparse.ArgumentParser(
        description='DnCNN')

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
    #                   #name for user          #name for program       #type       #default values                                         #explanation sentences
    parser.add_argument('--input_dir',          dest='input_dir',       type=str,   default='./PyTorchCheckpoint/',                         help='directory of saved checkpoints for denoising operation or retraining')

    parser.add_argument('--train_dir',          dest='train_dir',       type=str,   default='./Holography/DATABASE/',                       help='directory of training database')
    parser.add_argument('--eval_dir',           dest='eval_dir',        type=str,   default='./Holography/DATABASE/',                       help='directory of training database')
    parser.add_argument('--test_dir',           dest='test_dir',        type=str,   default='./Holography/DATAEVAL/DATAEVAL/',              help='directory of testing database')
    parser.add_argument('--save_test_dir',      dest='save_test_dir',   type=str,   default='./TestImages/',                                help='directory where results of de-noising operation will be saved')


    parser.add_argument('--train_patterns',     dest='train_patterns',  type=int,   nargs='+', default=(1, 2, 3, 4, 5),                     help='patterns used for training')
    parser.add_argument('--train_noises',       dest='train_noises',    type=str,   default="0-1-1.5-2-2.5",                                help='noise levels used for training ')

    parser.add_argument('--eval_patterns',      dest='eval_patterns',   type=int,   nargs='+', default=(1, 2, 3, 4, 5),                     help='patterns used for eval')
    parser.add_argument('--eval_noises',        dest='eval_noises',     type=str,   default="0-1-1.5-2-2.5",                                help='noise levels used for eval ')

    parser.add_argument('--test_patterns',      dest='test_patterns',   type=int,   nargs='+', default=(1, 2, 3, 4, 5),                     help='patterns used for testing')
    parser.add_argument('--test_noises',        dest='test_noises',     type=str,   default="0-1-1.5-2-2.5",                                help='noise levels used for testing ')

    parser.add_argument('--clean_train',        dest='clean_train',     type=str,   default='data1/img_clean_train_1-2-3-4-5_0-1-1.5-2-2.5_two_50_50_384.npy',   help='filepath of noise free file for training')
    parser.add_argument('--noisy_train',        dest='noisy_train',     type=str,   default='data1/img_noisy_train_1-2-3-4-5_0-1-1.5-2-2.5_two_50_50_384.npy',   help='filepath of noisy file for training')
    
    parser.add_argument('--clean_eval',         dest='clean_eval',      type=str,   default='data1/img_clean_train_1-2-3_0-1-1.5two.npy',   help='filepath of noise free file for eval')
    parser.add_argument('--noisy_eval',         dest='noisy_eval',      type=str,   default='data1/img_noisy_train_1-2-3_0-1-1.5two.npy',   help='filepath of noisy file for eval')
    
    parser.add_argument('--num_epochs',         dest='num_epochs',      type=int,   default=200,                                            help='number of epochs to train')
    parser.add_argument('--D',                  dest='D',               type=int,   default=4,                                              help='number of dilated convolutional layer (resBlock)')
    parser.add_argument('--C',                  dest='C',               type=int,   default=64,                                             help='kernel size of convolutional layer')
    
    parser.add_argument('--plot',               dest='plot',            action='store_true',                                                help='plot loss during training')
    parser.add_argument('--lr',                 dest='lr',              type=float, default=1e-3,                                           help='learning rate for training')
41
    
42
43
44
45
46
47
48
49
50
    parser.add_argument('--train_image_size',   dest='train_image_size',type=int,   nargs='+', default=(50, 50),                            help='size of train images')
    parser.add_argument('--eval_image_size',    dest='eval_image_size', type=int,   nargs='+', default=(1024, 1024),                        help='size of eval images')
    parser.add_argument('--test_image_size',    dest='test_image_size', type=int,   nargs='+', default=(1024, 1024),                        help='size of test images')
 
    parser.add_argument('--image_mode',         dest='image_mode',      type=int,   default=1,                                              help='1 or 3 (black&white or RGB)')
  
    parser.add_argument('--batch_size',         dest='batch_size',      type=int,   default=384,                                            help="")
    parser.add_argument('--epoch',              dest='epoch',           type=int,   default=None,                                           help='epoch\'s number from which we going to retrain')
    parser.add_argument('--test_mode',          dest='test_mode',       action='store_true',                                                help='testing phase')
51
    
52
53
54
    parser.add_argument('--tsf',                dest='tsf',             action='store_true',                                                help='add if code in tensorflow')
    parser.add_argument('--graph',              dest='graph',           action='store_true',                                                help='add if graph is visible')
    parser.add_argument('--graph_fin',          dest='graph_fin',       action='store_true',                                                help='add if graph is visible during training')
55
    
56
57
58
59
60
    # Tensorflow arguments
    
    parser.add_argument('--use_gpu',            dest='use_gpu',         type=int,   default=1,                                              help='gpu flag, 1 for GPU and 0 for CPU')
    parser.add_argument('--checkpoint_dir',     dest='ckpt_dir',        type=str,   default='./checkpoint',                                 help='models are saved here')
    parser.add_argument('--sample_dir',         dest='sample_dir',      type=str,   default='./sample',                                     help='sample are saved here')
61
    
62
    #parser.add_argument('--test_dir', dest='test_dir', default='./test', help='test sample are saved here')
63
    
64
    parser.add_argument('--params',             dest='params',          type=str,   default='',                                             help='hyper parameters')
65

66
67
68
69
70
71
72
73
    parser.add_argument('--test_noisy_img',     dest='noisy_img',       type=str,                                                           help='path of the noisy image for testing')
    parser.add_argument('--test_noisy_key',     dest='noisy_key',       type=str,                                                           help='key for noisy matlab image for testing')
    parser.add_argument('--test_clean_img',     dest='clean_img',       type=str,                                                           help='path of the clean image for testing')
    parser.add_argument('--test_clean_key',     dest='clean_key',       type=str,                                                           help='key for clean matlab image for testing')
    
    parser.add_argument('--test_flip',          dest='flip',            type=bool,  default=False,                                          help='option for upside down flip of noisy (and clean) test image')
    
    #parser.add_argument('--test_ckpt_index', dest='ckpt_index', type=str, default='', help='name and directory of the checkpoint that will be restored.')
74

75
76
    parser.add_argument('--save_dir',           dest='save_dir',        type=str, default='./data1/',                                       help='dir of patches')
    parser.add_argument('--exp_file',           dest='exp_file',        type=str,                                                           help='experiment file')
77

78
    parser.add_argument('--nb_iteration',       dest='nb_iteration',    type=int, default=3,                                                help='number of iteration for de-noising operation')
Touklakos's avatar
Touklakos committed
79
    parser.add_argument('--nb_rotation',        dest='nb_rotation',     type=int, default=8,                                                help='number of ration for data augmentation')
80

81
82
83
84
85

    parser.add_argument('--isDebug', dest='isDebug', action='store_true')
    parser.add_argument('--patch_size', dest='patch_size', default=50)
    parser.add_argument('--stride', dest='stride', default=50)
    parser.add_argument('--step', dest='step', default=0)
Touklakos's avatar
Touklakos committed
86
    parser.add_argument('--freq_save', dest='freq_save', type=int, default=1)
87
88
89
90
91
92
93
94
95
96
    parser.add_argument('--phase_type', dest='phase_type', default="two")
    parser.add_argument('--patch_per_image', dest='patch_per_image', default=384)
    parser.add_argument('--noise_src_dir', dest='noise_src_dir', default="./chemin/")
    parser.add_argument('--clean_src_dir', dest='clean_src_dir', default="./chemin/")
    
    parser.add_argument('--perform_validation', dest='perform_validation', action="store_true")
    
    parser.add_argument('--scales',    dest='scales', type=int,   nargs='+', default=[1],                        help='size of test images')
    parser.add_argument('--originalsize',    dest='originalsize', type=int,   nargs='+', default=(1024, 1024),                        help='size of test images')
    
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
    return parser.parse_args()


class Args():
    '''
    For jupyter notebook
    Not up to date
    '''

    def __init__(self):
        self.root_dir = '../dataset/BSDS300/images'
        self.output_dir = '../checkpoints/'
        self.noisy = 'data1/img_noisy_train_1-2-3-4-5_0_two_50_50_9.npy'
        self.clean = 'data1/img_clean_train_1-2-3-4-5_0_two_50_50_9.npy'
        self.num_epochs = 200
        self.D = 4
        self.C = 64
        self.plot = False
        self.model = 'dudncnn'
        self.lr = 1e-3
        self.image_size = (180, 180)
        self.test_image_size = (320, 320)
        self.batch_size = 60
        self.sigma = 30
        self.is_training = False
        self.image_mode = 1
        self.graph = False