Skip to content

Commit 3d17b3b

Browse files
author
Remi Cresson
committed
DOC: add help to select the trainig parameters values
1 parent 25cd163 commit 3d17b3b

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

doc/HOW_TO.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Karnewar et Al. (multi scale gradient)
3636
}
3737
```
3838

39-
4039
## How to install
4140

4241
Use the [OTBTF Docker image](https://github.com/remicres/otbtf#how-to-install) with version >= 2.0.
@@ -73,6 +72,8 @@ The LR and HR images have the same number of bands, ordered in the same followin
7372

7473
### Step 2: train your network
7574

75+
![](train.png)
76+
7677
Use `train.py` to train a super-resolution network and export the SavedModel.
7778
**A (known bug)[https://github.com/remicres/sr4rs/issues/36] affects the training when `--streaming` is not used, for OTBTF versions < 2.5. Use `--streaming` in this case!**
7879
Well, here you might want to play with the parameters. The result will depend likely on your images!
@@ -114,13 +115,24 @@ python train.py \
114115
--lr_scale 0.0001 --hr_scale 0.0001 \
115116
--savedmodel /path/to/savedmodel
116117
```
117-
This gave me some cool results, but you might find some settings better suited to your images.
118+
These settings helped to generate good looking images from our Sentinel-2 products.
119+
Since this is quite subjective, other settings might be better suited, depending on your images.
118120
The important thing is, after the training is complete, the SavedModel will be generated in `/path/to/savedmodel`.
119121
Take care not to use an existing folder for `--savedmodel`, else TensorFlow will cancel the save. You must provide a non-existing folder for this one.
120122
Note that you can provide multiple HR and LR patches: just be sure that there is the same number of patches images, in the same order. Use the `--streaming` option if this takes too much RAM.
121123

124+
#### How to chose the training parameters?
125+
126+
Here are a few rules of thumb to follow:
127+
- use `lr_scale` and `hr_scale` so that the images pixels values range is generally in the [0, 1] interval,
128+
- use small `depth` and `nresblocks` to train a small model: this would be useful if you have small dataset, or low GPU memory budget.
129+
- Play with `batchsize` and `adam_lr` to train your model. The outcome mostly depends on the distribution of your data. Generally, a small batch size helps (4, 8, 16) and a learning rate in the 10e-2 and 10e-5 range.
130+
- `l1weight`, `l2weight`, `vggweight`: tune these parameters so that their contribution is in the same magnitude as the GAN loss.
131+
122132
### Step 3: generate your fake HR images
123133

134+
![](inference.png)
135+
124136
Now we use OTBTF `TensorFlowModelServe` application through `sr.py`.
125137
We just apply our SavedModel to a LR image, and transform it in a fake HR image.
126138
```
@@ -131,6 +143,8 @@ python sr.py \
131143
```
132144

133145
#### Useful parameters
146+
134147
- Depending on your hardware, you can set the memory footprint using the parameter `--ts` (as **t**ile **s**ize). Use large tile size to speed-up the process. If the tile size is too large, TensorFlow will likely throw an OOM (out of memory) exception. **Note the the default value (512) is quite small, and you will like to manually change that value to gain a great speed-up** for instance on an old GTX1080Ti (12Gb RAM) you can use 1024.
135148
- Change the output image encoding using the `--encoding` parameter. e.g for Sentinel-2 images you can use `--encoding int16`.
136149
- The image generation process avoids blocking artifacts in the generated output image. Use the `--pad` parameter to change the margin used to keep the pseudo-valid region, in spatial dimensions, of the output tensor.
150+

doc/inference.png

68.2 KB
Loading

doc/train.png

74.4 KB
Loading

0 commit comments

Comments
 (0)