3

I have a severe space limitation on my deployment device that mean I cannot fit the entire "Keras" package.

Is there a way to get a prediction from a trained keras model without the entire keras package?

I have noted that the Keras docker is ~1GB. I would need it to be < 650MB

Kevin Glasson
  • 408
  • 2
  • 13
  • You might find some of the answers to [this post](https://stackoverflow.com/questions/36720498/convert-keras-model-to-c) helpful. – IonicSolutions Jul 12 '18 at 05:39
  • Yeah thank you, I've been using one of the libraries on that post an implementing it in cpp. It's just the preprocessing ( creating a spectrogram ) of the input before making a prediction is breaking my brain! so I was wondering if I could get away with doing it in python – Kevin Glasson Jul 12 '18 at 05:47
  • To me this sounds like the problem is creating the spectrogram in C++ then? – IonicSolutions Jul 12 '18 at 05:49
  • Well If there isn't a way to make a prediction without the full Keras package then yep you're right that is my problem – Kevin Glasson Jul 12 '18 at 05:55
  • Perhaps [TensorFlow Lite](https://www.tensorflow.org/mobile/tflite/) is a solution worth looking into? As far as I understand, it allows you to run pre-trained TensorFlow models on mobile devices with about 300KB of library (?). If you can convert your model to pure-TensorFlow, then this should be worth trying. – IonicSolutions Jul 12 '18 at 06:03

1 Answers1

0

I was able to get my docker container small enough by using a different backend when predicting ( theano ) as opposed to tensorflow.

The other solutions I investigated are some C++ libraries, e.g. ( frugally deep, kerasify, keras2cpp ) but the preprocessng of my data became much harder ( for me anyway ). So I went with the theano backend as above!

Of course you could manually do the convolutions for each filter etc in python.. but that would be even harder

Kevin Glasson
  • 408
  • 2
  • 13