Keras on Android

3,483 views
Skip to first unread message

Tammy Yang

unread,
May 10, 2016, 11:14:29 PM5/10/16
to Keras-users
Hi,

My friends and I are trying to port Keras to Android. The goal is to make the model run without modifying the source code. We haven't see much discussion about making Keras model running on Android or iOS. Do anyone know interesting projects or discussion on the web related to it?

Many thanks,
Tammy

François Chollet

unread,
May 11, 2016, 12:34:39 AM5/11/16
to Tammy Yang, Keras-users
Hi Tammy,

The TensorFlow runtime is supported by Android, and there is also experimental support for iOS. So the quickest way to get a Keras model running on a mobile device would be via the TensorFlow runtime.

What are your plans? I'd love to know more.


--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/dd17acb5-7704-4129-bf9f-f99ddbac9af3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ba...@dt42.io

unread,
May 11, 2016, 11:46:27 AM5/11/16
to Keras-users
Hi François,

I am Tammy's colleague.  Our plan is to port the code related to prediction process in Keras (without the need of considering training process).  Since I can successfully build the Android example of TensorFlow, the backend might not be a huge concern at the mean time.  Some dependencies (numpy, hdf5, etc.) has been ported, but it is still a huge effort to port Keras to Android.  Is there any official plan to port Keras on mobile platforms, or is there anyone else doing the same work?

Thanks,
Bafu

François Chollet

unread,
May 11, 2016, 12:10:27 PM5/11/16
to ba...@dt42.io, Keras-users
Is there any official plan to port Keras on mobile platforms, or is there anyone else doing the same work?

Not that I know of. But it's certainly a very useful project I can see it benefit many other people.

What are the technical pieces that you need for running a Keras model in inference mode on Android? I would have thought that exporting the TF graph of the model would be sufficient?

Tammy Yang

unread,
May 11, 2016, 2:04:16 PM5/11/16
to Keras-users, ba...@dt42.io
Hi François,                                                                    
                                                                                
The current Tensorflow sample on Android loads tensorflow_inception_graph.pb. Assuming one can convert a model generated by Keras to a Tensorflow graph and replace the file, I believe it should work. This is our step #1 -- to make the model running on Android. However, it is still different to our original goal: running Keras model on Android. It is more like a process to convert (and compress?) Keras model to Tensorflow, and run Tensorflow on Android (please correct me if my understanding about Keras and Tensorflow is not correct). If it is possible, we are hoping to make the Keras model run on Android with minimum changes to the model source built on desktop. That is why Bafu mentioned porting python modules to Android (mainly rely on Kivy).
                                                                                
Our project has just started and is still at very early stage, so any comment/suggestion is more than welcome :).
If it goes well, we plan to share more technical details in two or three months.    

Many thanks,
Tammy

Christophe Cerisara

unread,
Oct 28, 2016, 10:45:51 AM10/28/16
to Keras-users, ba...@dt42.io
Hi,

"How to install and use Keras+Theano python API on Android without rooting": you can find a recipe here:
http://talc1.loria.fr/users/cerisara/posts/tflow/

Sorry for the bad English and not so nice presentation - I write my posts very fast and never polish them,
but it's working, even on Lollipop (which is known for its annoying "security" restrictions) !

Happy coding !
xtof

ozgur.g...@gmail.com

unread,
Jun 5, 2017, 4:49:51 PM6/5/17
to Keras-users, ta...@dt42.io
Hi Francois, 

I am also interested running Keras models on iOS. 

Is this the following tutorial my best bet to do so? 

Thank you,
Ozgur

Venelin Valkov

unread,
Jun 6, 2017, 1:37:59 PM6/6/17
to Keras-users
Hi all,

I've posted tutorial/guide on how to export your TensorFlow model to Android (along with a sample app). It can be found here:


I was able to export Keras model as well and use it in similar fashion. Some sample code can be found here:


Hope that helps!

ozgur.g...@gmail.com

unread,
Jun 6, 2017, 5:17:33 PM6/6/17
to Keras-users
Hi Venelin, I guess the exported Tensorflow model should also work on iOS, right? I am planning to use the Tensorflow example app for iOS. 

Thanks,
Ozgur

andre...@gmail.com

unread,
Jun 11, 2017, 11:54:06 PM6/11/17
to Keras-users
Hi Venelin! 

What about the dropout? Did you just remove/bypass the nodes? You did not rescale the variables like you would usually do on Keras? Any difference in accuracy with/without dropout?

dreamf...@gmail.com

unread,
Jun 12, 2017, 3:35:45 PM6/12/17
to Keras-users
I am interested in working on the same project for iOS

ozgur.g...@gmail.com

unread,
Jun 15, 2017, 11:13:38 AM6/15/17
to Keras-users, ta...@dt42.io, ozgur.g...@gmail.com
Not a very active community here :(

valon...@gmail.com

unread,
Jul 29, 2017, 8:04:58 PM7/29/17
to Keras-users
It is possible.
I installed gnuroot debian and sm able to run Keras with Theano backend. Thats not simple to do but possible.
Reply all
Reply to author
Forward
0 new messages