def predictions_for_tiles(test_images, model):
"""Batch predictions on the test image set, to avoid a memory spike."""
npy_test_images = numpy.array([img_loc_tuple[0] for img_loc_tuple in test_images])
test_images = npy_test_images.astype(numpy.float32)
test_images = numpy.multiply(test_images, 1.0 / 255.0)
all_predictions = []
for x in range(0, len(test_images) - 100, 100):
for p in model.predict(test_images[x:x + 100]):
all_predictions.append(p)
for p in model.predict(test_images[len(all_predictions):]):
all_predictions.append(p)
assert len(all_predictions) == len(test_images)
return all_predictions
评论列表
文章目录