You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/HOW_TO.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,6 @@ Karnewar et Al. (multi scale gradient)
36
36
}
37
37
```
38
38
39
-
40
39
## How to install
41
40
42
41
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
73
72
74
73
### Step 2: train your network
75
74
75
+

76
+
76
77
Use `train.py` to train a super-resolution network and export the SavedModel.
77
78
**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!**
78
79
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 \
114
115
--lr_scale 0.0001 --hr_scale 0.0001 \
115
116
--savedmodel /path/to/savedmodel
116
117
```
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.
118
120
The important thing is, after the training is complete, the SavedModel will be generated in `/path/to/savedmodel`.
119
121
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.
120
122
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.
121
123
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
+
122
132
### Step 3: generate your fake HR images
123
133
134
+

135
+
124
136
Now we use OTBTF `TensorFlowModelServe` application through `sr.py`.
125
137
We just apply our SavedModel to a LR image, and transform it in a fake HR image.
126
138
```
@@ -131,6 +143,8 @@ python sr.py \
131
143
```
132
144
133
145
#### Useful parameters
146
+
134
147
- 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.
135
148
- Change the output image encoding using the `--encoding` parameter. e.g for Sentinel-2 images you can use `--encoding int16`.
136
149
- 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.
0 commit comments