TinyML: Getting Started with TensorFlow Lite for Microcontrollers | Digi-Key Electronics

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ต.ค. 2024
  • In this tutorial, Shawn shows you how to use the TensorFlow Lite for Microcontrollers library to perform machine learning tasks on embedded systems. Specifically, he uses the STM32CubeIDE, but TensorFlow Lite for Microcontrollers can be copied to almost any embedded build system.
    You will need first need to train a sample neural network by following the steps in this video: • Intro to TinyML Part 1... . Download all three model files (.h5, .tflite, .h).
    We show you how to generate the TensorFlow Lite for Microcontrollers source code files using the Make build system. Note that for this step, you will need access to Linux or macOS. From there, you can copy the model file and TensorFlow Lite source code files to your embedded project directory.
    We demonstrate how to include the necessary TensorFlow Lite source files and any changes that need to be made to them. After, we walk you through the code for running inference using the trained neural network.
    Finally, we measure the required flash and RAM used to run our basic neural network as well as the time it takes to run inference. These numbers can be used to compare against other machine learning frameworks, such as X-Cube-AI.
    Before starting, we recommend you watch the following videos:
    What is Edge AI • Intro to Edge AI: Mach...
    Getting Started with Machine Learning Using TensorFlow and Keras • Getting Started with T...
    Intro to TinyML Part 1: Training a Neural Network for Arduino in TensorFlow • Intro to TinyML Part 1...
    Product Links:
    Nucleo-L432KC - www.digikey.co...
    Related Videos:
    Intro to Edge AI
    • Intro to Edge AI: Mach...
    Getting Started with Machine Learning Using TensorFlow and Keras
    • Getting Started with T...
    Intro to TensorFlow Lite Part 1: Wake Word Feature Extraction
    • Intro to TensorFlow Li...
    Intro to TensorFlow Lite Part 2: Speech Recognition Model Training
    • Intro to TensorFlow Li...
    Intro to TensorFlow Lite Part 3: Speech Recognition on Raspberry Pi
    • Intro to TensorFlow Li...
    Low-Cost Data Acquisition (DAQ) with Arduino and Binho for Machine Learning
    • Low-Cost Data Acquisit...
    Intro to TinyML Part 1: Training a Neural Network for Arduino in TensorFlow
    • Intro to TinyML Part 1...
    Intro to TinyML Part 2: Deploying a TensorFlow Lite Model to Arduino
    • Intro to TinyML Part ...
    Edge AI Anomaly Detection Part 1: Data Collection
    • Edge AI Anomaly Detect...
    Edge AI Anomaly Detection Part 2: Feature Extraction and Model Training
    • Edge AI Anomaly Detect...
    Edge AI Anomaly Detection Part 3: Deploy Machine Learning Models to Raspberry Pi | Digi-Key
    • Edge AI Anomaly Detect...
    Edge AI Anomaly Detection Part 4: Deploy TinyML Model in Arduino to ESP32
    • Edge AI Anomaly Detect...
    Related Project Links:
    TinyML: Getting Started with TensorFlow Lite for Microcontrollers www.digikey.co...
    Related Articles:
    What is Edge AI?
    www.digikey.co...
    Getting Started with Machine Learning Using TensorFlow and Keras
    www.digikey.co...
    TensorFlow Lite Tutorials: www.digikey.co...
    Low-Cost Data Acquisition (DAQ) with Arduino and Binho for ML
    www.digikey.co...
    Intro to TinyML: www.digikey.co...
    Edge AI Anomaly Detection: www.digikey.co...

