I currently have images in my local laptop and would like to transform them into datasets in order to load in for keras python. Is there any solutions for me to do that?
Asked
Active
Viewed 76 times
2 Answers
1
You can use ImageDataGenerator
to load the images.
train_datagen = ImageDataGenerator(
rescale=1./255,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True)
train_generator = train_datagen.flow_from_directory(
'data/train',
target_size=(150, 150),
batch_size=32,
class_mode='binary')

Suraj Subbarao
- 89
- 5
1
In this link, you can find several ways of loading your images from your directory using Python. A simple way also is the following:
import numpy as np
import cv2
import os
instances = []
# Load in the images
for filepath in os.listdir('images/'):
instances.append(cv2.imread('images/{0}'.format(filepath),0))
print(type(instances[0]))
Not sure if it is the most efficient though.

Chris Tosh
- 446
- 2
- 8