Course 4 Week 3 A1 YOLO Car detection - Model load "IndexError: Read fewer bytes than requested"


after completing the assignment, i downloaded the whole workspace and ran it in a virtual environment with the same package versions as in Coursera.

It works up to the cell:

yolo_model = load_model(“model_data/”, compile=False)

which throws the following error.
In my local directory all files are present with the same files sizes, like in Coursera.

Any ideas on where to look to make it run?

IndexError Traceback (most recent call last)
----> 1 yolo_model = load_model(“model_data/”, compile=False)

C:\ProgramData\Anaconda3\envs\coursera_env\lib\site-packages\tensorflow\python\keras\saving\ in load_model(filepath, custom_objects, compile, options)
185 if isinstance(filepath, six.string_types):
186 loader_impl.parse_saved_model(filepath)
→ 187 return saved_model_load.load(filepath, compile, options)
189 raise IOError(

C:\ProgramData\Anaconda3\envs\coursera_env\lib\site-packages\tensorflow\python\keras\saving\saved_model\ in load(path, compile, options)
120 model = tf_load.load_internal(
→ 121 path, options=options, loader_cls=KerasObjectLoader)
123 # pylint: disable=protected-access

C:\ProgramData\Anaconda3\envs\coursera_env\lib\site-packages\tensorflow\python\saved_model\ in load_internal(export_dir, tags, options, loader_cls)
631 try:
632 loader = loader_cls(object_graph_proto, saved_model_proto, export_dir,
→ 633 ckpt_options)
634 except errors.NotFoundError as err:
635 raise FileNotFoundError(

C:\ProgramData\Anaconda3\envs\coursera_env\lib\site-packages\tensorflow\python\keras\saving\saved_model\ in init(self, *args, **kwargs)
192 self._models_to_reconstruct =
→ 194 super(KerasObjectLoader, self).init(*args, **kwargs)
196 # Now that the node object has been fully loaded, and the checkpoint has

C:\ProgramData\Anaconda3\envs\coursera_env\lib\site-packages\tensorflow\python\saved_model\ in init(self, object_graph_proto, saved_model_proto, export_dir, ckpt_options)
130 self._load_all()
→ 131 self._restore_checkpoint()
133 for node in self._nodes:

C:\ProgramData\Anaconda3\envs\coursera_env\lib\site-packages\tensorflow\python\saved_model\ in _restore_checkpoint(self)
326 if self._expect_partial_checkpoint:
327 load_status = saver.restore(variables_path,
→ 328 self._checkpoint_options).expect_partial()
329 else:
330 load_status = saver.restore(variables_path, self._checkpoint_options)

C:\ProgramData\Anaconda3\envs\coursera_env\lib\site-packages\tensorflow\python\training\tracking\ in restore(self, save_path, options)
1280 dtype_map = reader.get_variable_to_dtype_map()
1281 try:
→ 1282 object_graph_string = reader.get_tensor(base.OBJECT_GRAPH_PROTO_KEY)
1283 except errors_impl.NotFoundError:
1284 # The object graph proto does not exist in this checkpoint. Try the

C:\ProgramData\Anaconda3\envs\coursera_env\lib\site-packages\tensorflow\python\training\ in get_tensor(self, tensor_str)
68 try:
69 return CheckpointReader.CheckpointReader_GetTensor(
—> 70 self, compat.as_bytes(tensor_str))
71 # TODO(b/143319754): Remove the RuntimeError casting logic once we resolve the
72 # issue with throwing python exceptions from C++.

IndexError: Read fewer bytes than requested

Hi Ingmar,

It looks like a preprocessing or memory issue. Either something went wrong preparing the right files (in case you didn’t do so already you might try downloading the files in the model_data directory individually so as to make sure the files are correct - there are not that many files), or you ran out of memory for some reason during model construction. I saw a few threads about the latter, but no real solutions besides saving space by cleaning up unnecessarily used memory/disk space.

I wish I could be of more help.

Can you tell me where I can get yolo_anchors.txt file

Try looking in