Giter VIP home page Giter VIP logo

embeddedml's Introduction

Machine learning on embedded devices

Focused primarily on running inference/prediction/feed-forward part on a microcontroller (or small embedded device). Training phase can run on a standard computer/server, using existing tools as much as possible.

Background

What and when to use machine learning

The defaults right now are to do conventional signal processing (no learning) in sensor, and stream raw data to the cloud for storage and processing. Machine learning happens in the cloud. If gateways are used, they mostly forward communication (no data processing).

On-edge processing valueable when

  • Local response needed. Autonomy
  • Adaptable response needed. Over time, in context.
  • Low/predictable latency needed
  • Sending raw sensor data has privacy implications. Audio, video.
  • Unreliable connection
  • High bandwidth sensor input. Audio, video, accelerometer/IMU, current sensor, radiowaves.
  • Low bandwidth algorithm output
  • Events of interest are rare
  • Low energy usage needed
  • Full/raw sensor data is not valuable to store
  • Sensor system should be low cost

Example usecases

  • Predictive maintenance, using audio/vibration data
  • Activitity detection for people, using audio/accelerometer data. Assistive tech, medical
  • Appliance disaggregation, using aggregated power consumption data. "Non-Intrusive Load Monitoring" (NILM)
  • Anomaly/change detection for predictive maintenance, using audio/vibration data, or electrical data
  • Gesture recognition as human input device, using accelerometer/gyro data.
  • Speech/command recognition as human input device, using microphone. Keyword/Wake-word detection
  • Battery saving in wireless sensors. Normally sending day/week aggregates, on event/anomaly detection send data immediately
  • Health status of animals via activity detected using accelerometer
  • Monitoring eating activity using accelerometer 1
  • Environmental monitoring, using microphone to detect unwanted activity like cutting down trees
  • Adaptive signalling and routing for wireless transmission in Wireless Sensor networks
  • Electronic nose using arrays of MEMS detectors
  • Material identification using reflecive spectrometer 1

More notes on Applications

Motivation

  • Why the Future of Machine Learning is Tiny (devices) Tiny Computers are Already Cheap and Everywhere. Energy is the Limiting Factor.We Capture Much More Sensor Data Than We Use.
  • embedded.com: Bringing machine learning to the edge Predictions are much lower bandwidth than the raw sensor data (e.g. video) It allows for local adaptation in the AI logic (L-DNN) It achieves lower latency between observed event and action resulting from AI logic "the most important question is what is the least amount accuracy and computation complexity we can do while still delivering the business value?" Top mistake: "Continuing with the top down approach ‘let’s make it perform the task first and then squeeze it on device` instead of switching to bottom up ‘let’s make it run on device and fulfill all hardware constraints first, and then tune it for the task at hand’."
  • How to run deep learning model on microcontroller with CMSIS-NN. Why run deep learning model on a microcontroller? Sensitive data gets to the cloud, photos, and audio recordings. The company who sells this may charge a service fee to use its service and even worse sell your private data. It won't work without the network connection to the server. Data traveling back and forth between the device and server introduces lag. Require network and wireless hardware components on the circuit design which increase the cost. It might waste bandwidth sending useless data.

State of the Art in 2019

Of ML inference on general-purpose microcontrollers.

TODO: update for 2023
  • Deep models have efficient implementations for ARM Cortex-M. Ex: CNN and RNN in CMSIS-NN, FC in uTensor
  • Some implementations available for non-neural models that can be used. Ex: SVM,RF,AdaBoost in sklearn-porter
  • A few special-designed ML algorithms made. Ex: ProtoNN, Bonsai
  • Basic tools available for converting Tensorflow models
  • Keyword-spotting/wake-word on audio well established. Used in commercial products (Alexa etc)
  • Human activity detecton on accelerometers.
  • Computer vision is actively developed
  • Lots of research and many announcements of low-power co-processors, but little on market yet

Limitations

  • Neural models lacking for non-ARM micros. ESP8266/ESP32
  • Non-neural models missing inference engines designed for microcontrollers
  • "Small DNN" work mostly on computer vision for mobile phones (model size 1000x of uC)
  • Few/no pretrained models available. Transfer learning little explored?
  • Very little documentation of entire development process. From planning, data aquisition, model design
  • Best practices underdocumented (or underdeveloped?)

Ways of advancing, make contributions

  • Faster inference. Power saving, or bigger problems.
  • Smaller models. Cheaper MCU, or bigger problems.
  • Better accuracy on a problem. Better user experience, new usecases
  • Solve a concrete usecase. Easier to deploy similar usecases
  • Comparison between approaches. Microcontroller, ML model
  • Libraries or tools. Lower time to market, enable more developers

Learning material

Books

Articles

Tools

Open-source

  • emlearn. Inference engine for microcontrollers. Supports converting scikit-learn models to plain C code. No dynamic allocations. No runtime needed.
  • TensorFlow Lite for Microcontrollers. Supports neural network models made with TensorFlow (including Keras). Can run on wide range of platforms. Since November 2018. Supports ARM Cortex M, RISC-V, ESP32/Xtensa and Linux/MacOS host. Requires a runtime.
  • nnom - Fixed-point neural network compiler for microcontrollers. Supports wide range of networks. Outputs plain C code. Can use CMSIS-NN on ARM Cortex M.
  • Embedded Learning Library by Microsoft. Set of C++ libraries for machine learning on embedded platforms. Includes code for kNN, RandomForest etc. Also has some node-based dataflow system in place it seems. JavaScript and Python bindings.
  • ONNC project has a backend for ARM Cortex M (using CMSIS-NN) and a C backend. Allows to convert an ONNX models to run on devices.
  • nn4mc_cpp. Neural Networks for Microcontrollers. Supports Keras natively. Provides instructions for PyTorch et.c via ONNX. Documentation for using from Python is lacking, as well as the type of networks supported. Does not seem maintained since 2020.
  • sklearn-porter. Can compile DecisionTreeClassifier and SVC models to C. Uses dynamic memory. Not optimized for use on embedded devices.
  • microTVM. Depends only on the C standard library, and runs bare metal such as STM32 and NRF52 microcontrollers. Is under development. Which models are supported on microcontrollers not specified.

Proprietary

  • X-CUBE-AI for STM32

Models

A range of Machine Learning models are useful in an embedded devices setting. Classical methods are used when the amount of data is quite small, and neural networks for large datasets and complex inputs.

Below are notes on the various models in the context of embedded Machine Learning, including model size and compute-time optimization.

More topics

embeddedml's People

Contributors

jonnor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

embeddedml's Issues

Have you considered MXC4005XC for gyro sensor ?

I am following your research and efforts to build $1 TinyML device. I myself is designing a BLE beacon based on CH582F micro controller with analog temperature, light and I2C gyro sensors for around $1 in Tomu/Fomu/Bomu (neck pendant for elderly patient) format. As my pcb is 12x14 mm I was looking for smallest parts to fit on limited space on pcb and came across following part. I will be watching your progress specially for Microphone part which I would like to include in my design.

Have you considered MXC4005XC for gyro sensor ? It is very small size at reasonable price.

https://www.lcsc.com/product-detail/Attitude-Sensor-Gyroscope_MEMSIC-MXC4005XC_C404327.html

Thanks.

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.