Week 4, Face Recognition Assignment

Can someone help me with running this assignment locally. I am getting some strange error.

from tensorflow.keras.models import model_from_json
json_file = open(‘keras-facenet-h5/model.json’, ‘r’)
loaded_model_json = json_file.read()
model = model_from_json(loaded_model_json)

In the 3rd line of this 6 line code snippet, I am getting an error

ValueError: bad marshal data (unknown type code)

I searched for this on the web. The only thing I was able to understand that this is generally due to a mismatch in versions.

I followed this link, and they seem to be thinking that this is basically due to the Python version. They think that running the pre-trained facenet model requires python 2.7.x, but I checked on Coursera notebook itself, and I found it to be running on python 3.7.x. Any idea or suggestion would be appreciated.

Hi Elemento,

In case you did not yet see this yet, here is another github repo with some pointers. From what I can see it is an issue with versioning of python, keras, and tensorflow.

@reinoudbosch Is the model can be load in Colab? (I haven’t try Colab yet).

Hi kelvinn,

I haven’t tried that either. Why don’t you give it a shot?

Okay. Maybe I’ll try it. Thanks.

How is it? I have the same issue

@Kennychuen I found the solution to it, but it was pretty elaborative. It included setting up a local environment with the exact package versions. So, I replicated my notebook in the Coursera environment only.

Does that mean it is not user-friendly since we dont really use specific old versions to nowadays. Did you manage to find any new and fast ways of loading the files instead?

@Kennychuen Unfortunately, that’s the bad part about pre-trained models. If you need to load the weights, then you need to use the same package versions, unless, the package hasn’t made any major changes.
As of now, I haven’t found a better way to load the models.

1 Like

Hello what are the some of the packages differences? For example tensorflow is 2.3.0 in the coursera server. Are there other packages to take note of?

@Kennychuen I don’t remember the differences actually. I guess you can find it on the repository, from where these model files are taken, for which you need to search on the web, cause as I said, I used the Coursera environment only.