Losely following this tutorial, I'm trying to apply Keras' ImageDataGenerator preprocessing on my custom object dataset. Here is the code:
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.layers import Dense, Activation
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.metrics import categorical_crossentropy
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.preprocessing import image
from tensorflow.keras.models import Model
from tensorflow.keras.applications import imagenet_utils
from sklearn.metrics import confusion_matrix
import itertools
import os
import shutil
import random
import matplotlib.pyplot as plt
%matplotlib inline
os.chdir('/home/pc3/deep_object/')
mobile = tf.keras.applications.mobilenet.MobileNet()
cwd = os.getcwd()
# Print the current working directory
print("Current working directory to generate: {0}".format(cwd))
train_path = 'data/Object-samples/train'
valid_path = 'data/Object-samples/valid'
test_path = 'data/Object-samples/test'
train_batches = ImageDataGenerator(preprocessing_function=tf.keras.applications.mobilenet.preprocess_input).flow_from_directory(
directory=r'data/Object-samples/train', target_size=(224,224), batch_size=10)
valid_batches = ImageDataGenerator(preprocessing_function=tf.keras.applications.mobilenet.preprocess_input).flow_from_directory(
directory=valid_path, target_size=(224,224), batch_size=10)
test_batches = ImageDataGenerator(preprocessing_function=tf.keras.applications.mobilenet.preprocess_input).flow_from_directory(
directory=test_path, target_size=(224,224), batch_size=10, shuffle=False)
However I get 0 pictures, despite the fact that the folders are already filled with pictures.
Current working directory to generate: /home/pc3/deep_object
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
my directory structure is like this:
~/deep_object$ tree -L 2
.
├── data
│ ├── Object-samples
│ ├── dogs-vs-cats
│ └── MobileNet-samples
├── deeplizard_tutorial_side_effects_example.ipynb
├── Mobilenet-finetunning-my-dataset.ipynb
So I'm wondering what is wrong here?
/Object-samples/
you'd have two sub-directories '/Object-samples/0/' and '/Object-samples/1/' which would contain images belonging to that class. $\endgroup$