I have a python project where I import keras.models.load_model:
from keras.models import load_model
This causes my project to launch in 3 to 4 seconds, how can I decrease the import time?
CodePudding user response:
Based on the benchmarks from this article, the format in which you save your weights affects how fast your model instantiates and loads saved weights.
It seems that the.h5
format is faster than the SavedModel
format. However, if speed is really paramount to the function of your project then you may want to look at taking one of these steps, although it definitely involves some work:
- Reducing the precision of your model
- Reducing your model size by pruning weights
- Using TensorFlow lite (however note that some models aren't supported)