Giter VIP home page Giter VIP logo

ml-edgeimpulse-project-builder's Introduction

Edge Impulse Project Builder

This repository contains instructions for integrating an Edge Impulse Studio project into an MPLAB X project for any xc32 supported platform.

Notes:

  • This script has only been tested under linux (ubuntu), Git Bash, and macOS.
  • *.options.ini can be modified to set additional project options; for help call the mplab script prjMakefilesGenerator -setoptions=@ -help
    • NB: all relative paths are considered relative to the project root folder (.X folder)
  • *.project.ini is just a placeholder - the languageToolchain and device variables are replaced when building the project - others will take default values if unspecified.

Software Used

Model Deployment

The first step in building an MPLAB project for Edge Impulse is of course to deploy the Edge Impulse model.

  1. Open Edge Impulse Studio.

  2. Click on the Deployment step in the sidebar menu.

  3. Under Create Library select C++ library, then click Build to download the library.

    Add library object

Edge Impulse SDK Build Instructions

The following steps cover compiling the Edge Impulse library into a static library object.

  1. Extract the library from the step above directly into this folder.

  2. (Optional) Open options.ini and modify as needed.

  3. Set the environment variables MPLABX_VERSION XC_VERSION XC_NUMBER_BITS as desired, then run build.sh to generate the library object. For example:

    MPLABX_VERSION=6.00 XC_VERSION=4.00 XC_NUMBER_BITS=32 ./build.sh ATSAME54P20A libedgeimpulse .

    If MPLAB X or the XC compiler are in non-default install locations, set the corresponding path directly through the MPLABX_PATH and XC_PATH environment variables.

Docker Build

To launch a Docker build for a specific target build arguments must be set as shown in the included example .args files. See docker_build.sh for a full example for building the docker image and generating the Edge Impulse library/project. This script can be run by passing the target name and .args file e.g.:

./docker_build.sh ATSAME54P20A args/SAME54.args

This will output the result of the build into a folder dist/ under your current working directory.

See packs.download.microchip.com for device family pack listings.

Integration Instructions

Below are instructions for integrating the library object, compiled with the steps above, into an MPLAB X project.

  1. Add the library object from the step above into an existing MPLAB project as shown below.

    Add library object

  2. Add the src/ei_classifier_porting.cpp file from this repository to your project, this implements the required Edge Impulse stubs.

  3. Use src/main.cpp as a template for integrating the Edge Impulse library into your project.

  4. Add the path to the directory where the SDK is extracted in your include path under Project Properties -> XC32 Global Options -> Common include dirs

    Add include directory

  5. The Edge Impulse SDK uses dynamic memory allocation so allocate additional heap memory under Project Properties -> xc32-ld -> Heap size (see (1) in the image below). The number will vary based on your Edge Impulse project parameters (especially the maximum width of your neural network layers).

  6. Ensure that the Remove unused sections option under Project Properties -> xc32-ld is enabled (see (2) in the image below); this will eliminate any unused data or functions from the SDK to reclaim device memory.

    Add include directory

You should now have your Edge Impulse model fully integrated with an MPLAB X project. In order to update the deployed model, simply repeat the steps from the build instructions section above.

Additional Notes

Some special care has to be taken to ensure the library is integrated correctly with your project:

  • If the CMSIS libraries are included in the build, make sure your project doesn't link the pre-built CMSIS library optionally included with MPLAB Harmony projects.

  • The Edge Impulse SDK will automatically determine whether to include the CMSIS NN/DSP libraries. You can use EIDSP_USE_CMSIS_DSP=0 and EI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN=0 to manually disable this behavior.

ml-edgeimpulse-project-builder's People

Contributors

tjgarcia-mchp avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

ml-edgeimpulse-project-builder's Issues

Issue working with "ml-edgeimpulse-project-builder": <cfloat> not found

Hi there,

First of all, thanks for creating such a build tool and instruction, which is exactly what I am looking for.
My recent project is trying to integrate the machine learning model trained on the Edge Impulse with my existing project developed in MPLAB (ver. 6.0.0) with xc32-gcc (ver.4.2.0). The MCU I am using is ATSAMD21J16B. I was following your instruction closely.
So far I was able to use docker to build the Edge Impulse model that is supposedly ready to be integrated to the MPLAB project. However, when I try to compile the library with the project, I ran into the following issue:
../src/ML/edge-impulse-sdk/dsp/numpy.hpp:32:10: fatal error: cfloat: No such file or directory  #include <cfloat>           ^~~~~~~~ compilation terminated. make[2]: *** [build/default/production/_ext/818654064/drv_usbfsv1_device.o] Error 255 make[2]: *** Waiting for unfinished jobs....

After some google search, it seems like cfloat is obsolete now, which is unfortunate considering this repo was last updated a year ago. I was assuming, the repo is pretty up to date and should be pretty "plug and play" sort to speak. My MPLAB and XC32 compiler seems to be pretty up-to-date with the example in your instruction as well.

Would you be able to shed some lights please?

Cheers,
Jordan

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.