Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @staticmethod
- def get_embedding(model, face_pixels):
- """
- Normalizes the image and uses the model to produce features.
- input:
- model - The model that creates the features. This should be the FaceNet model
- face_pixels - The cropped face image.
- output:
- yhat - The features for a face. This should produce 128 features with FaceNet.
- """
- face_pixels = face_pixels.astype('float32')
- # standardize pixel values across channels (global)
- mean, std = face_pixels.mean(), face_pixels.std()
- face_pixels = (face_pixels - mean) / std
- # transform face into one sample
- samples = expand_dims(face_pixels, axis=0)
- # make prediction to get embedding
- yhat = model.predict(samples)
- return yhat[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement