Created
December 26, 2019 18:49
-
-
Save himanshurawlani/b50afcc2545ec894324731230fdff6e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def construct_image_batch(image_group, BATCH_SIZE): | |
# get the max image shape | |
max_shape = tuple(max(image.shape[x] for image in image_group) for x in range(3)) | |
# construct an image batch object | |
image_batch = np.zeros((BATCH_SIZE,) + max_shape, dtype='float32') | |
# copy all images to the upper left part of the image batch object | |
for image_index, image in enumerate(image_group): | |
image_batch[image_index, :image.shape[0], :image.shape[1], :image.shape[2]] = image | |
return image_batch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment