remicres / otbtf

Deep learning with otb (mirror of https://forgemia.inra.fr/remi.cresson/otbtf)
Apache License 2.0
159 stars 39 forks source link

Error TensorflowModelTrain with path of dimension 48 instead of 16 #88

Open viennois opened 1 year ago

viennois commented 1 year ago

HI, I extract patches of dimension 48 instead of 16 Here, my line of code : "otbcli_PatchesExtraction -source1.il Mosa_8B_Projet_Pheno_24022022_hillshade.tif -source1.patchsizex 48 -source1.patchsizey 48 -source1.out train_mosafinale17classes_Patches48.tif -vec Training_17classes02032022.shp -field "Num_class" -outlabels train_mosafinale17classes_Labels48.tif uint8".

And when I run otbcli_TensorflowModelTrain \ with -training.source1.patchsizex 48 \ -training.source1.patchsizey 48 \ I have this error message :

"wModelTrain: itk::ERROR: TensorflowMultisourceModelTrain(0x564fdea48c70): Can't run the tensorflow session ! Tensorflow error message: Invalid argument: logits and labels must have the same first dimension, got logits shape [8100,18] and labels shape [100] [[{{node sparse_softmax_cross_entropy_loss/xentropy/xentropy}}]] OTB Filter debug message: Output image buffered region: ImageRegion (0x7ffe967afb80) Dimension: 2 Index: [0, 0] Size: [1, 1]

Input #0: Requested region: ImageRegion (0x7ffe967afbb0) Dimension: 2 Index: [0, 0] Size: [48, 4270176]

Tensor shape ("x": {100, 48, 48, 11} Input #1: Requested region: ImageRegion (0x7ffe967afbb0) Dimension: 2 Index: [0, 0] Size: [1, 88962]

Tensor shape ("y": {100, 1, 1, 1}

So my question : Do I have any parameters to modify in the python script?

Thanks for your help

remicres commented 1 year ago

Hi @viennois This message comes from tensorflow. It says that the number of labels is wrong. Here I see 8100 values (instead of 100) which is 81 times greater than it should. Maybe you have 9x9 labels outputs, instead of 1x1. You have either to shrink this output or add convolutions to match 1x1

viennois commented 1 year ago

I have 18 classes and i try to use patches of 48*48. I 'm just user of our application and I don't know how to use tensorflow How shrink the output or add convolutions to match 1x1? Thanks for your help