I'm just attempting to load the model below like you have in README.md,
but am getting the error: " ValueError: bad marshal data (unknown type code)".
These are the version of keras and python that I'm using.
Keras: 2.1.1
Python 3.6.2
Do I need to use a different version of Keras/Python?
from keras.models import load_model
from keras.utils import CustomObjectScope
import tensorflow as tf
with CustomObjectScope({'tf': tf}):
model = load_model('Keras-OpenFace-master/model/nn4.small2.v1.h5')
ValueError Traceback (most recent call last)
in ()
3 import tensorflow as tf
4 with CustomObjectScope({'tf': tf}):
----> 5 model = load_model('Keras-OpenFace-master/model/nn4.small2.v1.h5')
//anaconda/envs/tf/lib/python3.6/site-packages/keras/models.py in load_model(filepath, custom_objects, compile)
238 raise ValueError('No model found in config file.')
239 model_config = json.loads(model_config.decode('utf-8'))
--> 240 model = model_from_config(model_config, custom_objects=custom_objects)
241
242 # set weights
//anaconda/envs/tf/lib/python3.6/site-packages/keras/models.py in model_from_config(config, custom_objects)
312 'Maybe you meant to use '
313 'Sequential.from_config(config)
?')
--> 314 return layer_module.deserialize(config, custom_objects=custom_objects)
315
316
//anaconda/envs/tf/lib/python3.6/site-packages/keras/layers/init.py in deserialize(config, custom_objects)
53 module_objects=globs,
54 custom_objects=custom_objects,
---> 55 printable_module_name='layer')
//anaconda/envs/tf/lib/python3.6/site-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
137 return cls.from_config(config['config'],
138 custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) +
--> 139 list(custom_objects.items())))
140 with CustomObjectScope(custom_objects):
141 return cls.from_config(config['config'])
//anaconda/envs/tf/lib/python3.6/site-packages/keras/engine/topology.py in from_config(cls, config, custom_objects)
2488 # First, we create all layers and enqueue nodes to be processed
2489 for layer_data in config['layers']:
-> 2490 process_layer(layer_data)
2491 # Then we process nodes in order of layer depth.
2492 # Nodes that cannot yet be processed (if the inbound node
//anaconda/envs/tf/lib/python3.6/site-packages/keras/engine/topology.py in process_layer(layer_data)
2474
2475 layer = deserialize_layer(layer_data,
-> 2476 custom_objects=custom_objects)
2477 created_layers[layer_name] = layer
2478
//anaconda/envs/tf/lib/python3.6/site-packages/keras/layers/init.py in deserialize(config, custom_objects)
53 module_objects=globs,
54 custom_objects=custom_objects,
---> 55 printable_module_name='layer')
//anaconda/envs/tf/lib/python3.6/site-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
137 return cls.from_config(config['config'],
138 custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) +
--> 139 list(custom_objects.items())))
140 with CustomObjectScope(custom_objects):
141 return cls.from_config(config['config'])
//anaconda/envs/tf/lib/python3.6/site-packages/keras/layers/core.py in from_config(cls, config, custom_objects)
697 elif function_type == 'lambda':
698 # Unsafe deserialization from bytecode
--> 699 function = func_load(config['function'], globs=globs)
700 else:
701 raise TypeError('Unknown function type:', function_type)
//anaconda/envs/tf/lib/python3.6/site-packages/keras/utils/generic_utils.py in func_load(code, defaults, closure, globs)
198 if isinstance(defaults, list):
199 defaults = tuple(defaults)
--> 200 code = marshal.loads(code.encode('raw_unicode_escape'))
201 if globs is None:
202 globs = globals()
ValueError: bad marshal data (unknown type code)