Android demo: add sample images to README.md and update model installation instructions.

Change: 147787804
This commit is contained in:
Andrew Harp 2017-02-16 17:11:16 -08:00 committed by TensorFlower Gardener
parent c35e3b523a
commit de4f4beeb7

View File

@ -12,6 +12,8 @@ Inference is done using the [TensorFlow Android Inference Interface](../../../te
which may be built separately if you want a standalone library to drop into your which may be built separately if you want a standalone library to drop into your
existing application. existing application.
A device running Android 5.0 (API 21) or higher is required to run the demo.
## Current samples: ## Current samples:
1. [TF Classify](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/src/org/tensorflow/demo/ClassifierActivity.java): 1. [TF Classify](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/src/org/tensorflow/demo/ClassifierActivity.java):
@ -27,17 +29,25 @@ existing application.
(https://arxiv.org/abs/1610.07629) to restyle the camera preview image (https://arxiv.org/abs/1610.07629) to restyle the camera preview image
to that of a number of different artists. to that of a number of different artists.
<img src="sample_images/classify1.jpg" width="33%">
<img src="sample_images/stylize1.jpg" width="33%">
<img src="sample_images/detect1.jpg" width="33%">
## Prebuilt APK: ## Prebuilt APK:
If you just want the fastest path to trying the demo, you may download the If you just want the fastest path to trying the demo, you may download the
nightly build nightly build
[here](https://ci.tensorflow.org/view/Nightly/job/nightly-android/). [here](https://ci.tensorflow.org/view/Nightly/job/nightly-android/). Expand the
A device running Android 5.0 (API 21) or higher is required. "View" and then the "out" folders under "Last Successful Artifacts to find
tensorflow_demo.apk. Also available are precompiled native libraries that you
may drop into your own applications. See
[tensorflow/contrib/android/README.md](../../../tensorflow/contrib/android/README.md)
for more details.
## Running the Demo ## Running the Demo
Once the app is installed it can be started via the "TF Classify" and Once the app is installed it can be started via the "TF Classify", "TF Detect"
"TF Detect" and icons, which have the orange TensorFlow logo as their icon. and "TF Stylize" icons, which have the orange TensorFlow logo as their icon.
While running the activities, pressing the volume keys on your device will While running the activities, pressing the volume keys on your device will
toggle debug visualizations on/off, rendering additional info to the screen toggle debug visualizations on/off, rendering additional info to the screen
@ -92,19 +102,20 @@ The NDK API level may remain at 21.
The TensorFlow `GraphDef`s that contain the model definitions and weights The TensorFlow `GraphDef`s that contain the model definitions and weights
are not packaged in the repo because of their size. They are downloaded are not packaged in the repo because of their size. They are downloaded
automatically and packaged with the APK by Bazel via a new_http_archive defined automatically and packaged with the APK by Bazel via a new_http_archive defined
in WORKSPACE during the build process. in `WORKSPACE` during the build process.
**Optional**: If you wish to place the models in your assets manually (E.g. for **Optional**: If you wish to place the models in your assets manually (E.g. for
non-Bazel builds), remove the `inception_5` and `mobile_multibox` entries in non-Bazel builds), remove all of the `model_files` entries from the `assets`
`BUILD` and download the archives yourself to the `assets` directory in the list in `tensorflow_demo` found in the `[BUILD](BUILD)` file. Then download
source tree: and extract the archives yourself to the `assets` directory in thesource tree:
```bash ```bash
$ curl -L https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip -o /tmp/inception5h.zip BASE_URL=https://storage.googleapis.com/download.tensorflow.org/models
$ curl -L https://storage.googleapis.com/download.tensorflow.org/models/mobile_multibox_v1.zip -o /tmp/mobile_multibox_v1.zip for MODEL_ZIP in inception5h.zip mobile_multibox_v1a.zip stylize_v1.zip
do
$ unzip /tmp/inception5h.zip -d tensorflow/examples/android/assets/ curl -L ${BASE_URL}/${MODEL_ZIP} -o /tmp/${MODEL_ZIP}
$ unzip /tmp/mobile_multibox_v1.zip -d tensorflow/examples/android/assets/ unzip /tmp/${MODEL_ZIP} -d tensorflow/examples/android/assets/
done
``` ```
This will extract the models and their associated metadata files to the local This will extract the models and their associated metadata files to the local
@ -116,7 +127,7 @@ After editing your WORKSPACE file to update the SDK/NDK configuration,
you may build the APK. Run this from your workspace root: you may build the APK. Run this from your workspace root:
```bash ```bash
$ bazel build -c opt //tensorflow/examples/android:tensorflow_demo bazel build -c opt //tensorflow/examples/android:tensorflow_demo
``` ```
If you get build errors about protocol buffers, run If you get build errors about protocol buffers, run
@ -130,7 +141,7 @@ later device, then after building use the following command from your workspace
root to install the APK: root to install the APK:
```bash ```bash
$ adb install -r bazel-bin/tensorflow/examples/android/tensorflow_demo.apk adb install -r bazel-bin/tensorflow/examples/android/tensorflow_demo.apk
``` ```
### Android Studio ### Android Studio