Solved by rasbt in post #6 
              
              
                I see. So you are not using DataLoader or anything like that but just calling that function on each image separately? 
In your function 
def normalizeCvImage(image_cv, device):
    image = torch.Tensor(image_cv).to(device)
    image = image.permute(2, 0, 1).unsqueeze(0)
    image = (image - 127.5) /…