-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.py
75 lines (69 loc) · 3.1 KB
/
config.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import argparse
def str2bool(v):
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.')
def parse_args():
parser = argparse.ArgumentParser(
description='Main argument parser')
parser.add_argument("--use_cuda", type=str2bool,
nargs='?', default=True,
help="GPU flag.")
parser.add_argument('--model_input_size',
help='Input resolution to feed to network',
type=int,
default=448)
parser.add_argument('--batch_size',
help='Batch size for training',
type=int,
default=32)
parser.add_argument('--num_epochs',
help='Number of training training',
type=int,
default=120)
parser.add_argument('--arch',
help='Network architecture',
type=str,
default='resnet50')
parser.add_argument('--optim',
help='Optimizer',
type=str,
default='sgd')
parser.add_argument('--lr',
help='Learning rate',
type=float,
default=1e-2)
parser.add_argument('--train_percentage',
help='Training set percentage, val set will not be used if set to 1',
type=float,
default=1)
parser.add_argument("--train", type=str2bool,
nargs='?', default=True,
help="Training flag.")
parser.add_argument("--use_extraimages", type=str2bool,
nargs='?', default=False,
help="Use labeled extra images in train set if true. "
"P.S. extra images should be labeled beforehand.")
parser.add_argument("--validate", type=str2bool,
nargs='?', default=False,
help="Validation flag.")
parser.add_argument("--test", type=str2bool,
nargs='?', default=True,
help="Test flag.")
# parser.add_argument("--subset_finetune", type=str2bool,
# nargs='?', default=False,
# help="Balanced subset finetuning flag.")
parser.add_argument("--use_weighted_loss", type=str2bool,
nargs='?', default=False,
help="Use class weights in loss function against imbalanced data if true.")
parser.add_argument("--tencrop_test", type=str2bool,
nargs='?', default=False,
help="Tencrop testing mode flag.")
parser.add_argument("--resume_path", type=str,
default='',
help="Resume training from checkpoint.")
args = parser.parse_args()
return args