How can I run my keras model on android devices?

I've created a model for classification task and want to know how to run it on mobile devices. I need a real time or fast model for mobiles.

3 votesLP199.00
2 Answers

Or you can use tensorflow lite, which is made just for mobile devices.

It has a lot of optimization tools, and many other functions for android and iphone mobiles.

You gonna need to convert your keras h5 model to tensorflow pb anyway, cause tensorflow lite comes from tensorflow graph or tensorflow pb file. After converting into tensorflow graph, you just need to call

tflite_convert \
  --output_file=/tmp/foo.tflite \
  --graph_def_file=/tmp/frozen_graph.pb \
  --input_arrays=input \

Command to convert it to tflite.

There are couple of discussions about tensorflow lite here.

  1. Convert pb to tflite
  2. Keras model to tflite

You have to do it with tensorflow. You can convert your keras h5 model to tensorflow pb and run it on android or iphone devices.

First you need to freeze your keras model, which is actualy a tensorflow graph, then convert it to pb file.

Here is a discussion on how to convert keras h5 model into tensorflow pb.

Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?