Last active
October 2, 2019 12:14
-
-
Save L-Lewis/a34845b596c15dbb41ed34b9f3ff729b to your computer and use it in GitHub Desktop.
This file contains 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
from keras.preprocessing.image import ImageDataGenerator | |
import pandas as pd | |
# Getting the images and rescaling | |
image_folder = 'model3_images/' | |
image_generator = ImageDataGenerator(rescale=1./255).flow_from_directory( | |
image_folder, shuffle=False, class_mode='binary', | |
target_size=(128, 128), batch_size=20000) | |
images, labels = next(image_generator) | |
# Output: Found 20000 images belonging to 2 classes. | |
# Checking the labels | |
image_generator.class_indices | |
# Output: {'danger': 0, 'safe': 1} | |
# Getting the ordered list of filenames for the images | |
image_files = pd.Series(image_generator.filenames) | |
image_files = list(image_files.str.split("\\", expand=True)[1].str[:-4]) | |
# Sorting the structured data into the same order as the images | |
df_sorted = df.reindex(image_files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment