Creating a "generic" Tensorflow Android app with Python code - android

I created a Tensorflow image classification app in python 2.7 using Kivy and Pycharm. I used my own data to create a custom graph and labels file. The app works great and does what I want it to do. It took me months of learning and coding to get to this point. My last part of this "journey" has been trying to port the app to the android platform (I'd like to do Windows or a web app too -- but that does not seem to be a real option today . . .) I've created the Tensorflow Android Camera Demo app using Bazel and it worked fine on my Galaxy S5. However, after spending several long days searching all the references I could fine in Google searches, Packt (and other) books, and so on I am at an impasse. My question is does anyone in this forum have any advice on a method to create an Android app from a working Python app as I described? I would be really grateful for any help from someone who has done this.

I used my own data to create a custom graph and labels file
Since you have already trained your TensorFlow model, you can import it into an Android app relatively easily.
The TensorFlow Android demo app can now be built in Android Studio without using Bazel. You should be able to replace the Inception v3 image classifier model with your own model.
Check out my blog post here for more information about how to use the Java TensorFlowInferenceInterface class to interact with your pre-trained model:
https://medium.com/#daj/using-a-pre-trained-tensorflow-model-on-android-e747831a3d6
As for how to port a Python app to Android, I'm not aware of an easy way to do that.

Related

How to open my Android native application with Xamarin.forms?

I've been developing an Android application with Android Studio and now I need to be able to open it with Xamarin.forms in Visual Studio (it's a task that my teacher gave me, and it's because a classmate has been creating the iOS version and now we will combine them into one project).
I have to say that I'm pretty much a noob and been looking a few tutorials that talk about Dependency Service and other stuff, but don't seem to quite cover what I'm looking for (or, at least, not clearly enough).
If you have a precise video that explains simply how to do this, I would be grateful if you share it with me.
I thank you for your time and wish you a great day :)
It is impossible at even now in current version of Visual Srudio .
Every file in Xamain is different with Native Android . The Java code can not be directly copyed to use in Xamarin , you should translate them to C#.
Having a look at this document: Porting Java to C# for Xamarin.Android .
There are two ways to port Java code to C#. The first way is to port the code manually. ..The second porting methodology is to try and automate the process by using a code converter...There is often a non-trivial amount of work involved with bootstrapping an automated code conversion tool, and this may prove to be a barrier to use. In many cases, it may be simpler and easier to port Java to C# by hand.

Creating a simple neural network on Tensorflow by means of Android

I want to create a simple neural network based on the example https://github.com/googlesamples/android-ndk/tree/master/nn_sample. Is it possible to create this with the help on Tensorflow only with Android tools on Java
Take a look at this folder https://github.com/googlesamples/android-ndk/tree/master/nn_sample/app/src/main/cpp
simple_model.h is the model trained in Tensorflow before creating the Android project. Now the model likes black-box, get input and predict output only, if you want to build your own model, try this tutorial (All steps from training, evaluating, prediction to deploy onto Android):
https://medium.com/#elye.project/applying-tensorflow-in-android-in-4-steps-to-recognize-superhero-f224597eb055
Affirmative. You can use TensorFlow Lite on Android, it's an open source deep learning framework which helps to compress and deploy models to a mobile or embedded application. It basically can take models as input and then deploys and interpret and perform resource-conserving optimizations for mobile applications. The NNAPI of Android NDK can interface with TFLite easily too. This link contains gesture, image, object & speech detection and classification example implementations on Android with Java using TFLite.

Tensorflow on android: directly build app in python?

The sample app given by google for tensorflow on android is written in C++.
I have a tensorflow application written in python. This application currently runs on desktop. I want to move the application to android platform. Can I use bazel to build the application that is written in python directly for android? Thanks.
Also sample tensorflow app in python on android will be much appreciated.
Currently, there is no simple way to run tensorflow on android. Typically, you would only have to use inference (runtime), not training.
Another way is to use TensorFlow serving to host models in the cloud and issue RPC calls from an Android client.
I tried to use python in my android application with some 3rd party terminals like SL4A and Qpython. Those will support to run the python files directly in our android application so we have to install SL4A apk's and we need to call that intent.But these will support for some level I guess.
I tried to import tensorflow in that terminal it shows module not found. So I thought this tensorflow will not work in these terminals.
So I am trying to create one .pb file from the python files which are working in unix platform.So We need to include that output .pb file in our android application and we need to change the c++ code regarding that .pb file.I am thinking in this way.let see it will work or not.I will update soon if it working.
You can create your tensorflow model on your desktop and save it as a .pb file. Then you can add this model to your android project and make use of it to make predictions on the android device.
Its like training(which involves heavy computations) on a desktop machine(which is more powerful) and using the model to make predictions(which involves less computations) on a mobile device(comparatively less powerful).
This is a link to a great video by Siraj Raval
https://www.youtube.com/watch?v=kFWKdLOxykE

Load custom tensorflow graph in the demo android application

I'm new with tensorflow and I'm following this tutorial in youtube then I'm trying to train my own graph with the tensorflow deep learning method (using retrain.py file). I'have as result 2 files: one for labels and the other for the graph.
I'm trying to replace those two files with the same ones in the tensorflow demo application for android, but this didn't work for me.
I have read a bit about tensorflow on their website, but I found it complex for me as a beginner. Anyone can explain the problem to me please ???.

Use Tensorflow model in c++ app

Apologies in advance for this relatively newbie question. Using Tensorflow, I've trained a neural net in python and I'd like to use it to classify images in a c++ application, which I want to later integrate into an android app.
Today I spent all day working through the Tensorflow Serving tutorial: https://tensorflow.github.io/serving/serving_basic.
I have everything installed and working, but it's still not obvious to me what to do next. Is TF Serving the right thing to do? Can it be used to integrate a trained TF model into a an application? Or is it just something to build models that can be run from the Terminal?
If TF Serving is not what I need, then where should I look in stead? Is there a simpler way to use trained models cross-platform?
Thanks!
Please take a look at this section in the tutorial for how to load a SessionBundle in c++.
Once you have a SessionBundle you can use utilities in signature.h to get a signature (e.g., GetClassificationSignature) then run an inference (e.g., RunClassification).

Categories

Resources