Search code examples
tensorflowkerasgoogle-colaboratory

How should I deploy the trained model from google colab to my computer


I am using Google Colaboratory for training my model through a dataset that I have uploaded to colab.research.google.com. After completing my training process I want to use the trained parameters in my local PC and create the same model with trained values locally. What procedure should I follow?


Solution

  • You need to connect your notebook to your google drive by:

    from google.colab import drive
    drive.mount('/content/gdrive')
    

    then after training, save your trained model as:

    model.save("/content/gdrive/My Drive/name_of_your_model.h5")
    

    Open your google drive, download the saved file name_of_your_model.h5. Then on your local pc load the model

    from keras.models import load_model
    model = load_model(<path to your model file on local machine>)
    

    Now you have the trained model on your local pc