Unable to open file (truncated file: eof = 7340032, sblock->base_addr = 0, stored_eof = 126651688)

Question:

I trained my model in Google colab and then saved it using model1.save('thebestonesofar57block5.h5'). After that I downloaded the file to my windows machine. After uploading it to a new google colab session, I’m getting the following error, using:

from keras.models import load_model

Loaded_model = load_model('thebestonesofar57block5.h5')

Error:

OSError: Unable to open file (truncated file: eof = 7340032,
sblock->base_addr = 0, stored_eof = 126651688)

Asked By: Umair Javaid

||

Answers:

In my case somehow the .h5 file was corrupted or erroneous so I downloaded it again and voila it worked

Answered By: kanishk verma
GG_Weights_path = keras.utils.get_file(
pretrained_url.split("/")[-1], pretrained_url)
print(VGG_Weights_path)
Answered By: Elvin Aghammadzada

This happens either the weights file is corrupt or not downloaded properly.

Answered By: Umang Maheshwari

This is obviously because of a corrupted or partially downloaded .h5 file. I have faced a similar issue recently. To fix this issue you should have a complete .h5 file with you. Then follow the steps

OSError Traceback (most recent call
last) in
4
5 model =tf.keras.models.load_model(r’E:new_model’)
—-> 6 model_2 = VGGFace(model=’resnet50′, include_top=False, input_shape=(224, 224, 3), pooling=’avg’)
7
8 def crime_detection():

E:softwarecondaenvsfinallibsite-packageskeras_vggfacevggface.py
in VGGFace(include_top, model, weights, input_tensor, input_shape,
pooling, classes)
92 ‘ as true, classes should be 8631′)
93
—> 94 return RESNET50(include_top=include_top, input_tensor=input_tensor,
95 input_shape=input_shape, pooling=pooling,
96 weights=weights,

**E:softwarecondaenvsfinallibsite-packageskeras_vggfacevggface.py**

in VGGFace(include_top, model, weights, input_tensor, input_shape,
pooling, classes)
92 ‘ as true, classes should be 8631′)
93
—> 94 return RESNET50(include_top=include_top, input_tensor=input_tensor,
95 input_shape=input_shape, pooling=pooling,
96 weights=weights,

step:1 go to this python file E:softwarecondaenvsfinallibsite-packageskeras_vggfacevggface.py
you will find modules list

step2: open modules.py, you will find the function used to load weight. Use print to find where the .h5 model was downloaded by the program.
finding path I have used printed the path using print(weights_path)

step3: Once you get the location replace the old model with the new one that you have downloaded

Answered By: Dcode

Make sure that the directory you are working in is the same as the directory where the .h5 file is located.

Answered By: ebruk