Skip to content

Edge Impulse ML Blocks

Edge Impulse is the leading development platform for machine learning on edge devices.

The models in SSCMA support running on Edge Impulse specific information is available in the sscma-ei-ml-blocks. The following is an example of how to run the SSCMA model on Edge Impulse, using the sscma-fomo model.

Run the Pipeline

You run this pipeline via Docker. This encapsulates all dependencies and packages for you.

Pipeline on Docker

  1. Clone the sample repository.

    sh
    git clone https://github.com/Seeed-Studio/sscma-ei-ml-blocks && \
    cd sscma-ei-ml-blocks/sscma-fomo
  2. Install Docker Desktop.

  3. Install the Edge Impulse CLI v1.16.0 or higher.

  4. Create a new Edge Impulse project, and make sure the labeling method is set to Bounding Boxes.

    • Click 'Create New Project' button.

      create-project-1

    • Guess a project name and finish setup.

      create-project-2

  5. Add labels and some data.

    dataset

  6. Under Create Impulse set the image size (e.g. 160x160, 320x320 or 640x640), add an Image DSP block and an Object Detection learn block.

    dataset

  7. Open a command prompt or terminal window.

  8. Initialize the block.

    sh
    edge-impulse-blocks init # Answer the questions, select 'Object Detection' for 'What type of data does this model operate on?' and "FOMO" for 'What's the last layer...'
  9. Fetch new data via.

    sh
    edge-impulse-blocks runner --download-data data/
  10. Build the container.

    sh
    docker build -t sscma-fomo .
  11. Run the container to test the script (you don't need to rebuild the container if you make changes).

    sh
    docker run --shm-size=1024m --rm -v $PWD:/scripts sscma-fomo --data-directory data/ --epochs 30 --learning-rate 0.00001 --out-directory out/
  12. This creates a .tflite file in the out directory.

TIP

If you have extra packages that you want to install within the container, add them to requirements.txt and rebuild the container.

Fetching the new Data

To get up-to-date data from your project:

  1. Install the Edge Impulse CLI v1.16 or higher.

  2. Open a command prompt or terminal window.

  3. Fetch new data using the command below.

    sh
    edge-impulse-blocks runner --download-data data/

Pushing the Block back to Edge Impulse

You can also push this block back to Edge Impulse, that makes it available like any other ML block so you can retrain your model when new data comes in, or deploy the model to device. See Docs > Adding custom learning blocks for more information.

  1. Push the block.

    sh
    edge-impulse-blocks push
  2. The block is now available under any of your projects, via Create impulse > Add learning block > Object Detection (Images).

    object-detection

  3. Download block output.

    dl

Released under the MIT License