Last active
December 26, 2021 15:47
-
-
Save aniruddha27/61ea724d3fec1d023c3dbbd6a606adad 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
# ImageDataGenerator flow_from_dataframe | |
df_train = pd.read_csv(home_path + r'/emergency_train.csv') | |
df_train['emergency_or_not'] = df_train['emergency_or_not'].astype('str') # requires target in string format | |
train_generator_df = datagen.flow_from_dataframe(dataframe=df_train, | |
directory=home_path+'/images/', | |
x_col="image_names", | |
y_col="emergency_or_not", | |
class_mode="binary", | |
target_size=(200, 200), | |
batch_size=1, | |
rescale=1.0/255, | |
seed=2020) | |
# plotting images | |
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_df)[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