2

Is there a way to speed up loading a model in Keras? I'm using a transfer-learned inception model. It seems to take 13 seconds to load a model from my experiences.

I want to load deploy some models onto smart phones. Using Tensorflow as backend.

start = time.time()
path = r'C:\Users\Moondra\Desktop\2017-12-20_10.hdf5'
labels = os.listdir(r'C:\Users\Moondra\Desktop\FISHES_MAIN')
model = load_model(path)

print(time.time() - start)

output

12.808000087738037
Moondra
  • 4,399
  • 9
  • 46
  • 104

1 Answers1

2

I found that calling load_model with compile=False sped it up. My times went down from 12-15 seconds to about 2-3 seconds on average.

load_model(path, compile=False)
greenkode
  • 4,001
  • 1
  • 26
  • 29
  • Hmm but then I have to compile it after loading in order to do anythin with my model, don't I? Thus, there would be no benefit.. – Markus Jul 31 '19 at 14:27
  • Little addition to my comment: No, there is no compilation necessary if you just want to predict stuff. Hence, this realy saved me a lot of trouble :) +1 – Markus Aug 08 '19 at 23:13
  • 1
    I don't get any speedup with this solution. – Rexcirus Nov 11 '19 at 18:11