Giter Site home page Giter Site logo

android-tensorflow-sample's Introduction

TensorFlow Android Camera Demo

This folder contains a simple camera-based demo application utilizing TensorFlow.

Description

This demo uses a Google Inception model to classify camera frames in real-time, displaying the top results in an overlay on the camera image.

To build/install/run

As a prerequisite, Bazel, the Android NDK, and the Android SDK must all be installed on your system.

  1. Get the recommended Bazel version listed at: https://www.tensorflow.org/versions/master/get_started/os_setup.html#source
  2. The Android NDK may be obtained from: http://developer.android.com/tools/sdk/ndk/index.html
  3. The Android SDK and build tools may be obtained from: https://developer.android.com/tools/revisions/build-tools.html

The Android entries in <workspace_root>/WORKSPACE must be uncommented with the paths filled in appropriately depending on where you installed the NDK and SDK. Otherwise an error such as: "The external label '//external:android/sdk' is not bound to anything" will be reported.

The TensorFlow GraphDef that contains the model definition and weights is not packaged in the repo because of its size. Instead, you must first download the file to the assets directory in the source tree:

$ curl -L https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip -o /tmp/inception5h.zip

$ unzip /tmp/inception5h.zip -d tensorflow/examples/android/assets/

The labels file describing the possible classification will also be in the assets directory.

Then, after editing your WORKSPACE file, you must build the APK. Run this from your workspace root:

$ bazel build //tensorflow/examples/android:tensorflow_demo

If you get build errors about protocol buffers, run git submodule update --init and build again.

If adb debugging is enabled on your Android 5.0 or later device, you may then use the following command from your workspace root to install the APK once built:

$ adb install -r -g bazel-bin/tensorflow/examples/android/tensorflow_demo.apk

Some older versions of adb might complain about the -g option (returning: "Error: Unknown option: -g"). In this case, if your device runs Android 6.0 or later, then make sure you update to the latest adb version before trying the install command again. If your device runs earlier versions of Android, however, you can issue the install command without the -g option.

Alternatively, a streamlined means of building, installing and running in one command is:

$ bazel mobile-install //tensorflow/examples/android:tensorflow_demo --start_app

If camera permission errors are encountered (possible on Android Marshmallow or above), then the adb install command above should be used instead, as it automatically grants the required camera permissions with -g. The permission errors may not be obvious if the app halts immediately, so if you installed with bazel and the app doesn't come up, then the easiest thing to do is try installing with adb.

Once the app is installed it will be named "TensorFlow Demo" and have the orange TensorFlow logo as its icon.

#Checkout Demo Youtube Me Alt text for your video

android-tensorflow-sample's People

Contributors

aerdy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.