How to read graphics with memory mapping in android using tensor stream

First of all, I searched for this in the last 2 days, and I could not find anything that was connected with this, except for this stackoverflow message - How to read a graphical memory graph with a tensor stream file in android?

I successfully built desportflow for android for my android due to its link: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android/

And I was able to integrate the detection functions into my project using ClassifierActivity and was able to load and read my own schedule. I could read retrained_graph.pb or stripped_graph.pb and even optimized_graph.pb using my application.

I used bazel build tensorflow/python/tools:optimize_for_inference

bazel build tensorflow/python/tools:strip_unused

for optimized and split graphs (although graphs are easily accessible from the server side).

But when using a graph with memory display, I get an error message that he can not read the graph.

In the stackoverflow link above, I was sure that this could be done somehow. But I did not find any help on the network to do this from the side of Android.

Please feel free to orient me to some post or forums that can provide a lot of information on how this can be done. I am not posting any code because I followed github for tendorflow android developer to make it work, and I only stick to this.

Thanks in advance for any advice.

Update

Below is the error I get when I try to read the displayed memory graph

 FATAL EXCEPTION: main Process: nanob2c.nano.com.nanob2c, PID: 2632 java.lang.RuntimeException: Failed to load model from 'file:///android_asset/optimized_mmapped_graph.pb' at org.tensorflow.contrib.android.TensorFlowInferenceInterface.<init>(TensorFlowInferenceInterface.java:100) at nanob2c.nano.com.nanob2c.tensorflow.core.TensorFlowImageClassifier.create(TensorFlowImageClassifier.java:109) at nanob2c.nano.com.nanob2c.tensorflow.ClassifierActivity.onPreviewSizeChosen(ClassifierActivity.java:147) at nanob2c.nano.com.nanob2c.tensorflow.core.CameraActivity$3.onPreviewSizeChosen(CameraActivity.java:603) at nanob2c.nano.com.nanob2c.tensorflow.core.CameraConnectionFragment.setUpCameraOutputs(CameraConnectionFragment.java:425) at nanob2c.nano.com.nanob2c.tensorflow.core.CameraConnectionFragment.openCamera(CameraConnectionFragment.java:432) at nanob2c.nano.com.nanob2c.tensorflow.core.CameraConnectionFragment.access$000(CameraConnectionFragment.java:68) at nanob2c.nano.com.nanob2c.tensorflow.core.CameraConnectionFragment$1.onSurfaceTextureAvailable(CameraConnectionFragment.java:99) at android.view.TextureView.getHardwareLayer(TextureView.java:368) at android.view.View.updateDisplayListIfDirty(View.java:15175) at android.view.View.draw(View.java:15971) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.java:15193) at android.view.View.draw(View.java:15971) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.draw(View.java:16204) at android.view.View.updateDisplayListIfDirty(View.java:15198) at android.view.View.draw(View.java:15971) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.java:15193) at android.view.View.draw(View.java:15971) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1195) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.draw(View.java:16204) at android.view.View.updateDisplayListIfDirty(View.java:15198) at android.view.View.draw(View.java:15971) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.java:15193) at android.view.View.draw(View.java:15971) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.java:15193) at android.view.View.draw(View.java:15971) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.java:15193) at android.view.View.draw(View.java:15971) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.java:15193) at android.view.View.draw(View.java:15971) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.draw(View.java:16204) at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2690) at android.view.View.updateDisplayListIfDirty(View.java:15198) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:282) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:288) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:323) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2642) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2461) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2094) at android.view.ViewRootImpl.doTraversal(ViewRo 

Update - May 23, 2017

From the blogpost by Pete Warden - https://petewarden.com/2016/09/27/tensorflow-for-mobile-poets/

it is clear that we can read memmapped graph in mobile devices, and he noted that - . One thing to keep in mind is that the file on disk is no longer a simple protobuf GraphDef, so if you try to load it into a program such as label_image that expects it, you will see errors. You need to load the model file a little differently, which is clearly visible in the iOS example below.

I am looking for an implementation of the same on the android side.

+7
android tensorflow
source share
2 answers

As far as I checked on the Internet and on the Pete Warden blog, processing graphics with memory display is not supported by Android. The same is mentioned by MatPag as its answer.

But for this there must be some work. As far as I was looking, we can configure the JNI part and make it possible to process the card from this side. My conclusions are that making changes to the following files can help you with this (I have not had time yet) -

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/src/main/native/tensor_jni.cc

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/src/main/native/graph_jni.cc

It is also necessary to update the corresponding files in the java part -

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/src/main/java/org/tensorflow/Tensor.java

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/src/main/java/org/tensorflow/NativeLibrary.java

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/android/java/org/tensorflow/contrib/android/TensorFlowInferenceInterface.java

The answer will be updated if I manage to do this.

Thank you for providing reliable information about this, since all this helped me find a solution.

+4
source share

After doing some research with your exception, I ended up here with the loadGraph() method (which is the one that breaks your application).

It seems that currently loading the graphic display of memory is not supported in the Android implementation you are using, in fact, on line # 376 there is TODO for the function you are asking for (or at least something related)

+1
source share

All Articles