IndexError: Read fewer bytes than requested while loading yolo_model

In Yolo assignment I wanted to run the yolo pretrained model on my local computer using…

from tensorflow.keras.models import load_model
yolo_model = load_model("./model_data/", compile=False)

I have already downloaded the model_data file into my computer , so this should be working ,
but I am getting error as:-
IndexError: Read fewer bytes than requested
here is the screenshot of error,

Anyone knows how to solve this?

I have downloaded the whole yolo assignment project directory on my local computer but the problem still persists…

Hi Aman,

It looks like a memory issue with your local computer. Unfortunately, there’s not much the course developers or mentors can do about that…

1 Like

I am not sure if its memory issue, I have Nvidia Graphics card in my system,

Can you just run once this assignment locally to confirm if it is an issue from my side only or a general issue.

Hi Aman,

I just loaded the model on my own computer without any problems. Did you include the rest of the environment of the assignment into your local working environment?

1 Like

Good point. Also note that means having compatible versions of the whole nine yards worth of python libraries and packages required.

Also note that merely having a powerful graphics card in your computer does nothing to enhance your main memory. All input data must be read into main memory first before the graphics card even gets access do it. And that doesn’t happen until you fire up CUDA, right?

1 Like

Hi thanks for the reply,
I have CUDA and CUDNN enabled, probably it is issue of incompatible version of python libraries.

Because in Face Recognition assignment ,my machine, with latest version of python i.e 3.9 was showing error while reading the model.json file , So I created separate environment with lower version of python that is 3.7.6 and tensorflow with 2.5.0 and it was able to read the json file.

Now when I am running Yolo project in this environment(python 3.7.6 and tensorflow 2.5.0), I am getting following error:-
WARNING:tensorflow:SavedModel saved prior to TF 2.5 detected when loading Keras model. Please ensure that you are saving the model with or tf.keras.models.save_model(), *NOT* To confirm, there should be a file named "keras_metadata.pb" in the SavedModel directory.
along with:-
IndexError: Read fewer bytes than requested

Can you tell me with which version of python and tensorflow this yolo assignment is compatible with or was made on?

Here is the screenshot of issue:-

Hi Aman,

The tensorflow version in the assignment is 2.3.0. The Python version is 3.7.6.

1 Like

I have installed tensorflow 2.3.0 and python 3.7.6 but it is not compatible with the yolo project.

from tensorflow.python.framework.ops import EagerTensor
shows error:-
ModuleNotFoundError: No module named 'tensorflow.python.framework.ops'

Hi again Aman,

On my local computer I am using Python 3.8.3 and Tensorflow 2.4.1, which makes the yolo assignment work like a charm. I also included all relevant files from the assignment in my local environment. You could try that.

If that does not work, you may need to work on your local configuration (maybe some reinstalls?).

Good luck!

1 Like

How can one know the memory/HW requirements to be able to load the saved model?