sorry to bother you. I am a fresh hand for face recognition and keras. I want to use your Feature Extraction
code to get the face feature in FC7. But I find the most elements of the FC7 feature are zero. Is this right?
below is my code:
from keras.engine import Model
from keras.layers import Input
from keras_vggface import VGGFace
import numpy as np
from keras.preprocessing import image
image_input = Input(shape=(224, 224, 3))
# for theano uncomment
# image_input = Input(shape=(3,224, 224))
# Convolution Features
#vgg_model_conv = VGGFace(include_top=False, pooling='avg') # pooling: None, avg or max
#vgg_model_conv = VGGFace(include_top=False) # pooling: None, avg or max
# FC7 Features
vgg_model = VGGFace() # pooling: None, avg or max
out = vgg_model.get_layer('fc7').output
#vgg_model_fc7 = Model(image_input, out)
vgg_model_fc7 = Model(vgg_model.input, out)
# Change the image path with yours.
img = image.load_img('images/chip_2.png', target_size=(224, 224))
print type(img)
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
# TF order aka 'channel-last'
x = x[:, :, :, ::-1]
# TH order aka 'channel-first'
# x = x[:, ::-1, :, :]
# Zero-center by mean pixel
x[:, 0, :, :] -= 93.5940
x[:, 1, :, :] -= 104.7624
x[:, 2, :, :] -= 129.1863
vgg_model_fc7_preds = vgg_model_fc7.predict(x)
print vgg_model_fc7_preds[0]