MIC-DKFZ / nnUNet

Apache License 2.0
5.87k stars 1.76k forks source link

The size of tensor a(112) must match the size of tensor b(221) at non-singleton dimension 4 #2258

Open one2clouds opened 5 months ago

one2clouds commented 5 months ago

All the preprocessing steps are finished and didn't cause any problem. But while training nnUNet, I came across the problem which says,

File "/home/shirshak/FracSegNet/.venv/lib/python3.10/site-packages/nnunet/training/loss_functions/dice_loss.py", line 198, in forward
    tp, fp, fn, _ = get_tp_fp_fn_tn(x, y,disMap,axes, loss_mask, False,current_epoch)
  File "/home/shirshak/FracSegNet/.venv/lib/python3.10/site-packages/nnunet/training/loss_functions/dice_loss.py", line 150, in get_tp_fp_fn_tn
    tp = torch.mul(tp, disMap2onehot)
RuntimeError: The size of tensor a (112) must match the size of tensor b (221) at non-singleton dimension 4

Now, from error above I see there is shape mismatch and all the images and labels are of different shapes, so How do I bring them in same shape? So , should I change shape of the files outside before even preprocessing nnUNet. That can be done, But Already preprocessing of those files have been done, so I am asking for any alternative that nnUNet itself gives?

seziegler commented 5 months ago

Hi @one2clouds , no you don't have to adapt the shapes for nnU-Net. Since it is sampling patches and never loads the whole image anyways this is not the problem. Can you please rerun the preprocessing with the flag --verify_dataset_integrity?