plantnet / GeoLifeCLEF

GeoLifeCLEF challenge toolkit and starter code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Land cover one hot reshape problem

riccardodelutio opened this issue · comments

Hi,

I was trying out the code you provided for creating a pytorch dataset and dataloader, (which is very helpful, thanks) https://github.com/maximiliense/GLC/blob/master/examples/pytorch_dataset.py.

I just encountered a small issue in the land cover one hot encoding, it seems like there is a problem when reshaping it in the __getitem__ method of the DatasetGLC20 class.

In fact when having a look at the sample 10000000 from the France training dataset, which looks like this before the one-hot:
no_onehot

After doing the one-hot encoding it looks like this:
one_hot

I made a small change to the __getitem__ method to fix this such that it looks like this:
fixed_one_hot

lc = rgb_ir_lc[4:5][0]    
lc_one_hot = np.zeros((self.one_hot_size,lc.shape[0], lc.shape[1]))
layer_idx = np.arange(lc.shape[0]).reshape(lc.shape[0], 1)
component_idx = np.tile(np.arange(lc.shape[1]), (lc.shape[0], 1))
lc_one_hot[lc, layer_idx, component_idx] = 1

I can open a pull request if that would help.

Cheers,
Riccardo

Dear Riccado, Yes thank you very much, I would be glad if you could open a pull request! Thanks!

Great, just opened it!

Thx! I merged your pull request!