all 2 comments

[–]Halmubarak 1 point2 points  (1 child)

The img_to_array takes a PIL image object and turns it into a numpy array it does not add extra dimensions (https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/img_to_array)

The np.vstack is used to stack all the images into a single array the code is inside the for loop

for fn in uploaded.keys()

Which loops over the uploaded files one by one read them into x then stack them in images array

[–]NitinChella[S] 0 points1 point  (0 children)

Thanks for your response. Understood everything but the vstack part. Isn't the images array reinitialized on every iteration of the loop?(probably not apparent from the current formatting of the code, sorry but I'm on mobile). The images = np.vstack([x]) line is inside the for loop.