Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to predict input image with trained model in Keras?

I am building a CNN model with Keras and tensorflow backend. I've trained the model for 6 hours. Now, I want to predict my custom external image using my model. How to do that in Keras? Thank you

like image 607
Justinus Hermawan Avatar asked Nov 02 '16 14:11

Justinus Hermawan


1 Answers

To simplify, you could say there is usually 4 main steps when working with models (not just in Keras) :

  • building the model and compiling it : model.compile()
  • training the model with your training data : model.fit()
  • evaluating the model with your test data : model.evaluate()
  • making predictions with your target data : model.predict()

Depending on which output you need, you will have to use model.predict_proba() or model.predict_classes().

See https://keras.io/models/sequential/#sequential-model-methods for complete reference and arguments.

Keras repository has also plenty of examples : https://github.com/fchollet/keras/tree/master/examples

like image 58
Gaarv Avatar answered Sep 22 '22 19:09

Gaarv