Skip to content
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

Error to run Magiori FCN #20

Closed
resnow92 opened this issue Apr 30, 2020 · 17 comments
Closed

Error to run Magiori FCN #20

resnow92 opened this issue Apr 30, 2020 · 17 comments
Labels
enhancement New feature or request good first issue Good for newcomers question Further information is requested

Comments

@resnow92
Copy link

Hi,
I tried to run the create_savedmodel_maggiori17_fullyconv.py to train a model with my 15 bands images but I obtained this error:
Capture

I specified the number of channels (15). I tried with the create_savedmodel_simple_fcn.py and all is running well.

Thanks for your help.

@remicres
Copy link
Owner

remicres commented May 7, 2020

There was an error in the documentation: wrong patches sizes during training step (I just corrected it in 3daef29).
You must change the patches sizes for input and output, because the Maggiori model inputs patches of size 80x80 and produce output labels of size 16x16. To generate the two sets of patches, you can use the PatchExtraction application with OTB_TF_NSOURCES=2

@resnow92
Copy link
Author

Thanks for your answer.
Why i have to use OTB_TF_NSOURCES=2 ?
Sorry if i don't understand, why we have to generate 2 set of patchs ? you mean the label data have to be 16*16 ?
Last question, can we use this script for 3 classes classifications ? or is it for binary classification only ?
Thanks for your time, I have a too small background in deep learning and I don't understand well how to change parameters and data format to be read by tensorflow.

@remicres
Copy link
Owner

Setting OTB_TF_NSOURCES=2 enables to extract the two set of patches in one time. If one patch lies outside the image, it is rejected from the sampling, and that guarantee that patches are sampled simultaneously for all sources. If you don't set OTB_TF_NSOURCES, it's harder to guarantee that you have the same patches. Suppose you have 2 images to sample simultaneously, like one label image and one remote sensing image: if your images have not exactly the same extend, some patches may fall outside one image but not the other, and this would lead to a unpaired dataset. Since 5704527, PatchesExtraction also allows to set a no-data value for each source: with that you can reject every set of patches that contains some undesired data in at least one source.

@remicres remicres added good first issue Good for newcomers question Further information is requested labels May 14, 2020
@resnow92
Copy link
Author

Ok thanks I think I understood, I have nice results with create_savedmodel_simple_fcn.py but i wanted to try this one.

@resnow92
Copy link
Author

resnow92 commented May 14, 2020

Sorry, I tried what you said, so I generate patch extraction with NSOURCES=2. As a result I have as you mentioned, 2 set of patchs:

  • 80x80 satellite patchs
  • 16x16 satellite patchs
    And I have one label file. Labels are 1 pixel in width.

So my question is, which file to use in the ModelTrain function for the training.source2.il parameter ? As my label are not 16x16 but 1 pixel width.
Or I made something wrong with the patch extraction ?
thanks

@remicres
Copy link
Owner

I admit that this outlabel parameter is confusing. Actually, the outlabel creates a 1x1 patch image that contains the field value of the input vector data (field name is set with the field parameter). It is convenient for patch-based classification (when your model outputs a single value for a given input patch, and when the class is stored in a vector data field). But as soon as you want to do something else using rasters (e.g. semantic segmentation, image-to-image translation, ...) and that you have output patches as reference (e.g. 16x16), the outlabel is not used anymore.

In your case, you just have to use the 80x80 (for input) and the 16x16 (for labels) patches. Just throw away the 1x1 patches, not used at all by the Maggiori model. By the way, I think that outlabel is not mandatory parameter, but you still have to provide the field parameter: not very logic if outlabel is not used, I conceed!

There is a little room for improvement in PatchesExtraction. In the future major release of otbtf, In next release, it could be great to improve this app parameters.

@remicres remicres added this to the Refactor PatchesExtraction parameters: use of outlabels is confusing when working on something different than single-valued patch-based classification/regression problems milestone May 14, 2020
@remicres remicres added the enhancement New feature or request label May 14, 2020
@resnow92
Copy link
Author

Hum OK, many thanks for this very helpful precision ! I think I have all elements I need. Indeed, it was not clear for me, but as I said I am not an expert :)

@resnow92
Copy link
Author

I have an error, don't know why, here is the log.
I will explore this issue tomorrow.
image

@remicres
Copy link
Owner

There is a typo in your command line: replace is.training=true with is_training=true

@resnow92
Copy link
Author

resnow92 commented May 15, 2020

new error concerning shapes of input images ?
image

My patchs 16x16 have 94 672 pixels height and patchs 80x80 have 473 360 pixels height

@remicres
Copy link
Owner

I don't know. How many channels have your images? Do you have modified the model? If yes, can you copy/paste it on pastebin or something like that

@resnow92
Copy link
Author

I have 15 channels and I put the option -- n_channels 15 when I ran the python script. I didn't change the model.

@remicres
Copy link
Owner

The maggiori model is used for binary semantic segmentation. You must provide to y some binary labels (i.e. 0 or 1 pixels). The paper: https://hal.inria.fr/hal-01350706/document

@resnow92
Copy link
Author

Ah, i think is the thing i missed ! I don't have binary raster label, only label from shapefile.

@remicres
Copy link
Owner

You can use the OTB application Rasterization to rasterize your vector over your image (otbcli_Rasterization -im yourimage.tif -vec yourvector.shp ... -out outputlabelimage.tif)

@resnow92
Copy link
Author

Nice, thanks ! I will try this :)

@remicres remicres removed this from the Refactor PatchesExtraction parameters: use of outlabels is confusing when working on something different than single-valued patch-based classification/regression problems milestone Nov 24, 2020
@remicres
Copy link
Owner

to be continued in #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants