Comments (7)
Fixed in #981. Thanks @jmlipman for your detailed report and code to reproduce.
from torchio.
Thanks for reporting, @jmlipman. This is bad. I've reproduced with the following code:
from collections import Counter
import numpy as np
from rich import print
import torch
from torch.utils.data import DataLoader
import torchio as tio
torch.manual_seed(42)
image_size = 10, 10, 10
patch_size = 10, 10, 1
batch_size = 10
num_subjects = 10
samples_per_volume = 8
max_queue_length = 50
subjects = []
for sub_id in range(num_subjects):
data = np.random.random((1, *image_size))
params = {
"im": tio.ScalarImage(tensor=data),
"info": sub_id,
}
subjects.append(tio.Subject(**params))
dataset = tio.SubjectsDataset(subjects)
sampler = tio.data.UniformSampler(patch_size)
queue = tio.Queue(
dataset,
max_length=max_queue_length,
samples_per_volume=samples_per_volume,
sampler=sampler,
verbose=True,
)
tr_loader = DataLoader(
queue,
batch_size=batch_size,
shuffle=False,
)
# One epoch of training
all_patch_ids = []
for patch in tr_loader:
ids = patch["info"].tolist()
print(ids)
all_patch_ids.extend(ids)
print()
counter = Counter(all_patch_ids)
for key in sorted(counter):
print(f'{key}: {counter[key]}')
Output:
Creating subjects loader with 0 workers
Patches list is empty.
[4, 4, 3, 6, 7, 4, 4, 4, 5, 3]
[7, 4, 7, 6, 2, 5, 0, 4, 6, 7]
[7, 2, 3, 6, 3, 7, 5, 5, 6, 6]
[2, 4, 7, 5, 3, 0, 6, 7, 3, 2]
[3, 2, 3, 2, 6, 5, 2, 5, 2, 5]
Patches list is empty.
Queue is empty:
Creating subjects loader with 0 workers
[8, 8, 1, 4, 4, 3, 3, 5, 5, 3]
[4, 5, 5, 4, 8, 3, 0, 3, 3, 1]
[1, 5, 5, 1, 5, 8, 8, 3, 5, 1]
0: 3
1: 5
2: 8
3: 15
4: 12
5: 16
6: 8
7: 8
8: 5
I'll debug it and come back to you.
from torchio.
It's independent of the "new" behavior, so I've edited the code above to use the queue normally.
from torchio.
Here's the output for 8ee2ab2 (#795):
Creating subjects loader with 0 workers
Patches list is empty.
/Users/fernando/git/torchio/torchio/data/queue.py:219: RuntimeWarning: Queue length (50) not divisible by the number of patches per volume (8)
warnings.warn(message, RuntimeWarning)
Filling queue from 6 subjects...
[3, 5, 5, 3, 7, 5, 2, 5, 6, 2]
[7, 4, 3, 2, 4, 3, 4, 6, 7, 7]
[3, 6, 4, 5, 2, 5, 3, 5, 2, 6]
[7, 4, 7, 6, 3, 6, 4, 6, 2, 2]
Patches list is empty.
Filling queue from 6 subjects...
0%| | 0/6 [00:00<?, ?it/s]Queue is empty:
Creating subjects loader with 0 workers
[7, 7, 2, 3, 5, 4, 4, 6, 8, 8]
[0, 8, 9, 9, 1, 0, 1, 1, 8, 9]
[1, 8, 9, 1, 8, 1, 0, 9, 1, 9]
[8, 0, 1, 8, 1, 1, 0, 8, 8, 0]
0: 6
1: 10
2: 8
3: 8
4: 8
5: 8
6: 8
7: 8
8: 10
9: 6
And for max queue length 40:
Creating subjects loader with 0 workers
Patches list is empty.
Filling queue from 5 subjects...
[7, 4, 2, 6, 6, 3, 7, 3, 3, 7]
[7, 2, 2, 3, 4, 4, 2, 7, 4, 6]
[6, 2, 4, 7, 6, 4, 3, 6, 4, 3]
[2, 3, 6, 3, 6, 2, 4, 2, 7, 7]
Patches list is empty.
Filling queue from 5 subjects...
[9, 8, 0, 5, 5, 9, 5, 1, 1, 8]
[8, 1, 9, 8, 9, 0, 1, 9, 0, 9]
[9, 0, 5, 1, 0, 1, 8, 0, 5, 5]
[1, 5, 8, 0, 5, 0, 9, 8, 1, 8]
0: 8
1: 8
2: 8
3: 8
4: 8
5: 8
6: 8
7: 8
8: 8
9: 8
So it's been broken at some point since then.
from torchio.
git bisect
says we did break it in #795:
8ee2ab2f0caf66f4a1338b115fab1d014c754f6e is the first bad commit
from torchio.
For max queue length 41:
Creating subjects loader with 0 workers
Patches list is empty.
[7, 4, 7, 4, 6, 2, 4, 7, 2, 6]
[4, 3, 3, 6, 2, 7, 5, 7, 6, 2]
[3, 3, 3, 2, 4, 7, 3, 6, 6, 4]
[7, 3, 6, 4, 3, 2, 7, 2, 6, 4]
Patches list is empty.
Queue is empty:
Creating subjects loader with 0 workers
[2, 8, 0, 9, 0, 0, 9, 0, 8, 9]
[1, 9, 1, 1, 0, 0, 9, 0, 8, 0]
[0, 8, 8, 8, 0, 1, 0, 0, 1, 8]
[0, 8, 9, 0, 1, 9, 0, 0, 9, 8]
0: 16
1: 6
2: 8
3: 8
4: 8
5: 1
6: 8
7: 8
8: 9
9: 8
from torchio.
I think I got it. It only took me three hours
from torchio.
Related Issues (20)
- GridAggregator does not support smaller output than input HOT 1
- After resample ,my label becomes zero tensor! HOT 4
- There is something wrong with the image origin HOT 4
- Add pythonic slicing support to torchio.Image HOT 2
- RuntimeError: More than one value for "direction" found in subject images HOT 2
- FileNotFoundError: File not found: "data" HOT 13
- Patch based augmentations/transformations HOT 8
- Typo in the documentation HOT 4
- Working with a dataset with different volumes HOT 5
- padding_mode does not support functions HOT 3
- Mypy CI checks on Windows are failing
- fftshift is not implemented until pytorch version 1.8.0
- Parallel histogram_standalization.train HOT 1
- Feature proposal: TorchIO hub - A system to store and fetch transform objects for reproducibility HOT 6
- Image get loading when __copy__ is called
- FileNotFoundError: File not found: "affine" HOT 9
- CropOrPad with marginally different Origins HOT 2
- Order of the elements in the queue changes unexpectedly HOT 4
- (Potential) Reversible RescaleIntensity Transform HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torchio.