官术网_书友最值得收藏!

Installing Android NDK and SDK

You need Android NDK to build the TensorFlow Lite code. You can download this from NDK Archives, accessed through the following link. 

Android NDK Archives can be downloaded from: https://developer.android.com/ndk/downloads/older_releases.

Android Studio comes with SDK tools. You need to access build tools version 23 or higher (the application runs on devices with API 21 or higher).

You can update the WORKSPACE file in the root of the directory with the API level and path to both SDK and NDK. 

Update the api_level and location of the SDK and NDK at the root of the repository. If you open SDK Manager from Studio, you can find the SDK path. For example, note the following for SDK:

android_sdk_repository (
name = "androidsdk",
api_level = 27,
build_tools_version = "27.0.3",
path = "/Users/coco/Library/Android/sdk",
)

And for Android NDK archives: 

android_ndk_repository(
name = "androidndk",
path = "/home/coco/android-ndk-r14b/",
api_level = 19,
)

At the time of writing, android-ndk-r14b-darwin-x86_64.zip is used from the NDK Archives. You can adjust the preceding parameters based on the availability.

Now, we are ready to build the source code. To build the demo app, run Bazel:

bazel build --cxxopt=--std=c++11 
//tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo

Caution:  Due to a bug, Bazel only  supports the Python 2 environment right now.  
MobileNet is a good place to start ML. The model images from this dataset consist of images in 299 * 299 pixel. But, the camera captures in a 224 * 224 pixel image and resizes it to match the size in the model.  It occupies 224 * 224 * 3 bytes in the disk, per image. These bytes are converted into ByteBuffer row by row after that. Here, the number 3 represents RGB values of a pixel. 

The demo app here uses the TensorFlow Lite Java API, which takes a single image as input and produces the same in output. The output contains a two-dimensional array. The first array contains the category index value, and the second dimension contains the confidence value of the classification. From the values, it displays the top three to the user on the frontend.

主站蜘蛛池模板: 江川县| 揭西县| 温州市| 隆回县| 宁化县| 德江县| 泗洪县| 仁布县| 濮阳县| 临潭县| 曲阜市| 买车| 贵州省| 张家口市| 永善县| 屏边| 吉林省| 泰宁县| 内黄县| 洛南县| 抚顺市| 丹棱县| 轮台县| 铁岭市| 永靖县| 永登县| 汝南县| 达州市| 望城县| 夏津县| 吴川市| 长泰县| 大石桥市| 翼城县| 温宿县| 紫金县| 宜黄县| 萝北县| 长宁区| 会宁县| 东乡县|