-
Notifications
You must be signed in to change notification settings - Fork 6
/
config.py
211 lines (151 loc) · 5.95 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
from pathlib import Path
import torch
from utils.self_ensemble import ensemble_ops
def base_config():
exp_name = "ours"
# ---------------------------------------------------------------------------- #
# Directories
# ---------------------------------------------------------------------------- #
image_dir = Path("data")
output_dir = Path("outputs") / exp_name
ckpt_dir = Path("ckpts") / exp_name
run_dir = Path("runs") / exp_name
# ---------------------------------------------------------------------------- #
# Data
# ---------------------------------------------------------------------------- #
train_source_dir = image_dir / "Poled_train" / "LQ"
train_target_dir = image_dir / "Poled_train" / "HQ"
val_source_dir = image_dir / "Poled_val" / "LQ"
val_target_dir = image_dir / "Poled_val" / "HQ"
test_source_dir = image_dir / "Poled_test" / "LQ"
static_val_image = "1.png"
static_test_image = "1.png"
image_height = 1024
image_width = 2048
batch_size = 1
num_threads = batch_size # parallel workers
# augment
do_augment = True
# ---------------------------------------------------------------------------- #
# Train Configs
# ---------------------------------------------------------------------------- #
# Schedules
num_epochs = 960
learning_rate = 3e-4
# Betas for AdamW. We follow https://arxiv.org/pdf/1704.00028
beta_1 = 0.9
beta_2 = 0.999
# Cosine annealing
T_0 = 64
T_mult = 2
# saving models
save_filename_G = "model.pth"
save_filename_latest_G = "model_latest.pth"
# save a copy of weights every x epochs
save_copy_every_epochs = 64
# For model ensembling
save_num_snapshots = 8
# the number of iterations (default: 10) to print at
log_interval = 25
# run val or test only every x epochs
val_test_epoch_interval = 10
# ---------------------------------------------------------------------------- #
# Val / Test Configs
# ---------------------------------------------------------------------------- #
# Self ensemble
self_ensemble = False
num_ensemble = len(ensemble_ops) + 1
save_train = False
inference_mode = "latest"
assert inference_mode in ["latest", "best"]
# ---------------------------------------------------------------------------- #
# Model: See models/get_model.py for registry
# ---------------------------------------------------------------------------- #
pixelshuffle_ratio = 2
# Guided map
guided_map_kernel_size = 3
guided_map_channels = 16
# ---------------------------------------------------------------------------- #
# Loss
# ---------------------------------------------------------------------------- #
lambda_image = 1 # l1
lambda_CoBi_RGB = 0.0 # https://arxiv.org/pdf/1905.05169.pdf
cobi_rgb_patch_size = 8
cobi_rgb_stride = 8
resume = True
finetune = False # Wont load loss or epochs
# ---------------------------------------------------------------------------- #
# Distribution Args
# ---------------------------------------------------------------------------- #
# choose cpu or cuda:0 device
device = "cuda:0" if torch.cuda.is_available() else "cpu"
distdataparallel = False
def ours_poled():
exp_name = "ours-poled"
def ours_poled_sim():
exp_name = "ours-poled-sim"
num_epochs = 16 + 32 + 64
log_interval = 25
val_test_epoch_interval = 3
save_copy_every_epochs = 16
# ---------------------------------------------------------------------------- #
# Data
# ---------------------------------------------------------------------------- #
image_dir = Path("data")
train_source_dir = image_dir / "Sim_train" / "POLED"
train_target_dir = image_dir / "Sim_train" / "Glass"
val_source_dir = image_dir / "Sim_val" / "POLED"
val_target_dir = image_dir / "Sim_val" / "Glass"
test_source_dir = None
def ours_poled_PreTr():
exp_name = "ours-poled-PreTr"
def ours_toled():
exp_name = "ours-toled"
# ---------------------------------------------------------------------------- #
# Data
# ---------------------------------------------------------------------------- #
image_dir = Path("data")
train_source_dir = image_dir / "Toled_train" / "LQ"
train_target_dir = image_dir / "Toled_train" / "HQ"
val_source_dir = image_dir / "Toled_val" / "LQ"
val_target_dir = image_dir / "Toled_val" / "HQ"
test_source_dir = image_dir / "Toled_test" / "LQ"
def ours_toled_sim():
exp_name = "ours-toled-sim"
num_epochs = 16 + 32 + 64
log_interval = 25
val_test_epoch_interval = 6
save_copy_every_epochs = 16
# ---------------------------------------------------------------------------- #
# Data
# ---------------------------------------------------------------------------- #
image_dir = Path("data")
train_source_dir = image_dir / "Sim_train" / "TOLED"
train_target_dir = image_dir / "Sim_train" / "Glass"
val_source_dir = image_dir / "Sim_val" / "TOLED"
val_target_dir = image_dir / "Sim_val" / "Glass"
test_source_dir = None
def ours_toled_PreTr():
exp_name = "ours-toled-PreTr"
# ---------------------------------------------------------------------------- #
# Data
# ---------------------------------------------------------------------------- #
image_dir = Path("data")
train_source_dir = image_dir / "Toled_train" / "LQ"
train_target_dir = image_dir / "Toled_train" / "HQ"
val_source_dir = image_dir / "Toled_val" / "LQ"
val_target_dir = image_dir / "Toled_val" / "HQ"
test_source_dir = image_dir / "Toled_test" / "LQ"
named_configs = [
ours_poled,
ours_poled_sim,
ours_poled_PreTr,
ours_toled,
ours_toled_sim,
ours_toled_PreTr,
]
def initialise(ex):
ex.config(base_config)
for named_config in named_configs:
ex.named_config(named_config)
return ex