Linked Questions

Popular Questions

Unable to load model created in Google Colaboratory

Asked by At

I had trained a CNN using Keras in Google Colab, but, after downloading the model, I am not able to load the hdf5 file in my local system ( Windows ).

I have done this before, and never had any issue. This is the error that I am getting.

Traceback (most recent call last):
  File "D:/Work/binary-face-recognition/", line 27, in <module>
    model = load_model('model.hdf5')
  File "C:\Users\PARTHA.N\AppData\Local\Continuum\anaconda3\envs\face\lib\site-packages\keras\engine\", line 417, in load_model
    f = h5dict(filepath, 'r')
  File "C:\Users\PARTHA.N\AppData\Local\Continuum\anaconda3\envs\face\lib\site-packages\keras\utils\", line 186, in __init__ = h5py.File(path, mode=mode)
  File "C:\Users\PARTHA.N\AppData\Local\Continuum\anaconda3\envs\face\lib\site-packages\h5py\_hl\", line 312, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
  File "C:\Users\PARTHA.N\AppData\Local\Continuum\anaconda3\envs\face\lib\site-packages\h5py\_hl\", line 142, in make_fid
    fid =, flags, fapl=fapl)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5f.pyx", line 78, in
OSError: Unable to open file (truncated file: eof = 38486016, sblock->base_addr = 0, stored_eof = 72708080)

For loading the model, I'm doing a base load_model call

from keras.models import load_model
model = load_model('model.hdf5')

To save & download the model from Google Colab I'm using the following snippet.

# save model'model.hdf5')

# download model
from google.colab import files'model.hdf5')

I get the following error in Google colb at the line after the file is downloaded.

Exception happened during processing of request from ('::ffff:', 47132, 0, 0)
Traceback (most recent call last):
  File "/usr/lib/python3.6/", line 317, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.6/", line 348, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.6/", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.6/", line 721, in __init__
  File "/usr/lib/python3.6/http/", line 418, in handle
  File "/usr/lib/python3.6/http/", line 406, in handle_one_request
  File "/usr/lib/python3.6/http/", line 639, in do_GET
    self.copyfile(f, self.wfile)
  File "/usr/lib/python3.6/http/", line 800, in copyfile
    shutil.copyfileobj(source, outputfile)
  File "/usr/lib/python3.6/", line 82, in copyfileobj
  File "/usr/lib/python3.6/", line 800, in write
ConnectionResetError: [Errno 104] Connection reset by peer

Related Questions