i can load my deep model in colab bu when i want load that model in pc i can't

Viewed 260

I trained a deep model in colab by keras=2.3.1 and tensorflow=2.1.0, I saved my model with JSON and Keras:

saveWeightPath = "/content/drive/My Drive/model_info/model_weights.h5"
saveModelPath = "/content/drive/My Drive/model_info"
model.save_weights(saveWeightPath)
tf.keras.models.save_model(model, saveModelPath)

and my cose for saved json

model_json = model.to_json()
with open("model.json", "w") as json_file:
json_file.write(model_json)
model.save_weights("model.h5")
print("Saved model to disk")

when I want load model in colab I don't have a problem but when I want to load my model in pc local I can't and I get this error: "

  • fid = h5f.open(name, 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 88, in h5py.h5f.open OSError: Unable to open file (unable to open file: name = 'C:/Users/Kosar 37638090/Desktop/end pro/model_info', errno = 13, error message = 'Permission denied', flags = 0, o_flags = 0)

"

  1. my Keras and tensor version is the same as my colab Keras and tensor version

  2. I try to load my model with JSON and Keras in pc

  3. I get a traceback error and I copy The last 5 lines of the error message and the top lines here3

     top lines of error

1 Answers

Hi first of all do you need to store your model or your model weights? To know the difference between that, model.save() save you weights and structure model and ... but model.save_weights() just save your weight model, I suggest you see this link for more information.

If you want to save the model, I suggest using model.save("test.hd5") or model.save(test.hdf5") and use tensorflow.kears.models.load_model("test.hd5") to load the model.

Related