I want to implement Facenet on my laptop, but when I load the model, I get an error. I have already downloaded the model.json file, but I don’t know what the error is.

Does that same code work if you run it on the course website? The reason I ask is that one thing to check is that this is not a version incompatibility issue with TF. The course runs a pretty old version of TF in most of the notebooks (2.3), although some of them were recently upgraded to 2.9.

Note that the code that does that in the Face Recognition assignment looks a bit different:

from tensorflow.keras.models import model_from_json

json_file = open('keras-facenet-h5/model.json', 'r')
loaded_model_json =
model = model_from_json(loaded_model_json)

So why did you make those changes? Why use TF v1? Most people think “eager mode” is a big win. :nerd_face:

The other major thing to note there is that the course notebook uses a local copy of the model JSON file, whereas you are using the version loaded directly from Keras.

Hi @Areeg_Fahad ,

To add on top of what Paul mentioned, bad Marshall error occurs when there is incompatibility issues, as in, the assignment that is on Coursera uses specific python and TF version, which I believe is different than the one you are using.

Also, the model, either the one on coursera or keras, have been trained and saved using specific TF versions and they can’t really be used with another version. I believe the assignment model was done using TF 2.4, so you can’t really load it with latest TF version, or as Paul suspects you are using, with TF v1.

Additionally, another thing to keep in mind is, even if you load TF v1 version from keras, all other library packages and python versions should be the same or closer to as the ones which were used for the model.


Hello @Areeg_Fahad! Yes, bad marshal error is very bad and occurs when we have compatibility issue. Our mentor Raymond discussed alternate way here.


1 Like

It worked perfectly. Thank you. @saifkhanengr :pray:

I am glad it worked for you…