CS6825: Computer Vision word cloud

Tensorflow

...what is it

  • open source software library for numerical computation using data flow graphs.

  • flexible architecture allows you to deploy computation to one or more CPUs or GPUs in a desktop, server, or mobile device with a single API.

  • originally developed by r Google Brain Team within Google's Machine Intelligence research organization for the purposes of conducting machine learning and deep neural networks research

  • version 1 released Feb. 2017

  • Commonly used for implementation of CNN and related networks

 

 

Tensorflow + Android options - running on Android device a model (not about training)

(Note: you can ofcourse run on regular machines too)

...first overall note:

  • TensorFlow is written in C++.

  • In order to build for android, we have to use JNI(Java Native Interface) to call the c++ functions like loadModel, getPredictions, etc.

  • We will have a .so(shared object) file which is a c++ compiled file and a jar file which will consist of JAVA API that will be calling the native c++. And then, we will be calling the JAVA API to get things done easily.

  • So, we need the jar(Java API) and a .so(c++ compiled) file.

  • regarding TensorFlow it creates a "model file" when you train it with images....so,we must have the pre-trained model file and a label file for the classification.

 

 

OPTION 1: Android & Tensorflow setup from Cloned Code--to run a pre-trained model inside Android App

 

OPTION 2: Creating Your Own Android Tensorflow application

 

 

Android Inference Library

Because Android apps need to be written in Java, and core TensorFlow is in C++, TensorFlow has a JNI library to interface between the two. Its interface is aimed only at inference, so it provides the ability to load a graph, set up inputs, and run the model to calculate particular outputs. You can see the full documentation for the minimal set of methods inTensorFlowInferenceInterface.java

The demos applications use this interface, so they’re a good place to look for example usage. You can download prebuilt binary jars at ci.tensorflow.org.

 

 

Training your own models

STEP 1: Installing Tensorflow for Training- CNN development - how to train (you have multiple languages like Python, Go, Java as options --but, Python seems to have most examples/documentation)

    • TIP: for python based install (for the training program development) you will need to install python and add it to the path and any scripts it might use for setup (typically this means adding something like C:\python37 and C:\python37\scripts to your path ---but, of course this will depend on YOUR version you installed and where it is located). Currently you use the pip3 tool of python to install it from command line. pip3 is located in the scripts directory of python (hence have to add to the path)
    • Validate install:
      1) RUN python interactive shell:
      $ python

      Enter the following short program inside the python interactive shell:

      >>> import tensorflow as tf
      >>> hello = tf.constant('Hello, TensorFlow!')
      >>> sess = tf.Session()
      >>> print(sess.run(hello))

      2) OUTPUT: If the system outputs the following, then you are ready to begin writing TensorFlow programs:

      Hello, TensorFlow!

       

STEP2: follow directions on how to do http://nilhcem.com/android/custom-tensorflow-classifier

NOTE: another tutorial on training your own image classifier- https://towardsdatascience.com/building-a-toy-detector-with-tensorflow-object-detection-api-63c0fdf2ac95

Pretrained Models --might be able to find existing model to use

Special topics

Preparing Pre-trained models for use on Mobile devices -- see https://www.tensorflow.org/mobile/prepare_models

you must do this to work with the mobile tensorflow api (compile 'org.tensorflow:tensorflow-android:1.3.0') because it has reduce API from normal Tensorflow to fit better on the reduce capability of mobile device and to reflect you are only running models not training them.... So this work tries to compress down the size of the trained model

 

3D & Tensorflow - various resources regarding using Tensorflow on 3D images

 

 

Special Note- if you want to install docker or bazel --these are tools for deployment and building resepctify you can at

Go to https://docs.docker.com/engine/installation/

follow instructions

(if have older windows may need to instead install docker toolbox
https://docs.docker.com/toolbox/toolbox_install_windows/)
go to https://bazel.build/versions/master/docs/install.html  (or search for current
link and follow directions this may require that you install first on windows chocolatey and on macOS brew which
are pacakage managers that assist with installing of software --- whatever the
process is you have to follow it at the bazel site

so on windows after you install chocolatey (choco) package manager to install bazel you
type
> choco install bazel

 

 

 

 

 

© Lynne Grewe