2
votes
File "train.py", line 43, in <module>
    FR=FR_model()
  File "/home/arsh/Desktop/machine learning/Outlier_dataset/Face_recognition.py", line 19, in __init__
    self.model = load_model('Facenet/facenet_model.h5')
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/saving/save.py", line 184, in load_model
    return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 177, in load_model_from_hdf5
    model = model_config_lib.model_from_config(model_config,
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/saving/model_config.py", line 55, in model_from_config
    return deserialize(config, custom_objects=custom_objects)
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/layers/serialization.py", line 105, in deserialize
    return deserialize_keras_object(
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 369, in deserialize_keras_object
    return cls.from_config(
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/engine/network.py", line 986, in from_config
    input_tensors, output_tensors, created_layers = reconstruct_from_config(
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/engine/network.py", line 2019, in reconstruct_from_config
    process_layer(layer_data)
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/engine/network.py", line 2001, in process_layer
    layer = deserialize_layer(layer_data, custom_objects=custom_objects)
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/layers/serialization.py", line 105, in deserialize
    return deserialize_keras_object(
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 369, in deserialize_keras_object
    return cls.from_config(
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/layers/core.py", line 990, in from_config
    function = cls._parse_function_from_config(
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/layers/core.py", line 1042, in _parse_function_from_config
    function = generic_utils.func_load(
  File "/home/arsh/.virtualenvs/conditional_slim_gan/lib/python3.8/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 471, in func_load
    code = marshal.loads(raw_code)
ValueError: bad marshal data (unknown type code)

I am trying to load a pre-trained keras model from .h5 file using the code- self.model = load_model('Facenet/facenet_model.h5').

The code runs smoothly on google colab, however when I run it locally it throws the above error, even when my tensorflow and keras are up to date.

To reproduce the error, please navigate to Face_recognition.py on my github repository.

1

1 Answers

2
votes

If you look at the source code for generic_utils.py:

https://github.com/keras-team/keras/blob/master/keras/utils/generic_utils.py

you'll see there is no line 471, so you seem to be running some old instance of keras and that might not be compatible with data generated with an newer (or just different) version.