-1

I built a CNN model for image classification using the Keras library. However training takes many hours. Once I trained my model, how can I use it without training once more? I mean after I trained my model, I want to use it many times. Because I will use my model in android studio. Any help is appreciated

Thank YOU...

EDIT

When I wrote this question, I did not know the save model and load.model, in the answers you see the appropriate usage of them.

Community
  • 1
  • 1
GhostDede
  • 438
  • 3
  • 15
  • 3
    Possible duplicate of [How to save final model using keras?](https://stackoverflow.com/questions/42763094/how-to-save-final-model-using-keras) – Jordan Singer Mar 15 '19 at 20:07
  • I could not find it before I post my question, after you wrote I realized that. Sorry – GhostDede Mar 15 '19 at 22:43

1 Answers1

3

You can easily save your model after the training process by using:

model.save('my_model.h5')

you can later load that model by using:

model = load_model('my_model.h5')

for more details have a look at the documentation: https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model

SerAlejo
  • 473
  • 2
  • 13
  • Thank you very much, it really helped. – GhostDede Mar 15 '19 at 22:42
  • Is there any documentation for the using the model inside of the mobile application. Because ı need to use my model in mobile phone. Thank you – GhostDede Mar 20 '19 at 23:27
  • @GhostDede I couldn't find a detailed documentation, but there are many examples how to use it on mobile. You will have to build a tensorflow model out of your keras model first. Check out this answer: https://stackoverflow.com/questions/45874245/keras-deep-learning-model-to-android On of the links is broken (1. answer), here is the fixed link: https://github.com/amir-abdi/keras_to_tensorflow/blob/master/keras_to_tensorflow.py – SerAlejo Mar 21 '19 at 09:10
  • Thank you very much, I will check them. – GhostDede Mar 21 '19 at 17:50