Loop function for importing multiple images and processing using TensorFlow Keras

This section describes how to import multiple images in a batch to process all of them together rather than importing them one by one. This is a critical skill to learn as, in most production applications, you will not be importing images one by one. The code for a loop function for importing and processing multiple images using TensorFlow Keras is as follows:

for image1 in images: i+=1 im = image.load_img(folder_path+image1, target_size=(224, 224)) img_data = image.img_to_array(im) img_data = np.expand_dims(img_data, axis=0)img_data = preprocess_input(img_data)resnet_feature = model_resnet.predict(img_data,verbose=0) label = decode_predictions(resnet_feature) ...

Get Mastering Computer Vision with TensorFlow 2.x now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.