1
$\begingroup$

I tried to run a project from repo and got the following log which, I believe, tells a problem with weights load.

python3 main.py
Traceback (most recent call last):
File "main.py", line 66, in <module>
yolo = YOLO()
File "/home/matalan/venv/survalance/Traffic-Survalance/ObjectDetection.py", line 32, in __init__
self.model = self._get_model()
File "/home/matalan/venv/survalance/Traffic-Survalance/ObjectDetection.py", line 39, in _get_model
return load_model(self.model_path)
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/saving/save.py", line 182, in load_model
  return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
File "/home/matalan/.local/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/matalan/.local/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/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/layers/serialization.py", line 171, in deserialize
  return generic_utils.deserialize_keras_object(
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/utils/generic_utils.py", line 354, in 
  deserialize_keras_object
return cls.from_config(
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/engine/training.py", line 2238, in from_config
return functional.Functional.from_config(
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/engine/functional.py", line 616, in from_config
  input_tensors, output_tensors, created_layers = reconstruct_from_config(
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/engine/functional.py", line 1204, in 
  reconstruct_from_config
 process_layer(layer_data)
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/engine/functional.py", line 1186, in process_layer
layer = deserialize_layer(layer_data, custom_objects=custom_objects)
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/layers/serialization.py", line 171, in deserialize
return generic_utils.deserialize_keras_object(
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/utils/generic_utils.py", line 354, in 
  deserialize_keras_object
return cls.from_config(
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/layers/core.py", line 1005, in from_config
function = cls._parse_function_from_config(
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/layers/core.py", line 1057, in 
  _parse_function_from_config
function = generic_utils.func_load(
File "/home/matalan/.local/lib/python3.8/site- 
  packages/tensorflow/python/keras/utils/generic_utils.py", line 457, in func_load
code = marshal.loads(raw_code)
ValueError: bad marshal data (unknown type code)

I use python 3.8.5 and latests TF & Keras for cpu. Is there a way to fix it? (load other weights or smth)

$\endgroup$
6
  • $\begingroup$ Can you add which repo is this and what version of Python it used? Marshaling error means corruption of the saved weight data. It can happen due to version mismatches between saving and reading or actual corruption of the data. Is there a checksum for the original saved data that you can verify to know there's no corruption? $\endgroup$
    – hssay
    May 20, 2021 at 5:38
  • $\begingroup$ @hssay, I can't tell which version of Python is used there as there is even no requirements file. github.com/azhartalha/… $\endgroup$
    – Michael
    May 20, 2021 at 5:42
  • $\begingroup$ In that case I think you are out of luck. Maybe you can contact the repo owner to see how to resolve this (provide correct weights data, specify versions or give you a checksum that will let you verify there's no data corruption in transit ) :-P . $\endgroup$
    – hssay
    May 20, 2021 at 5:46
  • $\begingroup$ @hssay, Can I download another .h5 file and load it to the model? $\endgroup$
    – Michael
    May 20, 2021 at 5:47
  • $\begingroup$ I am not sure about this particular model. If someone else has released their model as h5 file maybe worth a try. $\endgroup$
    – hssay
    May 20, 2021 at 5:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.