Skip to content

2749 Fix ThreadDataLoader reset #2750

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

Merged
merged 10 commits into from
Aug 13, 2021
6 changes: 2 additions & 4 deletions monai/data/thread_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class ThreadDataLoader(DataLoader):
def __init__(self, dataset: Dataset, num_workers: int = 0, **kwargs):
super().__init__(dataset, num_workers, **kwargs)

# ThreadBuffer will use the inherited __iter__ instead of the one defined below
self.buffer = ThreadBuffer(super().__iter__())

def __iter__(self):
yield from self.buffer
buffer = ThreadBuffer(super().__iter__())
yield from buffer
2 changes: 2 additions & 0 deletions tests/test_thread_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def test_dataloader(self):
for d in dataloader:
self.assertEqual(d["image"][0], "spleen_19.nii.gz")
self.assertEqual(d["image"][1], "spleen_31.nii.gz")

for d in dataloader:
self.assertEqual(d["label"][0], "spleen_label_19.nii.gz")
self.assertEqual(d["label"][1], "spleen_label_31.nii.gz")

Expand Down