AWF-GAUG / TreeCrownDelineation

Individual tree crown delineation in optical remote sensing images
MIT License
81 stars 18 forks source link

Found 0 polygon with 7 band pretrained model #14

Open Kadircanidrisoglu opened 1 month ago

Kadircanidrisoglu commented 1 month ago

Hi, first of all thanks for comprehensive documented project. I have B,G,R,I bands on my WV3 data therefore I just stacked some same bands for building 7 band data to use 7 band pre trained model. My processed data looks like this; B1 Blue B2 Green B3 yellow=(Red+ Green )/ 2 B4 Red B5 NIR B6 NIR B7 NIR

But when I make prediction on this data via inference.py with this casual parameters; --red 3 --nir 6 --ndvi --min-dist 10 --sigma 2 -l 0.4 -b 0.05 -s 0.21 --div 2000 --rescale-ndvi --sigmoid -d cpu, I did not get an error but found 0 polygon. So it means my stacking process does not work or I missed some theoretical thing? Thanks..

maxfreu commented 1 month ago

Hi! Did you finetune the model after your stacking process? If not, it can easily happen that you get no output. You could also take another way: Copy the weights for BGR NIR from the first conv layer of the pretrained model to a copy of the model with only 4 input channels.

Apart from that you can check the intermediate network output using the --save-prediction argument to the inference script. That should output a three channel image containing the predictions for tree cover mask, outlines and distance transform. The polygon extraction will work with that data, so if you spot errors there, the extraction won't work.

Kadircanidrisoglu commented 3 weeks ago

What is the exact order of the bands in the 7 band model? I saw red=3, nir=4 in the training_bengalaru.py script, but there is a different order of the bands on the WV-3 website. Also, interestingly, when I predict my WV-3 input data, which has BGR NIR bands, directly with the 4-band model, I get better results than when I convert the place of the bands in this input data to RGB NIR and predict. Is there a reason why I get better results with the BGR NIR input since the 4-band model is trained with RGB NIR?

maxfreu commented 3 weeks ago

There is a readme in each file that should explain these things. The WV3 model has the first (coastal) band removed and the NDVI attached at the end, so index 0 is blue, then green, and so on to NIR, as the original data, then the last band is the NDVI rescaled to 0..1. The model trained on aerial images has the band ordering RGBI-NDVI with the NDVI again rescaled to 0..1. I have no explanation why you receive better results with BGRI-NDVI when using the aerial model.

maxfreu commented 3 weeks ago

Oh and for computing the NDVI I used the red edge channel, so the one right after red. That's what I'm referring to by NIR. So the command in your first post would have to use --nir 4.

Kadircanidrisoglu commented 3 weeks ago

So, ndvi=(red_edge - red)/(red_edge + red) you used this formula for 7 band model right?

maxfreu commented 3 weeks ago

Yes, as well as for the 4 band model.