forked from davidtvs/PyTorch-ENet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
args.py
138 lines (128 loc) · 4.03 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 \"--save_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(
"--model",
choices=['deeplab_resnest50_ade','deeplab_resnest101_ade','deeplab_resnest269_ade','deeplab_resnest200_ade','fcn_resnest50_ade'],
default='deeplab_resnest50_ade',
help="Model Name .Default:deeplab_resnest50_ade")
# 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.5")
parser.add_argument(
"--lr-decay-epochs",
type=int,
default=100,
help="The number of epochs before adjusting the learning rate. "
"Default: 100")
parser.add_argument(
"--weight-decay",
"-wd",
type=float,
default=2e-4,
help="L2 regularization factor. Default: 2e-4")
# 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")
parser.add_argument(
"--height",
type=int,
default=360,
help="The image height. Default: 360")
parser.add_argument(
"--width",
type=int,
default=480,
help="The image width. Default: 480")
parser.add_argument(
"--weighing",
choices=['enet', 'mfb', 'none'],
default='ENet',
help="The class weighing technique to apply to the dataset. "
"Default: enet")
parser.add_argument(
"--with-unlabeled",
dest='ignore_unlabeled',
action='store_false',
help="The unlabeled class is not ignored.")
# Settings
parser.add_argument(
"--workers",
type=int,
default=4,
help="Number of subprocesses to use for data loading. Default: 4")
parser.add_argument(
"--print-step",
action='store_true',
help="Print loss every step")
parser.add_argument(
"--imshow-batch",
action='store_true',
help=("Displays batch images when loading the dataset and making "
"predictions."))
parser.add_argument(
"--device",
default='cuda',
help="Device on which the network will be trained. Default: cuda")
# Storage settings
parser.add_argument(
"--name",
type=str,
default='ENet',
help="Name given to the model when saving. Default: ENet")
parser.add_argument(
"--num-epochs",
type=int,
default=10,
help="No. of epochs after which model is saved Default: 10")
parser.add_argument(
"--save-dir",
type=str,
default='save',
help="The directory where models are saved. Default: save")
return parser.parse_args()