Open rousseau opened 3 days ago
Hi Francois
Interesting, this is a good example of side effect related to this issue #1179
First solution is to downgrade PyTorch to a version < 2.3
Second solution is to use the "hack" propose here https://github.com/fepegar/torchio/issues/1179#issuecomment-2254715480
and then addapt your code
instead of using tio.datasets.Colin27() and tio.SubjectsDataset(subjects) you must use the redefined Subject and SubjectsDataset class (as proposed by c-winder) I did :
suj = Subject(t1=subject.t1,head=subject.head)
training_set = SubjectsDataset([suj])
and also instead of
def training_step(self, batch, batch_idx):
target = batch['t1'][tio.DATA]
source = batch['t1'][tio.DATA]
use
def training_step(self, batch, batch_idx):
target = batch['t1']
source = batch['t1']
I just realize that c-winder, also propose this https://github.com/fepegar/torchio/issues/1179#issuecomment-2254691162
then if you use his SubjectDataLoader
instead of torch.utils.data.DataLoader
, it will work too (with same change in training_step function
Note that you then get an other error due to unet not dealing with odd shape, which can be solved by using CropOrPad for instance
tc = tio.CropOrPad(target_shape=[184,216,184])
suj = tc(suj)
Thank you both. You can also take a look at EnsureShapeMultiple for the U-Net error.
Is there an existing issue for this?
Bug summary
Crash when using Lightning and TorchIO during training.
Code for reproduction
Actual outcome
The issue seems to be related to torchio/data/image.py", line 471, in _parse_path TypeError: The path argument cannot be a dictionary
Error messages
Expected outcome
It's a dummy code. The expected outcome is that the training should work.
System info