"vscode:/vscode.git/clone" did not exist on "1ebcd6c50af7bc5c41507c60961f9031c729ec8c"
Config.md 11.5 KB
Newer Older
mashun1's avatar
mashun1 committed
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# Configuration

[English](Config.md) **|** [简体中文](BasicSR_docs_CN.md)

#### Contents

1. [Experiment Name Convention](#Experiment-Name-Convention)
1. [Configuration Explanation](#Configuration-Explanation)
    1. [Training Configuration](#Training-Configuration)
    1. [Testing Configuration](#Testing-Configuration)

## Experiment Name Convention

Taking `001_MSRResNet_x4_f64b16_DIV2K_1000k_B16G1_wandb` as an example:

- `001`: We usually use index for managing experiments
- `MSRResNet`: Model name, here is Modified SRResNet
- `x4_f64b16`: Import configuration parameters. It means the upsampling ratio is 4; the channel number of middle features is 64; and it uses 16 residual block
- `DIV2K`: Training data is DIV2K
- `1000k`: Total training iteration is 1000k
- `B16G1`: Batch size is 16; one GPU is used for training
- `wandb`: Use wandb logger; the training process has been uploaded to wandb server

**Note**: If `debug` is in the experiment name, it will enter the debug mode. That is, the program will log and validate more intensively and will not use `tensorboard logger` and `wandb logger`.

## Configuration Explanation

We use yaml files for configuration.

### Training Configuration

Taking [train_MSRResNet_x4.yml](../options/train/SRResNet_SRGAN/train_MSRResNet_x4.yml) as an example:

```yml
####################################
# The following are general settings
####################################
# Experiment name, more details are in [Experiment Name Convention]. If debug in the experiment name, it will enter debug mode
name: 001_MSRResNet_x4_f64b16_DIV2K_1000k_B16G1_wandb
# Model type. Usually the class name defined in the `models` folder
model_type: SRModel
# The scale of the output over the input. In SR, it is the upsampling ratio. If not defined, use 1
scale: 4
# The number of GPUs for training
num_gpu: 1  # set num_gpu: 0 for cpu mode
# Random seed
manual_seed: 0

########################################################
# The following are the dataset and data loader settings
########################################################
datasets:
  # Training dataset settings
  train:
    # Dataset name
    name: DIV2K
    # Dataset type. Usually the class name defined in the `data` folder
    type: PairedImageDataset
    #### The following arguments are flexible and can be obtained in the corresponding doc
    # GT (Ground-Truth) folder path
    dataroot_gt: datasets/DIV2K/DIV2K_train_HR_sub
    # LQ (Low-Quality) folder path
    dataroot_lq: datasets/DIV2K/DIV2K_train_LR_bicubic/X4_sub
    # template for file name. Usually, LQ files have suffix like `_x4`. It is used for file name mismatching
    filename_tmpl: '{}'
    # IO backend, more details are in [docs/DatasetPreparation.md]
    io_backend:
      # directly read from disk
      type: disk

    # Ground-Truth training patch size
    gt_size: 128
    # Whether to use horizontal flip. Here, flip is for horizontal flip
    use_hflip: true
    # Whether to rotate. Here for rotations with every 90 degree
    use_rot: true

    #### The following are data loader settings
    # Number of workers of reading data for each GPU
    num_worker_per_gpu: 6
    # Total training batch size
    batch_size_per_gpu: 16
    # THe ratio of enlarging dataset. For example, it will repeat 100 times for a dataset with 15 images
    # So that after one epoch, it will read 1500 times. It is used for accelerating data loader
    # since it costs too much time at the start of a new epoch
    dataset_enlarge_ratio: 100

  # validation dataset settings
  val:
    # Dataset name
    name: Set5
    # Dataset type. Usually the class name defined in the `data` folder
    type: PairedImageDataset
    #### The following arguments are flexible and can be obtained in the corresponding doc
    # GT (Ground-Truth) folder path
    dataroot_gt: datasets/Set5/GTmod12
    # LQ (Low-Quality) folder path
    dataroot_lq: datasets/Set5/LRbicx4
    # IO backend, more details are in [docs/DatasetPreparation.md]
    io_backend:
      # directly read from disk
      type: disk

##################################################
# The following are the network structure settings
##################################################
# network g settings
network_g:
  # Architecture type. Usually the class name defined in the `basicsr/archs` folder
  type: MSRResNet
  #### The following arguments are flexible and can be obtained in the corresponding doc
  # Channel number of inputs
  num_in_ch: 3
  # Channel number of outputs
  num_out_ch: 3
  # Channel number of middle features
  num_feat: 64
  # block number
  num_block: 16
  # upsampling ratio
  upscale: 4

#########################################################
# The following are path, pretraining and resume settings
#########################################################
path:
  # Path for pretrained models, usually end with pth
  pretrain_network_g: ~
  # Whether to load pretrained models strictly, that is the corresponding parameter names should be the same
  strict_load_g: true
  # Path for resume state. Usually in the `experiments/exp_name/training_states` folder
  # This argument will over-write the `pretrain_network_g`
  resume_state: ~


#####################################
# The following are training settings
#####################################
train:
  # Optimizer settings
  optim_g:
    # Optimizer type
    type: Adam
    #### The following arguments are flexible and can be obtained in the corresponding doc
    # Learning rate
    lr: !!float 2e-4
    weight_decay: 0
    # beta1 and beta2 for the Adam
    betas: [0.9, 0.99]

  # Learning rate scheduler settings
  scheduler:
    # Scheduler type
    type: CosineAnnealingRestartLR
    #### The following arguments are flexible and can be obtained in the corresponding doc
    # Cosine Annealing periods
    periods: [250000, 250000, 250000, 250000]
    # Cosine Annealing restart weights
    restart_weights: [1, 1, 1, 1]
    # Cosine Annealing minimum learning rate
    eta_min: !!float 1e-7

  # Total iterations for training
  total_iter: 1000000
  # Warm up iterations. -1 indicates no warm up
  warmup_iter: -1

  #### The following are loss settings
  # Pixel-wise loss options
  pixel_opt:
    # Loss type. Usually the class name defined in the `basicsr/models/losses` folder
    type: L1Loss
    # Loss weight
    loss_weight: 1.0
    # Loss reduction mode
    reduction: mean


#######################################
# The following are validation settings
#######################################
val:
  # validation frequency. Validate every 5000 iterations
  val_freq: !!float 5e3
  # Whether to save images during validation
  save_img: false

  # Metrics in validation
  metrics:
    # Metric name. It can be arbitrary
    psnr:
      # Metric type. Usually the function name defined in the`basicsr/metrics` folder
      type: calculate_psnr
      #### The following arguments are flexible and can be obtained in the corresponding doc
      # Whether to crop border during validation
      crop_border: 4
      # Whether to convert to Y(CbCr) for validation
      test_y_channel: false

########################################
# The following are the logging settings
########################################
logger:
  # Logger frequency
  print_freq: 100
  # The frequency for saving checkpoints
  save_checkpoint_freq: !!float 5e3
  # Whether to tensorboard logger
  use_tb_logger: true
  # Whether to use wandb logger. Currently, wandb only sync the tensorboard log. So we should also turn on tensorboard when using wandb
  wandb:
    # wandb project name. Default is None, that is not using wandb.
    # Here, we use the basicsr wandb project: https://app.wandb.ai/xintao/basicsr
    project: basicsr
    # If resuming, wandb id could automatically link previous logs
    resume_id: ~

################################################
# The following are distributed training setting
# Only require for slurm training
################################################
dist_params:
  backend: nccl
  port: 29500
```

### Testing Configuration

Taking [test_MSRResNet_x4.yml](../options/test/SRResNet_SRGAN/test_MSRResNet_x4.yml) as an example:

```yml
# Experiment name
name: 001_MSRResNet_x4_f64b16_DIV2K_1000k_B16G1_wandb
# Model type. Usually the class name defined in the `models` folder
model_type: SRModel
# The scale of the output over the input. In SR, it is the upsampling ratio. If not defined, use 1
scale: 4
# The number of GPUs for testing
num_gpu: 1  # set num_gpu: 0 for cpu mode

########################################################
# The following are the dataset and data loader settings
########################################################
datasets:
  # Testing dataset settings. The first testing dataset
  test_1:
    # Dataset name
    name: Set5
    # Dataset type. Usually the class name defined in the `data` folder
    type: PairedImageDataset
    #### The following arguments are flexible and can be obtained in the corresponding doc
    # GT (Ground-Truth) folder path
    dataroot_gt: datasets/Set5/GTmod12
    # LQ (Low-Quality) folder path
    dataroot_lq: datasets/Set5/LRbicx4
    # IO backend, more details are in [docs/DatasetPreparation.md]
    io_backend:
      # directly read from disk
      type: disk
  # Testing dataset settings. The second testing dataset
  test_2:
    name: Set14
    type: PairedImageDataset
    dataroot_gt: datasets/Set14/GTmod12
    dataroot_lq: datasets/Set14/LRbicx4
    io_backend:
      type: disk
  # Testing dataset settings. The third testing dataset
  test_3:
    name: DIV2K100
    type: PairedImageDataset
    dataroot_gt: datasets/DIV2K/DIV2K_valid_HR
    dataroot_lq: datasets/DIV2K/DIV2K_valid_LR_bicubic/X4
    filename_tmpl: '{}x4'
    io_backend:
      type: disk

##################################################
# The following are the network structure settings
##################################################
# network g settings
network_g:
  # Architecture type. Usually the class name defined in the `basicsr/archs` folder
  type: MSRResNet
  #### The following arguments are flexible and can be obtained in the corresponding doc
  # Channel number of inputs
  num_in_ch: 3
  # Channel number of outputs
  num_out_ch: 3
  # Channel number of middle features
  num_feat: 64
  # block number
  num_block: 16
  # upsampling ratio
  upscale: 4
  upscale: 4

#################################################
# The following are path and pretraining settings
#################################################
path:
  ## Path for pretrained models, usually end with pth
  pretrain_network_g: experiments/001_MSRResNet_x4_f64b16_DIV2K_1000k_B16G1_wandb/models/net_g_1000000.pth
  # Whether to load pretrained models strictly, that is the corresponding parameter names should be the same
  strict_load_g: true

##########################################################
# The following are validation settings (Also for testing)
##########################################################
val:
  # Whether to save images during validation
  save_img: true
  # Suffix for saved images. If None, use exp name
  suffix: ~

  # Metrics in validation
  metrics:
    # Metric name. It can be arbitrary
    psnr:
      # Metric type. Usually the function name defined in the`basicsr/metrics` folder
      type: calculate_psnr
      #### The following arguments are flexible and can be obtained in the corresponding doc
      # Whether to crop border during validation
      crop_border: 4
      # Whether to convert to Y(CbCr) for validation
      test_y_channel: false
    # Another metric
    ssim:
      type: calculate_ssim
      crop_border: 4
      test_y_channel: false
```