WasmEdge CLI tools for Android

    First, install WasmEdge-TensorFlow-Tools pre-release on your Android device. It works with the Android version of TensorFlow-Lite dynamic shared library.

    Android developer options

    Currently, WasmEdge only supports the arm64-v8a architecture on Android devices. You need an arm64-v8a Android simulator or a physical device with . WasmEdge requires Android 6.0 and above.

    In Ubuntu Linux, you can use the command to install Android debugging and testing tool adb. Using the adb shell command on the Ubuntu dev machine, you can open a CLI shell to execute commands on the connected Android device.

    1. $ wget https://github.com/second-state/WasmEdge-tensorflow-tools/releases/download/0.10.0/WasmEdge-tensorflow-tools-0.10.0-android_aarch64.tar.gz
    2. $ mkdir WasmEdge-tensorflow-tools && tar zxvf WasmEdge-tensorflow-tools-0.10.0-android_aarch64.tar.gz -C WasmEdge-tensorflow-tools
    3. show-tflite-tensor

    We provide an Android compatible version of TensorFlow-Lite dynamic shared library in the WasmEdge-Tensorflow-deps package. Download the package to your Ubuntu dev machine as follows.

    1. $ wget https://github.com/second-state/WasmEdge-tensorflow-deps/releases/download/0.10.0/WasmEdge-tensorflow-deps-TFLite-0.10.0-android_aarch64.tar.gz
    2. $ tar zxvf WasmEdge-tensorflow-deps-TFLite-0.10.0-android_aarch64.tar.gz -C WasmEdge-tensorflow-tools
    3. libtensorflowlite_c.so

    Next use the adb tool to push the downloaded WasmEdge-TensorFlow packages onto a connected Android device.

    In this example, we will demonstrate a standard WasmEdge Tensorflow-Lite sample application. It can recognize and classify the bird type from a JPG or PNG picture of a bird. The explanation of the source code can be .

    1. git clone https://github.com/second-state/wasm-learning.git
    2. cd wasm-learning/rust/birds_v1
    1. rustup target add wasm32-wasi
    2. cargo build --release --target=wasm32-wasi

    Push the Wasm bytecode file, tensorflow lite model file, and the test bird picture file onto the Android device using adb.

    Type adb shell from the Ubuntu CLI to open a command shell for the connected Android device. Confirm that the tools, programs, and test image are all available on the Android device under the /data/local/tmp/WasmEdge-tensorflow-tools folder.

    1. $ adb shell
    2. sirius:/ $ cd /data/local/tmp/WasmEdge-tensorflow-tools
    3. sirius:/data/local/tmp/WasmEdge-tensorflow-tools $ ls
    4. bird.jpg lite-model_aiy_vision_classifier_birds_V1_3.tflite
    5. birds_v1.wasm show-tflite-tensor

    Load the TensorFlow-Lite dynamic shared library, and use the show-tflite-tensor CLI tool to examine the Tensorflow Lite model file.

    1. sirius:/data/local/tmp/WasmEdge-tensorflow-tools $ export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
    2. sirius:/data/local/tmp/WasmEdge-tensorflow-tools $ ./show-tflite-tensor lite-model_aiy_vision_classifier_birds_V1_3.tflite
    3. INFO: Initialized TensorFlow Lite runtime.
    4. Input tensor nums: 1
    5. Input tensor name: module/hub_input/images_uint8
    6. dimensions: [1 , 224 , 224 , 3]
    7. data type: UInt8
    8. tensor byte size: 150528
    9. Output tensor nums: 1
    10. Output tensor name: module/prediction
    11. dimensions: [1 , 965]
    12. tensor byte size: 965

    The result shows that the bird type is in line 166 of the label file (Sicalis flaveola) and the confidence level is 84.7%.