Skip to content Skip to sidebar Skip to footer

Unable To Load .h5 File Made In Google Colab To Jupyter Notebook

I tried a code for Face mask detect and alert system and I am getting an error regarding the same. I trained the model in Google Collaboratory and ran the following code in Jupyter

Solution 1:

Seems the issue is similar as mentioned in this stackoverflow question. already.

As the accepted answer here mentions that the exported model may be from tf.keras and not keras directly :

"Don't import keras directly as your model is saved with Tensorflow's keras high level api. Change all your imports to tensorflow.keras".

My suggestion:

1.You should try to use tf.keras for all keras imports

  1. And also as Mohammad mentions in the answer , use compile=False in load_model.

  2. Check the version of tf and keras in colab and local environment.Both versions need to be same.

From Keras github issues regarding this.

Solution 2:

I think the version of TensorFlow that you used to train and save your model is different than the one that you are using to load the model.

Try compile=False while loading your model:

#Load trained deep learning modelmodel = load_model('face_mask_detection_alert_system.h5', compile=False)

Post a Comment for "Unable To Load .h5 File Made In Google Colab To Jupyter Notebook"