I am trying to resize and normalise all the images in a folder but at the end, it throws an error saying list is out of range
def resize():
data = []
img_size = 244
data_dir = r'C:\technocolab project2\archive'
for img in os.listdir(data_dir):
try:
imgPath = os.path.join(data_dir,img)
images = cv2.imread(imgPath, cv2.IMREAD_GRAYSCALE)
image_resized = cv2.resize(images,(img_size,img_size))
data.append(img_resized)
except:
pass
return data
data = resize()
print(len(data))
sample = data[0]
print(sample.shape)
the error that it shows is given in the figure that says:
IndexError: list index out of range
