I have trained the CNN to classify images on 3 class. while training the model i have used ImageDataGenerator class from keras to apply preprocessing function on image and rescale it. Now my network is trained with a good accuracy on test set, but i don't know how to apply preprocessing function on single image prediction. If i use ImageDataGenerator it looks for directory. Suggest me some alternatives to do preprocessing function and rescaling on single image. see my code below
TRAINING SET:
train_datagen = ImageDataGenerator(preprocessing_function = tf.keras.applications.vgg16.preprocess_input,
rescale = 1./255,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip = True)
training_set = train_datagen.flow_from_directory('./training_set',
target_size = (224, 224),
batch_size = 10,
class_mode = 'categorical')
TESTING SET:
test_datagen =ImageDataGenerator(preprocessing_function=tf.keras.applications.vgg16.preprocess_input,
rescale = 1./255)
test_set = test_datagen.flow_from_directory('./test_set',
target_size = (224, 224),
batch_size = 10,
shuffle=False,
class_mode = 'categorical')
Now,im unable to apply preprocessing function and rescaling on single image before prediction. SINGLE PREDICTION:
single_datagen = ImageDataGenerator(preprocessing_function=tf.keras.applications.vgg16.preprocess_input,
rescale = 1./255)
single_test = single_datagen.flow_from_directory('./single_prediction/cc.jpg',
target_size = (224, 224),
batch_size = 1,
class_mode = 'categorical')
ERROR: NotADirectoryError: [Errno 20] Not a directory: './single_prediction/cc.jpg'