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

Noise on my semantic segmentation #98

Open aleguillou1 opened 7 months ago

aleguillou1 commented 7 months ago

Hello,

I've tried to make a segmentation using the same method as the book "Deep Learning for Remote sensing images with open source software". I tried a first time with the example in the book and it worked well. So I tried using my own data to perform a segmentation of buildings and roads (in a single class) but this time on a Pleiades image. I managed to train the model (using the same one as in the book: create_model4.py as I recall).

After successfully training the model on 64x64 patches, I was able to carry out the inference in the same way as in the book, but the result was rough. I'd already had this result with multi-class segmentation but I thought it was me who'd done something wrong. But as it still happens, even with binary segmentation, I'm thinking there's a problem, maybe it's the Pleiades sensor, or my training data? Or The result is normal for pléiades and maybe i need to try a better U-net Architecture ?

Here's the rough result: Result My Pleiades image: Image My labels : labels And my point for Patch_Exctraction : poitn_entrainement For information, I've extracted around 6000 training patches to the scale of the image and a further 3000 for validation in 64x64, the image is a 3-channel image.

Thank you in advance and have a nice day,
Adrien

remicres commented 7 months ago

Hello @aleguillou1 ,

The problem may come from:

Also, I would like to point you toward a more modern way to train your models. The book is a bit outdated now and TensorFlow / Keras have considerably evolved. There is also pyotb to the rescue to play with OTB apps. Here is a lightweight tutorial showing how to do the semantic segmention like in the book, but with today's librairies versions. Also, you can take a look in the otbtf doc hosted on readthedocs that explains a lot of thing.

aleguillou1 commented 7 months ago

Hello Rémi,

Thank you for your prompt reply. To answer point by point:

import otbApplication app = otbApplication.Registry.CreateApplication("PatchesExtraction") app.SetParameterStringList("source1.il", ["/home/Thèse_SSD/Unet_RS/Image/Image.tif"]) app.SetParameterInt("source1.patchsizex", 64) app.SetParameterInt("source1.patchsizey", 64) app.SetParameterString("source1.out", "/home/Thèse_SSD/Unet_RS/OTBTF_Unet/Patch/Patch_Image_val.tif") app.SetParameterString("vec", "/home/Thèse_SSD/Unet_RS/OTBTF_Unet/train/val.shp") app.SetParameterString("field", "code") app.SetParameterStringList("source2.il" , ["/home/Thèse_SSD/Unet_RS/Image/label.tif"]) app.SetParameterInt("source2.patchsizex", 64) app.SetParameterInt("source2.patchsizey", 64) app.SetParameterString("source2.out" , "/home/Thèse_SSD/Unet_RS/OTBTF_Unet/Patch/Patch_Label_val.tif" ) app.SetParameterString("outlabels", "/home/Thèse_SSD/Test_Unet/Test_2/Patch2/asuppr.tif") app.ExecuteAndWriteOutput()

for example val.shp are the validation points.

Thanks for the Pyotb tip, I've never tried it, but I will in the future.

Best regards, Adrien

remicres commented 5 months ago

Hello @aleguillou1 ,

Here is a full tutorial that covers the modern way to build/train/evaluate deep nets with keras/otbtf and apply them on images with otbtf: https://orfeo-toolbox.pages.mia.inra.fr/otbtf-keras-tutorial/

In case that can help (I really recommend you to switch to keras and the new otbtf python API)

aleguillou1 commented 5 months ago

Hi Remi,

I'm sorry, I've never relaunched on this git, but I managed to launch a semantic segmentation using pyotb without any problem. It didn't allow me to understand the original problem on my method but at least with the pyotb method everything works fine and is even more practical , thank you very much !

Thank you for the link by the way !

Adrien