Wrong/different image shapes after DataLoader; bug in DL?

Image shape WITH DataLoader: torch.Size([376, 1241, 3])
Image ARRAY shape -manual- BEFORE/AFTER DataLoader execution: (375, 1242, 3)

The image size is
height: 375
width: 1242

But the ouput of DL is:
height: 376
width: 1241

If I catch the output of my __getitem__ manually an image array is returned with the right shape.
If I next(iter(train_dataloader)) I get the wrong shape … which really confuses me.
I haven’t enabled any transforms or similar.

The confusing thing is … at the beginning everything worked fine – even with the DataLoader.
I restarted my docker-container (with torch, …) several time; tried an other container, opened a new Notebook, ran it straight as a python-script, backuped my CustomData-Set with some “older” version, I backuped …: Nothing.

I don’t get it, where and why my image is changed in shapes.

collate_fn should be deactivated.

train_data = KittiDist(root = "datasets", develop = True)

train_dataloader = DataLoader(dataset=train_data,
                               batch_size=None, # how many samples per batch?
                               num_workers=1, # how many subprocesses to use for data loading? (higher = more)
                               shuffle=False) # shuffle the data?

image_dl, target = next(iter(train_dataloader))

Any idea?

using the collate_fn the same just with the batch_dim: ([1, 376, 1241, 3])

Issue happens with different docker containers using:
torchversion: ‘1.13.1+cu117’ and ‘1.12.x…’

any idea? :slight_smile:

shuffle=False: →Wrong shape.
Bildschirmfoto vom 2023-03-02 05-59-35

shuffle=True: → Right shape.
Bildschirmfoto vom 2023-03-02 05-58-51

When I played around with pin_memory=True/False AND shuffle=True/False the shape gots even more crazy (1238 instead of 1242, …). But I couldn’t reproduce it again.

(With shuffle=True)

and again (randomly wrong shape) also with shuffle=True

What’s going on here? :smiley:

Hi @MikeTensor
Can you change the batch_size to 1 and try it out? In general batch_size should not be None DataLoader

Could you point me to the implementation of KittiDist and where I could find this dataset?

Same issue.
As I wrote:

using the collate_fn the same just with the batch_dim: ([1, 376, 1241, 3])
Only that the batch_dim is added.

Oh my godness – I am so sorry for the false alarm.
The solution: The Kitti-Dataset does NOT have the same image-size.
Since I always opened the images manually with the __getitem__ I never got lucky enough to catch one of a few with different shape …

I am just happy that I can move on :smiley:
– Ohh dear …