-
Notifications
You must be signed in to change notification settings - Fork 13
/
args.py
138 lines (130 loc) · 3.5 KB
/
args.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
from argparse import ArgumentParser
def get_arguments():
"""Defines command-line arguments, and parses them."""
parser = ArgumentParser()
# Execution mode
parser.add_argument(
"--mode",
"-m",
choices=['train', 'test', 'full'],
default='train',
help=(
"train: performs training and validation; test: tests the model "
"found in \"--checkpoint-dir\" with name \"--name\" on \"--dataset\"; "
"full: combines train and test modes. Default: train"
)
)
parser.add_argument(
"--resume",
action='store_true',
help=(
"The model found in \"--checkpoint-dir/--name/\" and filename "
"\"--name.h5\" is loaded."
)
)
parser.add_argument(
"--initial-epoch",
type=int,
default=0,
help="Epoch at which to start training. Default: 0"
)
parser.add_argument(
"--no-pretrained-encoder",
dest='pretrained_encoder',
action='store_false',
help=(
"Pretrained encoder weights are not loaded."
)
)
parser.add_argument(
"--weights-path",
type=str,
default="./checkpoints/linknet_encoder_weights.h5",
help=(
"HDF5 file where the weights are stored. This setting is ignored "
"if \"--no-pretrained-encoder\" is set. Default: "
"/checkpoints/linknet_encoder_weights.h5"
)
)
# Hyperparameters
parser.add_argument(
"--batch-size",
"-b",
type=int,
default=10,
help="The batch size. Default: 10"
)
parser.add_argument(
"--epochs",
type=int,
default=300,
help="Number of training epochs. Default: 300"
)
parser.add_argument(
"--learning-rate",
"-lr",
type=float,
default=5e-4,
help="The learning rate. Default: 5e-4"
)
parser.add_argument(
"--lr-decay",
type=float,
default=0.1,
help="The learning rate decay factor. Default: 0.1"
)
parser.add_argument(
"--lr-decay-epochs",
type=int,
default=100,
help=(
"The number of epochs before adjusting the learning rate. "
"Default: 100"
)
)
# Dataset
parser.add_argument(
"--dataset",
choices=['camvid', 'cityscapes'],
default='camvid',
help="Dataset to use. Default: camvid"
)
parser.add_argument(
"--dataset-dir",
type=str,
default="data/CamVid",
help=(
"Path to the root directory of the selected dataset. "
"Default: data/CamVid"
)
)
# Settings
parser.add_argument(
"--workers",
type=int,
default=4,
help="Number of subprocesses to use for data loading. Default: 4"
)
parser.add_argument(
"--verbose",
choices=[0, 1, 2],
default=1,
help=(
"Verbosity mode: 0 - silent, 1 - progress bar, 2 - one line per "
"epoch. Default: 1"
)
)
# Storage settings
parser.add_argument(
"--name",
type=str,
default='LinkNet',
help="Name given to the model when saving. Default: LinkNet"
)
parser.add_argument(
"--checkpoint-dir",
type=str,
default='checkpoints',
help="The directory where models are saved. Default: checkpoints"
)
return parser.parse_args()