# Unable to load the keras-facenet model from local jupyter

**URL:** <https://community.deeplearning.ai/t/unable-to-load-the-keras-facenet-model-from-local-jupyter/38073>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [September 15, 2021, 5:01pm UTC](https://community.deeplearning.ai/t/unable-to-load-the-keras-facenet-model-from-local-jupyter/38073 "2021-09-15T17:01:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![clonesangram](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/clonesangram/32/6421_2.png) [@clonesangram](https://community.deeplearning.ai/u/clonesangram)\
**Post date:** [September 15, 2021, 5:01pm UTC](https://community.deeplearning.ai/t/unable-to-load-the-keras-facenet-model-from-local-jupyter/38073/1 "2021-09-15T17:01:42Z")

</div>

Hi,  
I am facing some error while trying to load the pre-trained model on my local system via jupyter.  
You have used it in course 4(Face recognition)

Can you please let me know which python/keras/tensorflow version you use on this assignment.

Below is the error message:

* * *

ValueError Traceback (most recent call last)  
~\AppData\Local\Temp/ipykernel\_14756/3412463693.py in   
5 json\_file.close()  
6  
----\> 7 model = model\_from\_json(loaded\_json\_model)  
8 model.load\_weights(‘model.h5’)

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\saving\model\_config.py in model\_from\_json(json\_string, custom\_objects)  
102 config = json\_utils.decode(json\_string)  
103 from keras.layers import deserialize # pylint: disable=g-import-not-at-top  
 → 104 return deserialize(config, custom\_objects=custom\_objects)

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\layers\serialization.py in deserialize(config, custom\_objects)  
206 “”"  
207 populate\_deserializable\_objects()  
 → 208 return generic\_utils.deserialize\_keras\_object(  
209 config,  
210 module\_objects=LOCAL.ALL\_OBJECTS,

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\utils\generic\_utils.py in deserialize\_keras\_object(identifier, module\_objects, custom\_objects, printable\_module\_name)  
672  
673 if ‘custom\_objects’ in arg\_spec.args:  
 → 674 deserialized\_obj = cls.from\_config(  
675 cls\_config,  
676 custom\_objects=dict(

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\engine\functional.py in from\_config(cls, config, custom\_objects)  
660 “”"  
661 with generic\_utils.SharedObjectLoadingScope():  
 → 662 input\_tensors, output\_tensors, created\_layers = reconstruct\_from\_config(  
663 config, custom\_objects)  
664 model = cls(inputs=input\_tensors, outputs=output\_tensors,

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\engine\functional.py in reconstruct\_from\_config(config, custom\_objects, created\_layers)  
1271 # First, we create all layers and enqueue nodes to be processed  
1272 for layer\_data in config[‘layers’]:  
 → 1273 process\_layer(layer\_data)  
1274 # Then we process nodes in order of layer depth.  
1275 # Nodes that cannot yet be processed (if the inbound node

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\engine\functional.py in process\_layer(layer\_data)  
1253 from keras.layers import deserialize as deserialize\_layer # pylint: disable=g-import-not-at-top  
1254  
 → 1255 layer = deserialize\_layer(layer\_data, custom\_objects=custom\_objects)  
1256 created\_layers[layer\_name] = layer  
1257

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\layers\serialization.py in deserialize(config, custom\_objects)  
206 “”"  
207 populate\_deserializable\_objects()  
 → 208 return generic\_utils.deserialize\_keras\_object(  
209 config,  
210 module\_objects=LOCAL.ALL\_OBJECTS,

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\utils\generic\_utils.py in deserialize\_keras\_object(identifier, module\_objects, custom\_objects, printable\_module\_name)  
672  
673 if ‘custom\_objects’ in arg\_spec.args:  
 → 674 deserialized\_obj = cls.from\_config(  
675 cls\_config,  
676 custom\_objects=dict(

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\layers\core.py in from\_config(cls, config, custom\_objects)  
1003 def from\_config(cls, config, custom\_objects=None):  
1004 config = config.copy()  
 → 1005 function = cls.\_parse\_function\_from\_config(  
1006 config, custom\_objects, ‘function’, ‘module’, ‘function\_type’)  
1007

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\layers\core.py in \_parse\_function\_from\_config(cls, config, custom\_objects, func\_attr\_name, module\_attr\_name, func\_type\_attr\_name)  
1055 elif function\_type == ‘lambda’:  
1056 # Unsafe deserialization from bytecode  
 → 1057 function = generic\_utils.func\_load(  
1058 config[func\_attr\_name], globs=globs)  
1059 elif function\_type == ‘raw’:

~\Anaconda3\envs\dnnenv2\lib\site-packages\keras\utils\generic\_utils.py in func\_load(code, defaults, closure, globs)  
787 except (UnicodeEncodeError, binascii.Error):  
788 raw\_code = code.encode(‘raw\_unicode\_escape’)  
 → 789 code = marshal.loads(raw\_code)  
790 if globs is None:  
791 globs = globals()

ValueError: bad marshal data (unknown type code)

please advise how to fix it

---

<div class="post-metadata">

**Author:** ![Elemento](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/elemento/32/854_2.png) [@Elemento](https://community.deeplearning.ai/u/Elemento)\
**Post date:** [May 19, 2022, 3:58pm UTC](https://community.deeplearning.ai/t/unable-to-load-the-keras-facenet-model-from-local-jupyter/38073/2 "2022-05-19T15:58:11Z")

</div>

Hey @clonesangram,  
Apologies for the delayed response. A quick way to find out the versions of the packages involved is to do `print(<package>. __version__ )` for all the packages involved. Make sure the packages are imported prior to this. Since the Coursera labs keeps on getting updated, make sure to download the file again since it might have been modified in accordance with the current versions of the packages. I hope this helps.

Regards,  
Elemento
