Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Last active August 7, 2020 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniruddha27/76183fea01820bca6f72ca17f87306bc to your computer and use it in GitHub Desktop.
Save aniruddha27/76183fea01820bca6f72ca17f87306bc to your computer and use it in GitHub Desktop.
# ImageDataGenerator flow_from_directory
train_generator = datagen.flow_from_directory(
directory=home_path + r'/train/',
target_size=(400, 400), # resize to this size
color_mode="rgb", # for coloured images
batch_size=1, # number of images to extract from folder for every batch
class_mode="binary", # classes to predict
seed=2020 # to make the result reproducible
)
fig, ax = plt.subplots(nrows=1, ncols=4, figsize=(15,15))
for i in range(4):
# convert to unsigned integers for plotting
image = next(train_generator)[0].astype('uint8')
# changing size from (1, 200, 200, 3) to (200, 200, 3) for plotting the image
image = np.squeeze(image)
# plot raw pixel data
ax[i].imshow(image)
ax[i].axis('off')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment