Closed mattnsoleil closed 3 years ago
Hello @mattnsoleil, we actually don't use PIL
at all. As you can see in mri_data.py
, we return a tuple with several different data types, the first of which should be a numpy array.
We provide examples of transforms you can use for this tuple for both the U-Net and the VarNet. Simple combinations of torchvision
transforms will not work - MRI reconstruction is a substantially different application than where torchvision
is used so you will need to reimplement most things to work with this data depending on how you want it preprocessed for your model.
Hello,
I have been always encountering TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found <class 'NoneType'> in Variational Network implementation not in UNET with fastmri multicoil knee test dataset. It works correctly in UNET. Thank you for sharing. But When searched for this error, it is always saying that dataset loading image error in PIL. I have seen all types were tuple but could not see the solution. Both UNET and Variational Network use mri_data.py and all types are tuple, but it just works only in UNET but not works in Variational Netwok. It is not about update of torchvision or transforms.ToTensor(). Is there anyone to overcome this problem?
Thanks,
Could you identify which script in the repository you ran to generate the error? I also need to know what transform function you used.
For example, one way this error might happen would be if you used a SliceDataset
without the VarNetDataTransform
. SliceDataset
in this case will return a None
for target
. A None
cannot be collated. This is fixed if you use the VarNetDataTransform
which converts the None
to a 0.
No, I have used VarNetDataTransform from fastmri/data/transforms.py. There is no problem in data_transform result. I could see it but in mri_data.py, SliceDataset does not give a dataset for DataLoader. Firstly, I saw TypeError: Caught TypeError in DataLoader worker process 0 and then faced TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found <class 'NoneType'. I thought there was a problem in converting tensor , made some modification but that were not a solution for this.
Have you got any idea why I have been facing this error?
Best,
@mattnsoleil unfortunately I don't think I can diagnose your case without a reproducible example.
python run_pretrained_varnet_inference.py --data_path 'G:\knee_multicoil_test_v2\multicoil_test_v2/' --output_path 'G:\Variational_Output_Test/' --challenge varnet_knee_mc command gives me this error.
Running inference: 0% 0/653 [00:00<?, ?it/s]
Traceback (most recent call last):
File "run_pretrained_varnet_inference.py", line 151, in
I can reproduce this. Working on a fix.
@mattnsoleil this should be fixed by PR #181. Let me know if it works for you.
Thanks, It worked.
Closing this as it seems to be resolved.
Hi,
In test dataset, It gives TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found <class 'NoneType'>. There is a problem in dataset loading images with the PIL library and does not convert them into necessary types like list or Tensor. Is there anyone who overcome this problem? Because I could not overcome with editting transform = transforms.Compose([ transforms.ToTensor() ]).