Keras ImageDataGenerator unable to find images
I'm trying to add image data to a Kaggle notebook so I can run a convolutional neural network but I'm having trouble doing this via ImageDataGenerator
. This is the link to my Kaggle notebook
These are my imports:
import numpy as np # linear algebra#
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from random import randint
from sklearn.utils import shuffle
from sklearn.preprocessing import MinMaxScaler
import tensorflow as tf#
from tensorflow import keras#
from tensorflow.keras.models import Sequential#
from tensorflow.keras.layers import Activation, Dense, Flatten, BatchNormalization, Conv2D, MaxPool2D#
from tensorflow.keras.optimizers import Adam #
from tensorflow.keras.metrics import categorical_crossentropy #
from tensorflow.keras.preprocessing.image import ImageDataGenerator #
from sklearn.metrics import confusion_matrix #
import itertools #
import matplotlib.pyplot as plt #
import os
import shutil
import random
import glob
import warnings
# Input data files are available in the read-only ../input/ directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
Here is my code where I attempt to import the data using the ImageDataGenerator
:
#Define datagen:
datagen = ImageDataGenerator(rescale=1./255)
#Train Data:
cat_train_datagen = datagen.flow_from_directory('../input/dog-vs-cat-images-data/dogcat/train/cats',
batch_size=500, shuffle=True)
dog_train_datagen = datagen.flow_from_directory('../input/dog-vs-cat-images-data/dogcat/train/dogs',
batch_size=500, shuffle=True)
#Valid Data:
cat_valid_datagen = datagen.flow_from_directory('../input/dog-vs-cat-images-data/dogcat/validation/cats',
batch_size=100, shuffle=True)
dog_valid_datagen = datagen.flow_from_directory('../input/dog-vs-cat-images-data/dogcat/validation/dogs',
batch_size=100, shuffle=True)
#Test Data:
test_datagen = datagen.flow_from_directory('../input/dog-vs-cat-images-data/dogcat/test1/test1',
batch_size=100, shuffle=True)
This is my terminal output:
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
Any input would be greatly appreciated, as I'm fairly new to Keras and am unsure whether I am using ImageDataGenerator
correctly.
Topic image-preprocessing cnn keras kaggle python
Category Data Science