Assuming the first image represents the image while the second one the mask, the data loading looks correct, so I’m still unsure why the previous shape is returned.
Could you iterate the Dataset for an entire epoch and check all mask shapes?