Unnecessary warning when using TorchIO inside Dataset __getitem__
without returning Subject
objects
#1247
Labels
bug
Something isn't working
Is there an existing issue for this?
Bug summary
When using TorchIO within the
__getitem__
method of a customDataset
, and returning a tuple of(torch.Tensor, dict)
instead of atorchio.Subject
, I receive a warning suggesting to useSubjectsLoader
. However, replacingDataLoader
withSubjectsLoader
is not feasible in this case and leads to errors, asSubjectsLoader
expectsSubject
instances. The warning seems unnecessary and cannot be easily suppressed.Code for reproduction
Actual outcome
Running the provided code with a standard
DataLoader
results in a warning message from TorchIO, even though the data returned by the customDataset
is a tuple of(torch.Tensor, dict)
and does not involvetorchio.Subject
objects in the final output. The warning is unnecessary because the actual batch structure is fully compatible with PyTorch'sDataLoader
.When attempting to follow the warning's suggestion to replace
DataLoader
withSubjectsLoader
, the program fails with anAttributeError
becauseSubjectsLoader
expects each dataset item to be atorchio.Subject
, but theDataset
returns a tuple instead. This makesSubjectsLoader
unusable for this scenario.Error messages
Expected outcome
I expect that when using TorchIO inside the
__getitem__
method but returning standard PyTorch data structures (e.g.,torch.Tensor
anddict
), the warning about usingSubjectsLoader
should not be displayed. Alternatively, there should be a way to suppress this warning when it's not applicable.System info
The text was updated successfully, but these errors were encountered: