Deployment option for android device

Question/Issue: I want to deploy a model to an android device. I don’t know which library I should use for deployment. Please suggest, which deployment library I should select.

Hi @ashokp

For deploying a model to an Android device, you can go a couple of routes, Naitive Android - utilize tflite for android, Cross Platform JS - tflite plus cross platform framework like ionic, or Cross Platform JS - wasm.

WASM may be the easiest and you can start with our browser guide - Through WebAssembly (browser) | Edge Impulse Documentation

I don’t have any docs for the tflite for android, but you can find their getting started guide here, and ask us questions / comment on your progress: Android 빠른 시작  |  TensorFlow Lite

It provides tools to convert your trained models into a format compatible with Android devices and APIs to integrate them into your Android applications seamlessly.

If you still decide to go naitive android you can follow these high level steps to deploy your Edge Impulse model to an Android device using TensorFlow Lite:

  1. Export your trained model in TensorFlow Lite format.
  2. Integrate the TensorFlow Lite model into your Android project.
  3. Use the TensorFlow Lite Android Support Library to load and run the model on the device.
  4. Implement the necessary logic in your Android application to process input data and interpret model outputs. (here is where you can give some feedback to us on your progress and hopefully we can get you)

I’ve made some progress with the ionic cross platform approac, but havent had time to complete it.

Feel free to reach out if you need further assistance or have any more questions!

Best

Eoin

If the exported Tflite model contains DSP blocks from Edge impulse, this would mean that these blocks would also need to be there. Our use case is to run the Tflite model. with the DSP blocks in Android and in Unity3D engine. Are the source code for the eported DSP blocks available? and how and where are the DSP blocks being called and run from?

1 Like

Thanks for the reply @Eoin ,

I have tried the demo project on audio classification. It used a preprocessing block ‘mfe’. After exporting the model, I get a c++ package. I want to understand where and how the sequence of the pipeline is defined. I couldn’t locate the code where the pipeline is defined, for example the input signal is preprocessed, features are extracted and then model is used for inference.

@Eoin, Do you have updates on these questions. This is quite a big blocker for us to move forward.

Very cool @BlueLotus!

You can review out MFE code and Docs in the public git repo:

Also see Custom Processing Blocks:

This level of usage isn’t something I’m able to help with unfortunately but you should be able to engage our ml solutions via our sales team if you need further assistance with it - Contact

Best

Eoin

Thanks @Eoin for sharing the docs links. I am trying to integrate the cpp package of edge impulse with unity using android studio, used the following videos as reference:

  1. Deploy an ML Model to Any Target with the Edge Impulse C++ Library (youtube.com)
  2. Creating a C++ Android Plugin for Unity with Android Studio (youtube.com)
    I am getting some errors while making the module in android studio. May you please check if the CMakeLists.txt file is correct? or please share any suggestion if you have.

Following is the content of the CMakeLists.txt file:

Sets the minimum CMake version required for this project.

cmake_minimum_required(VERSION 3.22.1)

include(edge-impulse-sdk/cmake/utils.cmake)
add_subdirectory(edge-impulse-sdk/cmake/zephyr)

RECURSIVE_FIND_FILE_APPEND(MODEL_SOURCE “tflite-model” “*.cpp”)
target_include_directories(cppLib PRIVATE .)

add all sources to the project

target_sources(cppLib PRIVATE ${MODEL_SOURCE})

project(“cppLib”)

add_library(cppLib
SHARED
# List C/C++ source files with relative paths to this CMakeLists.txt.
main.cpp)

find_library( # sets the name of the path variable
log-lib
# Specify the name of the NDK lib that you want CMake to locate

        log

)

target_link_libraries(cppLib
# List libraries link to the target library
android
log)

Hi @ashokp

Nice work but try to get both working independently first, the android SDK / NDK doesn’t appear to be set up correctly. If you can get both working on their own you will have more hope of integrating.

For Edge Impulse get C++ working on your desktop, I see some reference to Zephyr for example you would be better off to start over and work along this guide:

Best

Eoin

Thanks, I will follow this guide and get back to you.

1 Like