Port TensorFlow code to Android - deep-learning

I have written a script for sequence classification using TensorFlow in Python. I would like to port this code to Android. I have seen the example on the TensorFlow github page regarding Android but that is for images.
Is there any way to directly port my TensorFlow Python code on Android?

The typical way to do this is to build (and train) your model using Python, save the GraphDef proto to a file using tf.train.write_graph(), and then write an app using the JNI to call the C++ TensorFlow API (see a complete example here).
When you build your graph in Python, you should take note of the names of the tensors that will represent (i) the input data to be classified, and (ii) the predicted output values. Then you will be able to run a step by feeding a value for (i), and fetching the value for (ii).
One final concern is how to represent the model parameters in your exported graph. There are several ways to do this, including shipping a TensorFlow checkpoint (written by a tf.train.Saver) as part of your app, and running the restore ops to reload it. One method, which has been used in the released InceptionV3 model is to rewrite the graph so that the model parameters are replaced with "Const" nodes, and the model graph becomes self contained.

There is QPython or Kivy.
QPython - Android Apps on GooglePlay. It's a script engine that runs Python on android devices. It lets your android device run Python scripts and projects. It contains the Python interpreter and some other stuff like pip, but there's no compiler available, so only pure-python packages will work.
Python for Android - lets you compile a Python application into an Android APK together with additional packages both pure-python and those that need compiling.

Related

Is it possible to use keplergl without Mapbox?

I want to do some spatiotemporal data analysis with kepler.
As the data is confidential and also huge, i cannot upload it in the demo site.
Tried installing keplergl locally but it needs a Mapbox Access Token (which I think is paid).
Is there a way I can use kepler with OpenStreetMap. (I want to run it in jupyter notebook or through python OR a one-time react setup, since I am not familiar with react).
Also when I use Kepler in jupyter notebook empty map loads as shown below:
Without data map
as soon as I load data it goes away:
With data map
here is console output:
error
My jupyter notebook is also configured with
jupyter nbextension install --py --sys-prefix keplergl
jupyter nbextension enable keplergl --py --sys-prefix
Is there a way to fix the jupyter notebook error OR is there an alternative open-source tool like keplergl.
Saw some solutions using Tile with docker but was not completely clear. I would prefer a way in which I can use it in jupyter notebook.
Tried pydeck of DeckGL, wasn't very interactive.
For example, I have multiple columns in my database and kepler lets me filter based on each column.
Also, kepler allows one to select which different columns for weights.
If pydeck allows it can you please say how?

How to call OpenCV in Sikuli/Jython?

I'm aware that Sikulix uses Jython and OpenCV for it's template matching, but I'm interested in performing some more complicated image processing tasks. Is it possible to directly access OpenCV in Sikulix/Jython, and are there any examples of how one would do this?

Communication between 2 Maya plugins

I am developing 2 Maya plugins in C++ and would like to call a function in plugin #1 from plugin #2 and send parameters along with the function.
The caller plugin is an MPxNode and the called plugin should be "general" functions whose role are to create some rendering VRayPlugins.
How should I proceed to declare and call the appropriate functions ?
Maya plug-ins are not different from standard DLL whether you run on Windows, OSX, or Linux. There is multiple approach you can use here. You can link the utility dll to your plug-in, and as long the OS can find it, it will be loaded in Maya address space whenever the plug-in loads in Maya (like any DLL, including the Maya DLLs). The other way is to export symbols from the DLL, but link the function/class at runtime (LoadLibrary() / GetProcAdress()). This time, you need to load the utility DLL yourself, and search for the export signatures before calling them. For these 2 methods, this is standard C++ programming, nothing special regarding Maya.
Now if you work with the Maya DG, you could also think about MMessage / MPxNode to transport and evaluate data. This is specific to the Maya DG and API. But I am not sure you need that level of complexity for what you described above.

What does generating an app bundle in Windows 8.1 do?

Windows 8.1 introduced a new feature in the packaging section of the manifest called "Generate app bundle". It says that "Consider generating an app bundle if your app contains language-specific resources, a variety of image scales, or resources that apply to specific versions of DirectX. If you don't generate one, your app will run just fine, but users will have to download a larger app. For more information about app bundles, see App Packaging."
But users can change their language or run the app on a variety of different monitors at any time without reinstalling the app. So how does this feature work, what is it doing?
Basically, the App Package is split up into modular chunks. Each library that you use is split up into its component dll's. The language resources are also split up into a different chunk for each language.
This does a few things. For instance, let's say you have two games, BlackJack and Spades. Both of them use the same base engine, with the same images and base game logic. All of these are included in your 'BaseCardGame' library. In the bundle, it will keep a log of the BaseCardGame library and include it in the bundle. Now, let's say you have a user who downloads both of these apps (as you hope they would). The bundle says "I need the BaseCardGame library with XXXXX signature." Your system says "I already have that, so bundle me up the rest of the stuff that I don't have." So your users only have to download that package once.
The same thing is true for the language resources. If they have only added to their system French and Italian, then it's unlikely they're going to need the Ukrainian language information. So, they don't have to download that. Note: It does not have to be the language they have currently set, only the languages they have added to their system. If they then add a new language, the system will go and get the language packages for the apps that have them.
This is all at a high level, but describes the basics of the bundling system. Channel 9 has quite a few good videos on it.

Is there any OCR SDK for c++ builder?

I'd like to add character recognition functionality to my application that's why asking you what's the best available and affordable OCR SDK . I looked at ABBY FineReader Engine 10.0 but haven't got trial version yet as I requested from the official site!
I've downloaded Asprise OCR SDK but it's doesn't recognize Cyrillic symbols..
How to implement character recognition on my application ? By using what kind of libs, SDKs, APIs and so on..
There's Cunieform and Google's Tesseract OCR, both of which are free. Personally I've used Tesseract, the SDK was giving a lot of trouble so finally decided to simply call the command line interface of Tesseract with arguments from within my C program using the system() function.
Lots of people face difficulties with the Tesseract installation, so here's a short summary (version 2 works for me, insert appropriate version if necessary):
Download the following from the svn: tesseract-2.00.tar.gz, tesseract-2.00.exe6.tar.gz, tesseract-2.00.eng.tar.gz
Unzip tesseract-2.00.tar.gz to a folder
Unzip tesseract-2.00.exe6.tar.gz and move to where tesseract-2.00.tar.gz was unzipped. A few files will be replaced this way
Similarly unzip tesseract-2.00.eng.tar.gz and move to tesseract-2.00.tar.gz where tessdata folder will be replaced.
After all this is done, open the tesseract.dsw workspace, select All Files and do "Rebuild All." This'll take a while with loads of warnings but hopefully no errors.
The command using DOS shell is tesseract picture.tif textfile -l eng. So basically save your image as a TIFF file, run the command from within your program and then read in the OCR output strings from the text file.
I can recommend you Crystal OCR if you don't need to recognize a very complex documents, they sent me C++ Builder sample by request. IMHO, Tesseract is still buggy, though it's the best free OCR of course.
You can try KSAI-Toolkits. It has a completely ocr application, which include C++ API, OCR model, benchmark and test data. And it supports different platforms.