ความคิดเห็น • 61

  • @a1nelson
    @a1nelson 4 ปีที่แล้ว +28

    I feel like we just exited the Nürbergring with Sabine behind the wheel. Exhilarating, but fun. Usually, I like to walch tutorials at 1.25 or 1.5 X, but I might have to actually bump it below 1.0 in order to fully absorb all that info. And, this is from a professional C++ programmer with decades of experience on MCUs and other embedded misc. Great video. I really appreciate the honesty of those little conditional statements, like “ to my understanding”, and such. Keep it up.

    • @BeefIngot
      @BeefIngot 3 ปีที่แล้ว +5

      He's such a class programmer even his speech includes conditionals 😁

  • @akhaled4990
    @akhaled4990 3 ปีที่แล้ว +4

    This video tutorial is one of the best out there. Great, great work here Shawn!

  • @aisolutions834
    @aisolutions834 3 ปีที่แล้ว +6

    Thanks, Shawn, I think many people work with ESP32, will you teach us a TFLite conversion (image classification) on ESP32?

  • @Seff2
    @Seff2 3 ปีที่แล้ว +1

    Thank you so much. What a great tutorial. Would probably take even experienced dudes many many hours to get to this point.

  • @thauolar186
    @thauolar186 2 ปีที่แล้ว +8

    None of this works anymore in 2022, please update or take it down, I spent 2 days messing with stuff that does not work.

  • @erenoz2910
    @erenoz2910 ปีที่แล้ว +3

    The problem with these tutorials is that Tensorflow isn't a regular library but rather a moving maze. You can make a tutorial, and 5 seconds later it's completely obsolete because the entire project structure has changed.

  • @gustavodenardin
    @gustavodenardin 3 ปีที่แล้ว +4

    Hi. Really pretty cool. I'm trying to reproduce this example based on TensorFlow 2.4. However, i found an error in tflite::ops::micro::Register_FULLY_CONNECTED() line. I notice that it was a change in files for the 2.4 version, but i do not know how to adapt this line for the new version. Can you help me, please?

  • @jakobtschavoll6542
    @jakobtschavoll6542 3 ปีที่แล้ว +5

    Sadly, TF is changing so fast that most of the stuff shown after 5 minutes does not work anymore. TFlite micro has since been moved to its own repo and it's file structure changed, so this doesn't work anymore. This isn't easy to get into except for the examples that treat you like an idiot "precompiled-certified-arduino" - style. Maybe an update-video might be good to consider, since TFlite micro is now its own project.

    • @missraa.g
      @missraa.g 3 ปีที่แล้ว +1

      Yes, I'm working on it and getting into a lot of trouble given the scarcity of documentation on tflite-micro. Hope to see them make an updated video on it. Also if you have any good resource do share in comments. Thanks!

  • @pradeepr173
    @pradeepr173 4 ปีที่แล้ว +1

    We followed the steps suggested in STM32F407G, but the program is erroring out? which version of Tensorflow is used during demonstration?

    • @ShawnHymel
      @ShawnHymel 4 ปีที่แล้ว +2

      I cloned the TensorFlow reap head, which was 2.3.0 at the time.

  • @haoyuren7596
    @haoyuren7596 3 ปีที่แล้ว

    I'm new to the MCU world but with ML experience. I have a stupid question: is it possible to use TF Lite Micro Library, which is written in C++, in some existing C project? What should be taken care of?

  • @Curtis2255
    @Curtis2255 4 ปีที่แล้ว +2

    Why not just use STM32CubeAI to import your Keras model?

    • @ShawnHymel
      @ShawnHymel 4 ปีที่แล้ว +4

      I plan to cover CubeAI on the next episode and compare it to TensorFlow Lite for Microcontrollers. It's just another way to accomplish the same thing (both methods have their pros and cons) :)

  • @resatyigen3430
    @resatyigen3430 3 ปีที่แล้ว +2

    I'm getting an error while compiling please can you help me?
    Error : No rule to make target 'generate_non_kernel_projects'

    • @ShawnHymel
      @ShawnHymel 3 ปีที่แล้ว +1

      Unfortunately, it seems that the TensorFlow repo (especially the TFLite for Microcontrollers portion) is changing rapidly, which breaks a lot of features or old tutorials. I believe I cloned v2.3.0 when I made the video. Maybe see if it helps to roll back to that version?

    • @ShawnHymel
      @ShawnHymel 3 ปีที่แล้ว +1

      It looks like "generate_non_kernel_projects" was removed as a target from the Makefile in the recent version of TFLite for Microcontrollers. Try changing the target to "generate_projects" to see if that fixes things.

  • @kimsachala
    @kimsachala 15 วันที่ผ่านมา

    I want to use this .tflite model in android, will it work in android... @all if yes please suggest how to integrate the this model in android.

  • @Electronzap
    @Electronzap 4 ปีที่แล้ว +1

    Looks pretty cool :)

  • @almogstern5184
    @almogstern5184 3 ปีที่แล้ว +1

    Do these video instructions still hold true 1 year later? will this still work?
    thanks :)

    • @fabianaseidel7012
      @fabianaseidel7012 3 ปีที่แล้ว +3

      You should clone the repository tflite-micro instead of Tensorflow's and replace command make -f tensorflow/lite/micro/tools/make/Makefile TAGS="portable_optimized" generate_non_kernel_projects by make -f tensorflow/lite/micro/tools/make/Makefile generate_projects. The rest is working.

  • @marisettiakhil4182
    @marisettiakhil4182 4 หลายเดือนก่อน +1

    How to do this for windows

  • @stoforest2375
    @stoforest2375 3 ปีที่แล้ว +1

    This video may need an update.
    tensorflow throws this error message: make -f tensorflow/lite/micro/tools/make/Makefile TAGS="portable_optimized" generate_non_kernel_projects
    tensorflow/lite/micro/tools/make/Makefile:61: *** The TAGS command line option is no longer supported in the TFLM Makefile.. Stop.

    • @Seff2
      @Seff2 3 ปีที่แล้ว +1

      same problem. Anyone found a solution?

    • @Tehkbkshow
      @Tehkbkshow 3 ปีที่แล้ว +1

      I found a fix; you just need to use an older version of tensorflow that still supports TAGS. I did this by running the clone command like this:
      Git clone --branch r2.4 ...
      This copies files from an old release, 2.4, which still supports the commads used in this video.

    • @lokmanedemagh6780
      @lokmanedemagh6780 3 ปีที่แล้ว +1

      @@Tehkbkshow Please how did you do for the make command?

    • @Tehkbkshow
      @Tehkbkshow 3 ปีที่แล้ว +1

      @@lokmanedemagh6780 I used the same make command as showed in the video, the command you have to change is the git clone of tensorflow to clone branch r2.4 instead of the latest version. There should be other releases that also work but r2.4 is the one I used

    • @lokmanedemagh6780
      @lokmanedemagh6780 3 ปีที่แล้ว +1

      @@Tehkbkshow I am using a vm debiane 9 what about you?

  • @Mr-lm2dv
    @Mr-lm2dv 4 ปีที่แล้ว

    do *not* alias python3 to python in a .bashrc file but change the symbolic link in /usr/bin/python to point to python3 (will cause python six errors)

  • @jaybee1359
    @jaybee1359 3 ปีที่แล้ว +1

    Shawn (or anyone else that might be able to help), I tried running this and ran into some issues. When I eventually got to the line
    "make -f tensorflow/lite/micro/tools/make/Makefile TAGS=”portable_optimized” generate_non_kernel_projects"
    I got the error:
    "No rule to make target 'generate_non_kernal_projects. Stop."
    I removed that last line and tried it again and got the error:
    "error: macro names must be identifiers"
    I'm assuming this is an issue with the version of Tflowlite taken from the GIT directory? I ended up changing to depth from 1 and getting the whole GIT directory. What version did you use? Do you know any ways around this issue?
    Any help you can give me would be greatly appreciated! Have a number of applications for this and would much prefer to use the tensorflow lite library than the Cube AI approach (the open source nature of it makes it easier to work with other teams with more Tflow experience).
    Thanks!

    • @ShawnHymel
      @ShawnHymel 3 ปีที่แล้ว +2

      Unfortunately, it seems that the TensorFlow repo (especially the TFLite for Microcontrollers portion) is changing rapidly, which breaks a lot of features or old tutorials. I believe I cloned v2.3.0 when I made the video. Maybe see if it helps to roll back to that version?

  • @minoosh4532
    @minoosh4532 2 หลายเดือนก่อน

    tnx

  • @irtiqaCreates
    @irtiqaCreates ปีที่แล้ว

    How to do this stuff in 2023?

  • @userou-ig1ze
    @userou-ig1ze 4 ปีที่แล้ว +3

    too complicated...

  • @aysebeyzaunal3472
    @aysebeyzaunal3472 3 ปีที่แล้ว

    can we do it in windows?

    • @dheidmusic
      @dheidmusic 2 ปีที่แล้ว

      Nope, Linux or Mac only.

    • @marisettiakhil4182
      @marisettiakhil4182 4 หลายเดือนก่อน

      Did you find any way to do in windows ??Please help