def predict_batch_test_images (model, batch_size = 1, max_image = 50):
#
# DESCRIPTION
# Generator function batching each of the 32 mapped image from one test image
# Once the image have been loaded they are predicted using the specified Keras Model
# Once predicted the generator finally yields the batch to be treated in a for loop in predict_and_rebuild
#
# INPUTS
# model keras model
# batch_size set to 1
# max_image the max number of image loaded (50 test set)
#
# OUTPUTS
# yield predictions a np.array of [:, 400, 400, 1]
#
images = np.zeros(shape=[8*4, 400, 400, 3], dtype=float)
for i in range(1,max_image+1):
count = 0
for rota_count in range(8):
for patch_count in range(4):
images[count, :,:,:] = mpimg.imread('test_set_images/test_'+str(i)+'/Test_'+str(i)+'_rota'+str(rota_count)+'_patch'+str(patch_count)+'.png')
count += 1
if (count == 32):
preds = model.predict(images, batch_size = batch_size, verbose=1)
yield preds
评论列表
文章目录