Sattawat
Sattawat

Reputation: 149

code = marshal.loads(raw_code) ValueError: bad marshal data (unknown type code)

Running flexget Python script I get an error:

Traceback (most recent call last):
File "D:\project\facenet3\FaceRecognition_SVM_Classifier.py", line 51, in <module>
    model = load_model('D:/project/facenet3/facenet_keras.h5')
  File "C:\Users\tueku\Envs\facenet5\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "C:\Users\tueku\Envs\facenet5\lib\site-packages\keras\utils\generic_utils.py", line 793, in func_load
    code = marshal.loads(raw_code)
ValueError: bad marshal data (unknown type code)

Upvotes: 0

Views: 7510

Answers (1)

Alexander Pacha
Alexander Pacha

Reputation: 9740

This typically happens when you save a model in one Python version (e.g., 3.6) and then try to load that model in another Python version (e.g., 3.9), as the binary serialization that Keras uses (marshal) is not upwards/downwards compatible. Try to install an old version of Python with an appropriate version of the Tensorflow / Keras libraries. If the model was not trained by yourself, you may ask the creators to export the trained models in a different format that doesn't have these problems, like ONNX.

Upvotes: 2

Related Questions