Intro
I’d like to add to olejorgenb’s answer – for a specific scenario, where you don’t want to train the model, just use it (e.g. in production).
“Compile” means “prepare for training”, which includes mainly setting up the optimizer. It could also have been saved before, and then you can continue the “same” training after loading the saved model.
The fix
But, what about the scenario – I want to just run the model? Well, use the compile=False argument to load_model like that:
trained_model = load_model('model.h5', compile=False)
You won’t be able to .fit() this model without using trained_model.compile(...) first, but most importantly – the warning will go away.
Misc Notes
Btw, in my Keras version, the argument include_optimizer has a default of True. This should work also for trainig callbacks like Checkpoint. This means, when loading a model saved by Keras, you can usually count on the optimizer being included (except for the situation: see Hull Gasper’s answer).
But, when you have a model which was not trained by Keras (e.g. when converting a model trained by Darknet), the model is saved un-compiled. This produces the warning, and you can get rid of it in the way described above.