Using Keras, how can I input an X_train of images (more than a thousand images)?

后端 未结 3 1743
一生所求
一生所求 2021-02-04 17:37

My application is accident-avoidance car systems using Machine Learning (Convolutional Neural Networks). My images are 200x100 JPG images and the output is an array of 4 element

相关标签:
3条回答
  • 2021-02-04 18:05

    In this repository you have an example:

    https://github.com/ZFTurbo/KAGGLE_DISTRACTED_DRIVER/blob/master/run_keras_simple.py

    They have different folders, in every folder there is a different class of image. They load the images using OpenCV and they build arrays that contains the class of every image.

    0 讨论(0)
  • 2021-02-04 18:20

    Create a folder for train and in the folder, create separate folders for the classes of images.

    Access the images using

      train_generator = train_datagen.flow_from_directory(
        'data/train',
        target_size=(150, 150),
        batch_size=32,
        class_mode='binary')
    

    In reference to keras.io

    0 讨论(0)
  • 2021-02-04 18:27

    This Keras blog post, Building powerful image classification models using very little data, is an excellent tutorial for training a model on images stored in directories. It also introduces the ImageDataGenerator class, which has the member function flow_from_directory referenced in @isaac-moore's answer. flow from directory can be used train on images, where the directory structure is used to deduce the value of Y_train.

    The three python scripts that accompany the tutorial blog post can be found at the links below:

    1. classifier_from_little_data_script_1.py
    2. classifier_from_little_data_script_2.py
    3. classifier_from_little_data_script_3.py

    (Of course, these links are in the blog post itself, but the links are not centrally located.) Note that scripts 2 and 3 build on the output of the previous. Also, note that additional files will need to be downloaded from Kaggle and Github.

    0 讨论(0)
提交回复
热议问题