Yanfeng-Zhou / XNet

[ICCV2023] XNet: Wavelet-Based Low and High Frequency Merging Networks for Semi- and Supervised Semantic Segmentation of Biomedical Images
MIT License
184 stars 8 forks source link

train 2D Xnet question #18

Open Ystartff opened 6 months ago

Ystartff commented 6 months ago

Hello! I would like to know how your mean and std are calculated if training other datasets, because I see that in semi-supervised learning, the unlabelled and labelled files contain L and H files.

Ystartff commented 6 months ago

Hello, my problem is that when I do onehot coding the previous batches target.shape is (2,128,128,2) but the later batches have (2,128,128,256). A problem with the code prompts me to Traceback (most recent call last): File "train_semi_XNet.py", line 255, in loss_train_sup1 = criterion(pred_train_sup1, mask_train_sup) File "/home/panxue/anaconda3/envs/wave/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "/mnt/data/panxue/PX/XNet-main/loss/loss_function.py", line 132, in forward return self._base_forward(output, target_one_hot, valid_mask) File "/mnt/data/panxue/PX/XNet-main/loss/loss_function.py", line 100, in _base_forward dice_loss = dice(predict[:, i], target[..., i], valid_mask) IndexError: index 2 is out of bounds for dimension 1 with size 2 Traceback (most recent call last): File "train_semi_XNet.py", line 255, in loss_train_sup1 = criterion(pred_train_sup1, mask_train_sup) File "/home/panxue/anaconda3/envs/wave/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, **kwargs) File "/mnt/data/panxue/PX/XNet-main/loss/loss_function.py", line 132, in forward return self._base_forward(output, target_one_hot, valid_mask) File "/mnt/data/panxue/PX/XNet-main/loss/loss_function.py", line 100, in _base_forward dice_loss = dice(predict[:, i], target[..., i], valid_mask) IndexError: index 2 is out of bounds for dimension 1 with size 2

Yanfeng-Zhou commented 5 months ago

Hello!

  1. I have written the corresponding code for the calculation of mean and std, but have not uploaded it. I will consider updating the code. In fact, the calculation of mean and std is very simple: calculate the mean and standard deviation of the individual pixel values of all images in the training data.
  2. IndexError: index 2 is out of bounds for dimension 1 with size 2. This error most likely comes from you not processing the mask (the foreground pixel in the mask before processing is 255). For binary semantic segmentation problems, the foreground pixel in the mask should be 1.