-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unnecessary warning when using next(iter(SubjectsLoader)) #1261
Comments
Thanks for reporting, @lorinczszabolcs. Unfortunately I won't be able to pick this up any time soon. Feel free to give it a try. |
Hi @lorinczszabolcs, I am pretty sure that warning message arises due to the wrong/unexpected instantiation of your subjects. Generally speaking, a # Create a list of subjects with file paths
subject_list = [
{
'image': image_path,
'label': label_path,
}
] The expected usage is outlined in the official documentation. The reason why you now get an error message arises from the call If you create your See following MWE: import torch
import torchio as tio
def generate_subject(tensor_size: tuple[int, ...]) -> tio.Subject:
subject = tio.Subject(
image=tio.ScalarImage(tensor=torch.randint(0, 2**8,tensor_size)),
label=tio.LabelMap(tensor=torch.randint(0, 2, tensor_size)),
)
return subject
def debug():
tensor_size = (1,240,240,155)
num_subjects = 2
transform = tio.Compose([
tio.ToCanonical(), # Standardize orientation
tio.RescaleIntensity((0, 1)), # Normalize intensity to 0-1
])
dataset = tio.SubjectsDataset([generate_subject(tensor_size=tensor_size) for _ in range(num_subjects)], transform=transform)
loader = tio.SubjectsLoader(dataset, batch_size=1)
for batch in loader:
print(batch)
break
if __name__ == '__main__':
debug() Hope this helps and we can close the Bug. Edit: Code formatting for better readability |
Thanks for investigating! Yes, issue can be closed, I somehow missed the part that we need to instantiate with list of Subjects. Thanks for the heads-up! |
Is there an existing issue for this?
Related issues, but not completely the same: #1247 #1250
Bug summary
I have some custom code where I iterate through my dataloader with
next(iter(loader))
, and it shows a warning message, which I believe is unnecessary, as I have changed my code to use a tio.SubjectsLoader.Code for reproduction
Actual outcome
Error messages
Expected outcome
I expect to not receive such a warning, given that I am using a
SubjectsLoader
andSubjectsDataset
.System info
The text was updated successfully, but these errors were encountered: