Visualze the dataset images

when I try to visualize the images of the dataset, always give me a white image
and when I feed another data set the correct image is was visualized

This is a code
import os

import torch

from torchvision import datasets, transforms

from torch.utils.data import Dataset, DataLoader

import torch

import torchvision

import torchvision.transforms as transforms

import matplotlib.pyplot as plt

import cv2

import numpy as np

Write data loaders for training, validation, and test sets

Specify appropriate transforms, and batch_sizes

from PIL import ImageFile

ImageFile.LOAD_TRUNCATED_IMAGES = True

number of subprocesses to use for data loading

num_workers = 0

how many samples per batch to load

batch_size = 64

data_transform_train = transforms.Compose([

transforms.Resize(256),

transforms.CenterCrop(224),

transforms.RandomHorizontalFlip(),

transforms.ToTensor(),

transforms.Normalize((.5), (.5))

])

data_transform_test = transforms.Compose([

transforms.Resize(256),

transforms.CenterCrop(224),

transforms.ToTensor(),

transforms.Normalize((0.5), (0.5))

])

data_dir = ‘/content/drive/MyDrive/graduation_project_dataset/Mammogram’

train_dir = os.path.join(data_dir, ‘train’)

valid_dir = os.path.join(data_dir, ‘valid’)

test_dir = os.path.join(data_dir, ‘test’)

train_data = datasets.ImageFolder(train_dir, transform=data_transform_train)

valid_data = datasets.ImageFolder(valid_dir, transform=data_transform_test)

test_data = datasets.ImageFolder(test_dir, transform=data_transform_test)

train_loader = torch.utils.data.DataLoader(train_data, batch_size=batch_size, num_workers=num_workers, shuffle=True)

valid_loader = torch.utils.data.DataLoader(valid_data, batch_size=batch_size, num_workers=num_workers, shuffle=True)

test_loader = torch.utils.data.DataLoader(test_data, batch_size=batch_size, num_workers=num_workers, shuffle=True)

loaders_scratch = {

'train' : train_loader,

'valid' : valid_loader,

'test'  : test_loader

}

train_images, train_labels = next(iter(train_loader))

for img in train_images:

print(’\nShape of the image is: {0}’.format(train_images.shape))

grid = torchvision.utils.make_grid(img, nrow = 5)

img = train_images[2]

label = train_labels[2]

plt.imshow(np.transpose(grid,(1,2,0)), cmap = ‘gray’)

plt.show()

print(f"Label: {label}")

break

This when i upload another directory of the same data and the same arrangment

the extenstions of white output image is png
and another images file is Jpeg

Could you check the value range of the white image and make sure matplotlib is able to visualize it?
Based on the data type and range I guess matplotlib might automatically rescale the numpy array and could yield an “empty” image.

images are 16 bit and I normalize them and resize to 224 pixels, but the problem is still shown.