rcmalli/keras-vggface

How to extract feature in VGG16 for a test image?

Opened this issue · 0 comments

it has a way to extract the features of a pretrained model:
vgg_model = VGGFace() # pooling: None, avg or max
out = vgg_model.get_layer('fc7').output
vgg_model_fc7 = Model(vgg_model.input, out)
img = image.load_img(imagepath, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = x[:, :, :, ::-1]
vgg_model_fc7_preds = vgg_model_fc7.predict(x)
print(vgg_model_fc7_preds[0])
Is predict (before last line) a tool for feature extraction (for getting output of layer) or for prediction of user?
If it is for feature extraction, why name it "predict" ?