SunNet for the ACM/IEEE TinyML Contest at ICCAD 2022

Introduction

This is a repository for a TinyML machine learning algorithms accelerator on low-end microprocessors/microcontrollers specialized in life-threatening ventricular arrhythmias (VAs) detection.The design won second place in 2022 ACM/IEEE TinyML Design Contest @ ICCAD.

Designed by:

Jingwei Zhang, Chaoyao Shen, Xinye Cao, Yuning Ji, Yu Zhang, et al.

SEUer Group, Southeast University

Our design is based on SunNet, which is modified from [IEGMNet](tinyml_contest2022_demo_example/model_1.py at master · tinymlcontest/tinyml_contest2022_demo_example · GitHub). Compared with the latter, SunNet has reduced MACC by nearly 40 times, and more importantly, the accuracy still exceeds 3.2%. We are so persistent in improving the performance of SunNet in an all-round way because we want to provide a safer solution for every heart patient, and determined to be the sun to protects them.

Repo organization

Platform

NUCLEO-L432KC

Software prerequisites

[STM32CubeMX](STM32CubeMX - STM32Cube initialization code generator - STMicroelectronics)

ST-Link driver

MDK5

Build the deployed from scratch

PS: If you want to deploy our project directly to evaluate performance, you can start with step 4 Deployment on MCU.

  1. Training and weights file generation

    1. Download the ICCAD Tiny-ML training dataset.

    2. Set the dataset file path and start training:

      cd training/
      python train.py
    3. Convert the model to onnx format by running:

      python pkl2onnx.py 
  2. Generating C source code with STM32CubeAI

    In this step, the C++ source code is generated by STM32CubeMX and X-CUBE-AI 7.2.0. Officially provides detailed [documentation](tinyml_contest2022_demo_example/README-Cube.md at master · tinymlcontest/tinyml_contest2022_demo_example · GitHub) on how to generate keil projects by onnx model.

    Note: If there is a yellow exclamation mark in the Keil5 project generated, it means that the path is incorrect and needs to be changed manually to the corresponding path.

  3. Supporting evaluation framework

    The official does not use the Validation function with STM32CubeMX, but provides its own [evaluation framework](GitHub - tinymlcontest/tinyml_contest2022_demo_evaluation). Therefore the code used for PC communication through UART in the generated keil project needs to be replaced. Finally compile it!

    Note: In order to ensure that the program works properly, you need to enable Use MicroLIB under ‘ Options for Target → Target ’ page.

  4. Deployment on MCU

    We provide the compiled keil project in the deploy folder, you only need to open the keil project in the MDK-ARM folder, connect the board to PC, and click the Download button to your L432KC board.

    About validation

    Run the validation.py in the evaluation framework, when seeing the progress bar of tqdm, press the reset button on your board, and the validation will start.