0

What are the preprocessing steps that need to be done to train a finetuned VGG model with pretrained VGGFace weights ?

I am trying to fit an array of images of size 224x224x3 into my finetuned VGG model (freezed last 4 layers of the network), and added some Dense layers on top of it. Training takes a lot of time, but the resultant accuracy I get is very low less than 1% accuracy, and the model never learns at all.

I have used this:

vgg16.preprocess_input(img_array)

I expect my model to learn atleast if not give a good accuracy. What could I be doing wrong ?

Amruth Lakkavaram
  • 1,467
  • 1
  • 9
  • 12

1 Answers1

0

You can look the exact preprocessing logic up on github. For VGG16, the general-purpose preprocessing function for imagenet is used. You can find the function here. It is quite verbose because it works both on numpy arrays and on tensors, but what is does is described in the docstring:

x: Input Numpy or symbolic tensor, 3D or 4D.
    The preprocessed data is written over the input data
    if the data types are compatible. To avoid this
    behaviour, `numpy.copy(x)` can be used. data_format: Data format of the image tensor/array. mode: One of "caffe", "tf" or "torch".
    - caffe: will convert the images from RGB to BGR,
        then will zero-center each color channel with
        respect to the ImageNet dataset,
        without scaling.
    - tf: will scale pixels between -1 and 1,
        sample-wise.
    - torch: will scale pixels between 0 and 1 and then
        will normalize each channel with respect to the
        ImageNet dataset.
sdcbr
  • 7,021
  • 3
  • 27
  • 44