If image data is scaled (0-1) at the input of a CNN image model as follows:
layers.experimental.preprocessing.Rescaling(1.0/255)
after the model is built and saved, will every image that is fed to the predict() method, also need to be scaled as such, or is this strictly for training purposes?
Hi @Nader_Afshar, Once you have defined pre processing layers in the model architecture the same pre processing will be applied for the data that is passed during prediction also. Thank You.
@Kiran_Sai_Ramineni so I would not need to preprocess any new image I collect form the web before feeding to the model? since the model has preprocessing steps for both resizing and rescaling?
If this is correct, then I can just feed any image to the model, making the process far simpler than I had though !!
@Kiran_Sai_Ramineni - Ok I tested this assumption and it does not quite work. If I try to feed the model an image that is not (256, 256), it complains about image size, so resizing is required even though it is part of the model already.
Actually this does make sense since after the model is created, all we have is a collection of static weights. Nothing else. It is not a “pipe line” that can take an image and take it through every step of model definition. It simply applies the saved weights to the new image data. This means every new input must be preprocessed as training data.