I have fine tuned the Keras VGG16 model, but I'm unsure about the preprocessing during the training phase.
I create a train generator as follow:
train_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(
train_folder,
target_size=(IMAGE_SIZE, IMAGE_SIZE),
batch_size=train_batchsize,
class_mode="categorical"
)
Is the rescale enough or I have to apply others preprocessing functions?
When I use the network to classify an image I use this code:
from keras.models import load_model
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input
import numpy as np
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
preds = model.predict(x)
I think this is the correct preprocess and I should apply it before training.
Thanks for your help.