bigmb/Unet-Segmentation-Pytorch-Nest-of-Unets

Help for data or data format

ALEXdwt opened this issue · 1 comments

Thanks for your work!

A dataset by myself was used to test your code, but it comes:
Traceback (most recent call last):
File "E:\dwt\BrainExtract\PythonUnet\Unet-Segmentation-Pytorch-Nest-of-Unets-master\pytorch_run.py", line 251, in
for x, y in train_loader:
File "F:\pythontool\lib\site-packages\torch\utils\data\dataloader.py", line 628, in next
data = self._next_data()
File "F:\pythontool\lib\site-packages\torch\utils\data\dataloader.py", line 671, in _next_data
data = self.dataset_fetcher.fetch(index) # may raise StopIteration
File "F:\pythontool\lib\site-packages\torch\utils\data_utils\fetch.py", line 58, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "F:\pythontool\lib\site-packages\torch\utils\data_utils\fetch.py", line 58, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "E:\dwt\BrainExtract\PythonUnet\Unet-Segmentation-Pytorch-Nest-of-Unets-master\Data_Loader.py", line 104, in getitem
img = self.tx(i1)
File "F:\pythontool\lib\site-packages\torchvision\transforms\transforms.py", line 95, in call
img = t(img)
File "F:\pythontool\lib\site-packages\torch\nn\modules\module.py", line 1190, in call_impl
return forward_call(*input, **kwargs)
File "F:\pythontool\lib\site-packages\torchvision\transforms\transforms.py", line 270, in forward
return F.normalize(tensor, self.mean, self.std, self.inplace)
File "F:\pythontool\lib\site-packages\torchvision\transforms\functional.py", line 360, in normalize
return F_t.normalize(tensor, mean=mean, std=std, inplace=inplace)
File "F:\pythontool\lib\site-packages\torchvision\transforms\functional_tensor.py", line 940, in normalize
return tensor.sub
(mean).div
(std)
RuntimeError: output with shape [1, 96, 96] doesn't match the broadcast shape [3, 96, 96]

I cut the 3D MRI data into 2D images (size 256*256), and save them as png format, then put some of the pngs into the data folder separately, is there any problem?

bigmb commented

Input to the model in pytorch run is of shape 3 and not 1.
So you can either change the shape of the model input in pytorch_run or make your image into 3 channel.