Pytorch-UNet
Pytorch-UNet copied to clipboard
RuntimeError: only batches of spatial targets supported (3D tensors) but got targets of size: : [1, 215, 245, 3]
Hi, I have a problem with this place, can you help me?
I have the same question!
I fixed this issue by making sure my masks files only had 1 channel and not 3.
With open cv it was : img = cv2.imread('path/to/your/mask') img_1_channel = img[:,:,0] cv2.imwrite('path/to/new/mask', img_1_channel)
Thanks, I know exactly what the problem is too. Pytorch nn.CrossEntropyLoss() requires input dimension is (N,C,H,W), target dimension is (N,H,W). So the mask must be pre-processed as a single channel. I learned this from the following blog, hope it can give you some help. https://blog.csdn.net/Fcc_bd_stars/article/details/105158215
Hi, can you try the latest master? I improved the support for custom datasets.