Problem with OTBTF Patches Extraction

Hi everyone,

I’m trying to extract patches from a Sentinel-2 image to train the SR4RS network. I’m working in the OTBTF Docker image. However, when I attempt to run the PatchesExtraction function, it stalls at “Loading metadata from the official product.” The function doesn’t terminate, but no further progress occurs. (I waited over 2 hours :D)

Here is the full input and log:

otbcli_PatchesExtraction \
-source1.il Sentinel2/Clip4328.tif \
-source1.patchsizex 8 \
-source1.patchsizey 8 \
-source1.out data_new/lr_patches.tif int16 \
-vec data/centroids.shp \
-field "ID"
2023-09-06 13:53:08 (INFO) PatchesExtraction: Default RAM limit for OTB is 256 MB
2023-09-06 13:53:08 (INFO) PatchesExtraction: GDAL maximum cache size is 797 MB
2023-09-06 13:53:08 (INFO) PatchesExtraction: OTB will use at most 24 threads
2023-09-06 13:53:08 (INFO): Loading metadata from official product

Thanks for helping!

Dear @fherrscher,

Thanks for using OTB!

Could you set the environment variable OTB_LOGGER_LEVEL to DEBUG, and share the result of your command?

Maybe @remi.cresson has encountered this problem with the OTBTF Docker image?

Regards.
Julien :slight_smile:

1 Like

Hi @fherrscher ,

Regarding the overall approach: to generate a dataset for sr4rs, you need 2 sources (1 for the LR, 1 for the HR). To enable 2 sources your must set the OTB_TF_NSOURCES environment variable to 2. Also the patch size is really small, I am a bit skeptical that it could work well with such small size.

Regarding the technical issue, could you enable logging as Julien mentioned and show us the output? Also monitor the CPU/RAM usage.

How many patches centroids do you have in your shp file?

The PatchesExtraction application is great to sparsely extract patches in images, but it could be counterproductive if you want to extract too much patches in images (it will consume too much memory, and the result could be a file larger than the original image). Sometimes it is better to go with your own patches extraction framework, depending on your specific problem.

1 Like

Thank you very much for your help!!

I followed the tutorial from An introduction to deep learning on remote sensing images (Tutorial) – mdl4eo and now it works.
The main difference was that I now normalized the data beforehand, so it worked. Maybe that was the problem…

1 Like