remicres / otbtf

Deep learning with otb (mirror of https://forgemia.inra.fr/orfeo-toolbox/otbtf)
Apache License 2.0
161 stars 39 forks source link

PatchesExtraction: sampler go through features with empty class field #81

Closed viennois closed 2 years ago

viennois commented 2 years ago

Hi When I run the command otbcli_PatchesExtraction, i have this error message : Sampling patches: 100% [**]2022-05-30 14:05:39 (FATAL) PatchesExtraction: itk::ERROR: Region ImageRegion (0x7fff99fb0650) Dimension: 2 Index: [0, 187216] Size: [16, 16] is outside of buffered region ImageRegion (0x55d38b9f0ef0) Dimension: 2 Index: [0, 0] Size: [16, 187216] Can you help me please ? Thanks Gaëlle

remicres commented 2 years ago

Hi, could you provide the full command line, with gdalinfo output for your input raster(s)? Wich version are you using ?

viennois commented 2 years ago

here, is the command line : otbcli_PatchesExtraction -source1.il mosaicOverLand_8bits_hillshade_nodata.tif -source1.patchsizex 16 -source1.patchsizey 16 -source1.out train_mosafinale17classes02032022_Patcheschgtdate_OL.tif -vec Train_Mosa2018_Hansen_Mask.shp -field "Num_class" -outlabels train_mosafinale17classes02032022_Labelschgtdate_OL.tif uint8

viennois commented 2 years ago

I used otbtf2.5:cpu

remicres commented 2 years ago

~~Could you please paste the output of gdalinfo for mosaicOverLand_8bits_hillshade_nodata.tif ? Thanks~~

remicres commented 2 years ago

I have a possible explanation, but not sure if it is the good one. Forget the gdal_info output.

If you take a look in the otbTensorflowSampler code, you can notice that the number of Geometries is counted, only when the geometry has a field "Num_class". However, when the patches are extracted, all geometries are walked (hence the count could be greater than the geometries with "Num_class" field). This is a design flaw, and it will be corrected in future release. Still, this would imply that there is a missing "Num_class" field in some of the geometries of your "Train_Mosa2018_Hansen_Mask.shp" vector file.

Can you confirm that there are some undefined "Num_class" field for one or multiple geometries? (you can check that in QGIS if you check the attributes table, you should see some NULL value(s) in your "Num_class" field)

viennois commented 2 years ago

Yes, in the "Num_class" field, i have the Null Values So, i will replace this value by one

remicres commented 2 years ago

Fixed in the source code here.

We will draft a new release with docker images soon

viennois commented 2 years ago

thanks

viennois commented 2 years ago

I will wait our new docker images to classify my images

remicres commented 2 years ago

you can use the last docker images available here (we have not published the images on dockerhub for now)