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

Found 0 polygon with 7 band pretrained model #14

Open
Kadircanidrisoglu opened this issue Aug 10, 2024 · 6 comments
Open

Found 0 polygon with 7 band pretrained model #14

Kadircanidrisoglu opened this issue Aug 10, 2024 · 6 comments

Comments

@Kadircanidrisoglu
Copy link

Kadircanidrisoglu commented Aug 10, 2024

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
Copy link
Contributor

maxfreu commented Aug 12, 2024

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
Copy link
Author

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
Copy link
Contributor

maxfreu commented Aug 19, 2024

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
Copy link
Contributor

maxfreu commented Aug 19, 2024

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
Copy link
Author

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

@maxfreu
Copy link
Contributor

maxfreu commented Aug 19, 2024

Yes, as well as for the 4 band model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants