journal article·2025-02-13Open access

Implementing Deep Neural Networks on ARM-Based Microcontrollers: Application for Ventricular Fibrillation Detection

Vessela Krasteva, Todor Stoyanov, Irena Jekova

Applied Sciences· Volume 15· Issue 4

Abstract

GPU-based deep neural networks (DNNs) are powerful for electrocardiogram (ECG) processing and rhythm classification. Although questions often arise about their practical application in embedded systems with low computational resources, few studies have investigated the associated challenges. This study aims to show a useful workflow for deploying a pre-trained DNN model from a GPU-based development platform to two popular ARM-based microcontrollers: Raspberry Pi 4 and ARM Cortex-M7. Specifically, a five-layer convolutional neural network pre-trained in TensorFlow (TF) for the detection of ventricular fibrillation is converted to Lite Runtime (LiteRT) format and subjected to post-training quantization to reduce model size and computational complexity. Using a test dataset of 7482 10 s cardiac arrest ECGs, the inference of LiteRT DNN in Raspberry Pi 4 takes about 1 ms with a sensitivity of 98.6% and specificity of 99.5%, reproducing the TF DNN performance. An optimization study with 1300 representative datasets (RDSs), including 10 to 4000 calibration ECG signals selected by random, rhythm, or amplitude-based criteria, showed that choosing a random RDS with a relatively small size of 80 resulted in a quantized integer LiteRT DNN with minimal quantization error. The inference of both non-quantized and quantized LiteRT DNNs on a low-resource ARM Cortex-M7 microcontroller (STM32F7) shows rhythm accuracy deviation of <0.4%. Quantization reduces internal computation latency from 4.8 s to 0.6 s, flash memory usage from 40 kB to 20 kB, and energy consumption by 7.85 times. This study ensures that DNN models retain their functionality while being optimized for real-time execution on resource-constrained hardware, demonstrating application in automated external defibrillators.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: ECG Monitoring and Analysis

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

Institute of Biophysics and Biomedical Engineering, Bulgarian Academy of Sciences, Acad. G. Bonchev Str. Bl 105, 1113 Sofia, Bulgaria

Funding

Bulgarian National Science Fund

References (90)

Show source-provided references
1. Subasi, A. (2020). Chapter 3—Machine learning techniques. Practical Machine Learning for Data Analysis Using Python, Academic Press. [1st ed.].10.1016/B978-0-12-821379-7.00003-5 ↗
2. Goodfellow, I., Bengio, Y., and Courville, A. (2016). Deep Learning, The MIT Press.
3. Lucan Orasan, I., Seiculescu, C., and Caleanu, C.D. (2022). A Brief Review of Deep Neural Network Implementations for ARM Cortex-M Processor. Electronics, 11.10.3390/electronics11162545 ↗
4. Embedded Machine Learning Using Microcontrollers in Wearable and Ambulatory Systems for Health and Care Applications: A Review10.1109/ACCESS.2022.3206782 ↗
5. Warden, P., and Situnayake, D. (2019). TinyML: Machine Learning with TensorFlow Lite on Arduino and Ultra-Lowpower Microcontrollers, O’Reilly Media. [1st ed.].
6. TinyML-Based Classification in an ECG Monitoring Embedded System
7. Farag, M.M. (2023). A Tiny Matched Filter-Based CNN for Inter-Patient ECG Classification and Arrhythmia Detection at the Edge. Sensors, 23.10.3390/s23031365 ↗
8. Tiny Machine Learning for Resource-Constrained Microcontrollers10.1155/2022/7437023 ↗
9. Edge computing: Vision and challenges10.1109/JIOT.2016.2579198 ↗
10. Deep Model Compression and Architecture Optimization for Embedded Systems: A Survey10.1007/s11265-020-01596-1 ↗
11. A Tiny Transformer for Low-Power Arrhythmia Classification on Microcontrollers
12. Implementing ultra-lightweight co-inference model in ubiquitous edge device for atrial fibrillation detection10.1016/j.eswa.2022.119407 ↗
13. Gragnaniello, M., Borghese, A., Marrazzo, V.R., Maresca, L., Breglio, G., Irace, A., and Riccio, M. (2024). Real-Time Myocardial Infarction Detection Approaches with a Microcontroller-Based Edge-AI Device. Sensors, 24.10.3390/s24030828 ↗
14. Zhao, X., Xu, R., and Guo, X. (2023, January 26–27). Post-training Quantization or Quantization-aware Training? That is the Question. Proceedings of the China Semiconductor Technology International Conference (CSTIC), Shanghai, China.10.1109/CSTIC58779.2023.10219214 ↗
15. Novac, P.-E., Boukli Hacene, G., Pegatoquet, A., Miramond, B., and Gripon, V. (2021). Quantization and Deployment of Deep Neural Networks on Microcontrollers. Sensors, 21.10.3390/s21092984 ↗
16. De Melo Ribeiro, H., Arnold, A., Howard, J.P., Shun-Shin, M.J., Zhang, Y., Francis, D.P., Lim, P.B., Whinnett, Z., and Zolgharni, M. (2022). ECG-based real-time arrhythmia monitoring using quantized deep neural networks: A feasibility study. Comput. Biol. Med., 143.10.1016/j.compbiomed.2022.105249 ↗
17. Wei, L., Ma, Z., Yang, C., and Yao, Q. (2024). Advances in the Neural Network Quantization: A Comprehensive Review. Appl. Sci., 14.10.20944/preprints202407.0076.v1 ↗
18. A simple approach for quantizing neural networks10.1016/j.acha.2023.04.004 ↗
19. Tang, W., Hua, G., and Wang, L. (2017). How to Train a Compact Binary Neural Network with High Accuracy?, AAAI.10.1609/aaai.v31i1.10862 ↗
20. Pal Chowdhury, A., Kulkarni, P., and Nazm Bojnordi, M. (2018). MB-CNN: Memristive Binary Convolutional Neural Networks for Embedded Mobile Devices. J. Low Power Electron. Appl., 8.10.3390/jlpea8040038 ↗
21. TensorFlow (2024, November 28). Pruning Comprehensive Guide. Available online: https://www.tensorflow.org/model_optimization/guide/pruning/comprehensive_guide.
22. Scalpel: Customizing DNN pruning to the underlying hardware parallelism10.1145/3140659.3080215 ↗
23. Google (2024, November 28). TensorFlow Model Optimization. Available online: https://www.tensorflow.org/model_optimization/guide.
24. Extensible Embedded Processor for Convolutional Neural Networks
25. Machine learning algorithms for FPGA Implementation in biomedical engineering applications: A review10.1016/j.heliyon.2024.e26652 ↗
26. Neural Networks Implementations on FPGA for Biomedical Applications: A Review10.1007/s42979-024-03381-4 ↗
27. Sanaullah, A., Yang, C., Alexeev, Y., Yoshii, K., and Herbordt, M.C. (2018). Real-time data analysis for medical diagnosis using FPGA-accelerated neural networks. BMC Bioinform., 19.10.1186/s12859-018-2505-7 ↗
28. (2024, November 28). CMSIS NN Software Library. Available online: https://arm-software.github.io/CMSIS-NN/latest/index.html.
29. (2024, November 28). LiteRT for Microcontrollers. Available online: https://ai.google.dev/edge/litert/microcontrollers/overview.
30. (2024, November 28). uTensor: TinyML AI Inference Library. Available online: https://github.com/uTensor/uTensor.
31. (2024, November 28). PyTorch Mobile: End-to-End Workflow from Training to Deployment for iOS and Android Mobile Devices. Available online: https://pytorch.org/mobile/home/.
32. STMicroelectronics (2024, November 28). X-CUBE-AI—AI Expansion Pack for STM32CubeMX. Available online: http://www.st.com/en/embedded-software/x-cube-ai.html.
33. ECG heartbeat classification using convolutional neural networks10.1109/ACCESS.2020.2964749 ↗
34. Heartbeat Classification Using 1D Convolutional Neural Networks10.1007/978-3-030-31129-2_46 ↗
35. Multiscaled Fusion of Deep Convolutional Neural Networks for Screening Atrial Fibrillation from Single Lead Short ECG Recordings10.1109/JBHI.2018.2858789 ↗
36. Densely connected convolutional networks for detection of atrial fibrillation from short single-lead ECG recordings10.1016/j.jelectrocard.2018.08.008 ↗
37. Analyzing single-lead short ECG recordings using dense convolutional neural networks and feature-based post-processing to detect atrial fibrillation10.1088/1361-6579/aad5bd ↗
38. Kalman-based spectro-temporal ECG analysis using deep convolutional networks for atrial fibrillation detection10.1007/s11265-020-01531-4 ↗
39. Automated detection of arrhythmias using different intervals of tachycardia ECG segments with convolutional neural network10.1016/j.ins.2017.04.012 ↗
40. Computer aided detection for fibrillations and flutters using deep convolutional neural network10.1016/j.ins.2019.02.065 ↗
41. Tutuko, B., Nurmaini, S., Tondas, A.E., Rachmatullah, M.N., Darmawahyuni, A., Esafri, R., Firdaus, F., and Sapitri, A.I. (2021). AFibNet: An implementation of atrial fibrillation detection with convolutional neural network. BMC Med. Inf. Decis. Mak., 21.10.1186/s12911-021-01571-1 ↗
42. Robust detection of atrial fibrillation from short-term electrocardiogram using convolutional neural networks10.1016/j.future.2020.07.021 ↗
43. A novel hybrid network of fusing rhythmic and morphological features for atrial fibrillation detection on mobile ECG signals10.1007/s00521-019-04318-2 ↗
44. Detecting atrial fibrillation by deep convolutional neural networks10.1016/j.compbiomed.2017.12.007 ↗
45. An artificial intelligence enabled ECG algorithm for the identification of patients with atrial fibrillation during sinus rhythm: A retrospective analysis of outcome prediction10.1016/S0140-6736(19)31721-0 ↗
46. Non-standardized patch-based ECG lead together with deep learning based algorithm for automatic screening of atrial fibrillation10.1109/JBHI.2020.2980454 ↗
47. Zhang, C.-J., Lu, Y., Tang, F.-Q., Cai, H.-P., Qian, Y.-F., and Wang, C. (2024). Heart failure classification using deep learning to extract spatiotemporal features from ECG. BMC Med. Inf. Decis. Mak., 24.10.1186/s12911-024-02415-4 ↗
48. A Simple and Effective Method for Detecting Myocardial Infarction Based on Deep Convolutional Neural Network10.1166/jmihi.2018.2463 ↗
49. Myocardial Infarction Detection Based on Deep Neural Network on Imbalanced Data10.1007/s00530-020-00728-8 ↗
50. Rawal, V., Prajapati, P., and Darji, A. (2023). Hardware Implementation of 1D-CNN Architecture for ECG Arrhythmia Classification. Biomed. Sig. Proc. Contr., 85.10.1016/j.bspc.2023.104865 ↗
51. Accelerating deep convolutional neural network on FPGA for ECG signal classification10.1016/j.micpro.2023.104939 ↗
52. Sá, P., Aidos, H., Roma, N., and Tomás, P. (2019, January 2–6). Heart Disease Detection Architecture for Lead I Off-the-Person ECG Monitoring Devices. Proceedings of the 27th European Signal Processing Conference (EUSIPCO), A Coruna, Spain.10.23919/EUSIPCO.2019.8902791 ↗
53. A 13.34 μW Event Driven Patient-Specific ANN Cardiac Arrythmia Classification for Wearable ECG Sensors10.1109/TBCAS.2019.2954479 ↗
54. Lu, J., Liu, D., Hu, A., Zhang, C., Mo, C., Guo, R., and Li, H. (2022, January 25–28). A Low-cost and Configurable Hardware Architecture of Sparse 1-D CNN for ECG Classification. Proceedings of the 2022 IEEE 16th International Conference on Solid-State & Integrated Circuit Technology (ICSICT), Nangjing, China.10.1109/ICSICT55466.2022.9963366 ↗
55. Homecare-Oriented ECG Diagnosis With Large-Scale Deep Neural Network for Continuous Monitoring on Embedded Devices10.1109/TIM.2022.3147328 ↗
56. An Efficient Unstructured Sparse Convolutional Neural Network Accelerator for Wearable ECG Classification Device10.1109/TCSI.2022.3194636 ↗
57. Faraone, A., and Delgado-Gonzalo, R. (September, January 31). Convolutional-recurrent neural networks on low-power wearable platforms for cardiac arrhythmia detection. Proceedings of the 2nd IEEE International Conference on Artificial Intelligence Circuits and Systems (AICAS), Genova, Italy.
58. Ingolfsson, T.M., Wang, X., Hersche, M., Burrello, A., Cavigelli, L., and Benini, L. (2021, January 6–9). ECG-TCN: Wearable cardiac arrhythmia detection with a temporal convolutional network. Proceedings of the IEEE 3rd International Conference on Artificial Intelligence Circuits and Systems (AICAS), Washington, DC, USA.10.1109/AICAS51828.2021.9458520 ↗
59. Kim, S., Chon, S., Kim, J.-K., Kim, J., Gil, Y., and Jung, S. (2022, January 11–15). Lightweight Convolutional Neural Network for Real-Time Arrhythmia Classification on Low-Power Wearable Electrocardiograph. Proceedings of the 44th Annual International Conference of the IEEE Engineering in Medicine & Biology Society (EMBC), Scottish Event Campus, Glasgow, UK.10.1109/EMBC48229.2022.9871156 ↗
60. Efficient Edge-AI Models for Robust ECG Abnormality Detection on Resource-Constrained Hardware10.1007/s12265-024-10504-y ↗
61. ANNet: A Lightweight Neural Network for ECG Anomaly Detection in IoT Edge Sensors10.1109/TBCAS.2021.3137646 ↗
62. Elola, A., Aramendi, E., Irusta, U., Picón, A., Alonso, E., Owens, P., and Idris, A. (2019). Deep Neural Networks for ECG-Based Pulse Detection during Out-of-Hospital Cardiac Arrest. Entropy, 21.10.3390/e21030305 ↗
63. Nguyen, M.T., and Kiseon, K. (2018, January 25–27). Feature Learning Using Convolutional Neural Network for Cardiac Arrest Detection. Proceedings of the 2018 International Conference on Smart Green Technology in Electrical and Information Systems (ICSGTEIS), Bali, Indonesia.10.1109/ICSGTEIS.2018.8709100 ↗
64. Automated identification of shockable and non-shockable life-threatening ventricular arrhythmias using convolutional neural network10.1016/j.future.2017.08.039 ↗
65. Deep learning approach for a shock advise algorithm using short electrocardiogram analysis intervals10.1016/j.resuscitation.2019.06.206 ↗
66. Picon, A., Irusta, U., lvarez-Gila, A., Aramendi, E., Alonso-Atienza, F., Figuera, C., Ayala, U., Garrote, E., Wik, L., and Kramer-Johansen, J. (2019). Mixed convolutional and long short-term memory network for the detection of lethal ventricular arrhythmia. PLoS ONE, 14.10.1371/journal.pone.0216756 ↗
67. Krasteva, V., Ménétré, S., Didon, J.-P., and Jekova, I. (2020). Fully Convolutional Deep Neural Networks with Optimized Hyperparameters for Detection of Shockable and Non-Shockable Rhythms. Sensors, 20.10.3390/s20102875 ↗
68. Isasi, I., Irusta, U., Aramendi, E., Eftestøl, T., Kramer-Johansen, J., and Wik, L. (2020). Rhythm Analysis during Cardiopulmonary Resuscitation Using Convolutional Neural Networks. Entropy, 22.10.3390/e22060595 ↗
69. Isasi, I., Irusta, U., Aramendi, E., Olsen, J.-Å., and Wik, L. (2020, January 13–16). Detection of shockable rhythms using convolutional neural networks during chest compressions provided by a load distributing band. Proceedings of the 2020 Computing in Cardiology Conference (CinC), Rimini, Italy.10.22489/CinC.2020.045 ↗
70. Deep Neural Network Approach for Continuous ECG-Based Automated External Defibrillator Shock Advisory System During Cardiopulmonary Resuscitation10.1161/JAHA.120.019065 ↗
71. Transfer learning based deep network for signal restoration and rhythm analysis during cardiopulmonary resuscitation using only the ECG waveform10.1016/j.ins.2023.01.055 ↗
72. Jekova, I., and Krasteva, V. (2021). Optimization of End-to-End Convolutional Neural Networks for Analysis of Out-of-Hospital Cardiac Arrest Rhythms during Cardiopulmonary Resuscitation. Sensors, 21.10.3390/s21124105 ↗
73. Krasteva, V., Didon, J.-P., Ménétré, S., and Jekova, I. (2023). Deep Learning Strategy for Sliding ECG Analysis during Cardiopulmonary Resuscitation: Influence of the Hands-Off Time on Accuracy. Sensors, 23.10.3390/s23094500 ↗
74. Convolution Neural Network Algorithm for Shockable Arrhythmia Classification Within a Digitally Connected Automated External Defibrillator10.1161/JAHA.122.026974 ↗
75. (2024, November 28). LiteRT Overview. Available online: https://ai.google.dev/edge/litert.
76. (2024, November 28). Model Conversion Overview. Available online: https://ai.google.dev/edge/litert/models/convert.
77. (2024, November 28). Post-Training Quantization. Available online: https://ai.google.dev/edge/litert/models/post_training_quantization.
78. (2024, November 28). LiteRT 8-Bit Quantization Specification. Available online: https://ai.google.dev/edge/litert/models/quantization_spec.
79. (2024, November 28). Raspberry Pi. Available online: https://www.raspberrypi.com/products/raspberry-pi-4-model-b/specifications/.
80. (2024, November 28). Discovery Kit with STM32F769NI MCU. Available online: https://www.st.com/en/evaluation-tools/32f769idiscovery.html.
81. (2024, November 28). Integrated Development Environment for STM32. Available online: https://www.st.com/en/development-tools/stm32cubeide.html.
82. European Resuscitation Council Guidelines for Resuscitation 2010 Section 2. Adult basic life support and use of automated external defibrillators10.1016/j.resuscitation.2010.08.009 ↗
83. European Resuscitation Council Guidelines for Resuscitation 2015: Section 2. Adult basic life support and automated external defibrillation10.1016/j.resuscitation.2015.07.015 ↗
84. Automatic External Defibrillators for Public Access Defibrillation: Recommendations for Specifying and Reporting Arrhythmia Analysis Algorithm Performance, Incorporating New Waveforms, and Enhancing Safety10.1161/01.CIR.95.6.1677 ↗
85. OoD-Control: Generalizing Control in Unseen Environments10.1109/TPAMI.2024.3395484 ↗
86. (2023, July 07). TensorFlow Lite for Microcontrollers. Available online: https://github.com/tensorflow/tflite-micro.
87. Huber, P., Göhner, U., Trapp, M., Zender, J., and Lichtenberg, R. (2024, January 24–27). Analysis of Neural Network Inference Response Times on Embedded Platforms. Proceedings of the 2024 Asian Conference on Communication and Networks (ASIANComNet), Bangkok, Thailand.10.1109/ASIANComNet63184.2024.10811052 ↗
88. (2024, November 28). Ultra-Low-Power with FPU Arm Cortex-M4 MCU 80 MHz with 1 Mbyte of Flash Memory, USB OTG, DFSDM. Available online: https://www.st.com/en/microcontrollers-microprocessors/stm32l475vg.html.
89. (2024, November 28). Nordic Semiconductor nRF52 Series SoCs. Available online: https://www.mouser.bg/new/nordic-semiconductor/nrf52-series-soc/.
90. (2024, November 28). Nordic Semiconductor nRF52840 Multi-Protocol 2.4GHz SoC. Available online: https://www.mouser.bg/new/nordic-semiconductor/nordic-nrf52840-soc/.