You need to add transfroms.ToTensor() at the end of transformations block and custom DataLoaders require operations with PIL library. So, you can do transformations with numpy and then convert the image to PIL format. In your case, you need to convert the result of img = np.moveaxis(img,0,-1) to PIL and then pass it to transform function.