Same shape, only one is the image
chw = np.transpose(photo, (2, 0, 1)) # (3, 512, 512) — correct
wrong = photo.reshape(3, 512, 512) # (3, 512, 512) — scrambled
Both give shape (3, 512, 512). Only one is the image.
A shape check passes on both, which is precisely why this bug survives code review. The check that catches it is a value check: pick a coordinate and confirm the number that lands there is the one you meant.