Facing resize error

while going through theses steps:

trainloader = torch.utils.data.DataLoader(custom_data_loader(img_root = img_root, image_list = train_list_file, crop=False,
resize = True, resize_shape=[128,128], classes = ‘IIC’),
batch_size=8, num_workers=8, shuffle = True, pin_memory=True)
for batch_idx, (inputs, targets) in enumerate(trainloader):

I face this error:

image = cv2.resize(image, (self.resize_shape[1], self.resize_shape[0]))   ### resize_shape is in [rows, cols]

cv2.error: /opencv-3.4.0/modules/imgproc/src/resize.cpp:4044: error: (-215) ssize.width > 0 && ssize.height > 0 in function resize

How to make sure image is not None in trainloader?

You could check if the image is None before the resize call.
If that’s the case you could randomly pick a new index and load another image. That will make things unclear, e.g. when shuffle=False, but for the moment your DataLoader does not crash.
Try to find the image using its index and fix it or delete it.