Tassou
Tassou

Reputation: 449

How to download local image sets to use with Keras?

Iam new to keras and after testing some tutorials with mnist images I would like to train with my own data set. The data are .png images of numbers from 0-9. I ordered them into 10 classes, each containing 100 .png images of the numbers separately (so one folder for 0, one folder for 1, one folder for 2 etc ..).

now I am wondering how to load the images with python, for keras to use them ?

Upvotes: 1

Views: 1590

Answers (1)

blackHoleDetector
blackHoleDetector

Reputation: 3033

You need to use Keras’ ImageDataGenerator().flow_from_directory() to generate batches of your image data from your file system that you will then train your model on. Once you have your images organized in the file system, creating ImageDataGenerator() would be the next step.

This video demonstrates how to prep your image data and create your ImageDataGenerator(), and then this video demonstrates how to train your CNN on the image data.

An example of this would look like

train_batches = ImageDataGenerator().flow_from_directory(directory=<path_to_image_data>, target_size=(224,224), classes=[‘0’, '1', ‘2’, ‘3’, …, ‘9’], batch_size=10)

Upvotes: 1

Related Questions