TensorFlow library does not support the old facenet.h5 model, do the following steps to avoid the 'bad marshal error': | 一见知得 | Mr J Blog

TensorFlow library does not support the old facenet.h5 model, do the following steps to avoid the 'bad marshal error':

Mr J 3324 0
1. install keras-facenet if you are not using COLAB

     pip install keras-facenet

2. add this code to your program:

    from keras_facenet import FaceNet

3. Change the way to load facenet:

    #MyFaceNet = load_model('facenet_keras.h5') -- delete this line and replace with the one below
    MyFaceNet = FaceNet()

4. The normalization process is no longer needed. Change 'predict' with 'embeddings':

    #face = face.astype('float32')                     -- delete this line
    #mean, std = face.mean(), face.std()        -- delete this line
    #face = (face - mean) / std                          -- delete this line

    face = expand_dims(face, axis=0)
    #signature = MyFaceNet.predict(face)     -- delete this line and replace with this code:
    signature = MyFaceNet.embeddings(face)



1. (since 2022, this step is no longer needed, see the change above) Make sure the facenet_keras.h5 is downloaded from the drive of  Hiroki Taniai model as in the video (other facenet_keras.h5 model might not work in this setting)
2. All the python files can be downloaded from the following link:
https://github.com/nemuelpah/Face-Rec...

Click on CC to activate the English subtitle.
发表评论
表情 图片 链接 代码

分享
微信
微博
QQ