Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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