-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from per-band mean/std normalization of Sentinel-2 values to surface reflectance conversion instead #94
Comments
Another detail after chatting with @lillythomas, we'll also need to apply a bias correction for Sentinel-2 images that were taken after Jan 2022, due to changes in the Line 152 in ee74c91
|
Good article on normalizing EO imagery: https://medium.com/sentinel-hub/how-to-normalize-satellite-images-for-deep-learning-d5b668c885af |
No, we should not use BatchNorm for the Foundation Model layers, since it is doing mean/std normalization! In Super Resolution models such as ESRGAN (Wang et al., 2018) and EDSR (Lim et al., 2017), BatchNorm layers have been removed and replaced with residual skip connections. Quoting from Lim et al., 2017:
The point is though, that we shouldn't be doing any mean/std normalization on the inputs to the first layer of the model, so that the band ratios are preserved. If we want to apply normalization to subsequent layers, that's fine, and for more recent models (from 2020- onwards), it seems like LayerNorm is preferred over BatchNorm (e.g. see ConvNext and https://stats.stackexchange.com/questions/474440/why-do-transformers-use-layer-norm-instead-of-batch-norm). |
I think for v1 and beyond we can use both. The model should see L1, L2 data, and different normalization patterns so that it hopefully generalized better. So I am closing this for now. @weiji14 feel free to keep this open or re-open later if we get back to working on this. |
Using mean and standard deviation normalization is a common procedure in standard Computer Vision, and can be applied e.g. by using
torchvision
's Normalize function. But this normalization can lead to incorrect band ratios when applied to optical remote sensing images.E.g. let's take the formula for Normalized Difference Vegetation Index (NDVI):
If say, we have a un-normalized Sentinel-2 pixel with Band 8 (NIR): 3327, and Band 4 (Red): 426, then the NDVI value would be:
However, if we apply a per-band mean/std normalization scheme, the value becomes:
Clearly this is wrong, since we've removed the NDVI signal! A model trained on these mean/std normalized pixel values would have a harder time capturing the semantics of band indices such as NDVI.
One possible solution, is that instead of applying a per-band normalization, we can convert the Sentinel-2 Digital Number (DN) values to surface reflectance by dividing with the dynamic range of the band to a value between 0-1. Sentinel-2's MSI sensor is 12-bit, but the data is stored as 16-bit. Usually people use 10000, but this doesn't work for very bright white areas, so I'll use$2^{14} = 16384$ below:
which matches with the actual NDVI value.
Notes:
Side note: Using a single mean and standard deviation value for all Sentinel-2 bands won't preserve the band ratios either. E.g. if we use a mean value of 1351 and standard deviation of 1071, and apply it to the NIR/Red bands
The 2.76 result is still not the correct NDVI value of 0.77.
References:
The text was updated successfully, but these errors were encountered: