Advertisement
Guest User

zscore_transform

a guest
Nov 14th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. @staticmethod
  2. def get_embedding(model, face_pixels):
  3. """
  4. Normalizes the image and uses the model to produce features.
  5.  
  6. input:
  7. model - The model that creates the features. This should be the FaceNet model
  8. face_pixels - The cropped face image.
  9.  
  10. output:
  11. yhat - The features for a face. This should produce 128 features with FaceNet.
  12. """
  13. face_pixels = face_pixels.astype('float32')
  14. # standardize pixel values across channels (global)
  15. mean, std = face_pixels.mean(), face_pixels.std()
  16. face_pixels = (face_pixels - mean) / std
  17. # transform face into one sample
  18. samples = expand_dims(face_pixels, axis=0)
  19. # make prediction to get embedding
  20. yhat = model.predict(samples)
  21. return yhat[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement