Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Tensorflow Lite MicroPython support?

    Scheduled Pinned Locked Moved Firmware
    15 Posts 2 Posters 45 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      Adnan Sabovic 0
      last edited by

      Hello everyone,

      I am just wondering is there any possibility to upload esp32 firmware, which enables TensorFlow Lite features, on the FiPy board? I was following the instruction found in this repo https://github.com/mocleiri/tensorflow-micropython-examples, but it's not possible to connect with my FiPy and upload this firmware on it. I am constantly getting this error:

      esptool.FatalError: Failed to connect to ESP32 : Invalid head on packet 0x08.

      Does anyone know how to fix this issue, or the solution is to buy esp32 for this purpose?

      Thanks and cheers!

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @Adnan Sabovic 0
        last edited by

        @Adnan-Sabovic-0 you have to connect P2 to Gnd and push reset, to set the ESP32 into bootloader mode. The mechanisms required by esptool and implement by Pycom are incompatible.

        1 Reply Last reply Reply Quote 0
        • A Offline
          Adnan Sabovic 0
          last edited by

          Hi, it worked when I connected P2 and GND. I was able to upload the firmware successfully. But now I am facing another issue: OSError: [Errno 2] ENOENT. Is it possible that I uploaded the wrong firmware version? I built standard non-psram 4MB Flash firmware. Is it okay, or I should consider another version?

          The possible versions can be found on this link:
          https://github.com/mocleiri/tensorflow-micropython-examples/actions/runs/1986616446

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @Adnan Sabovic 0
            last edited by

            @Adnan-Sabovic-0 It means that files are missing, like boot.py or main.py. If you installed a fresh firmware, you start with an empty file system. What do you get when you type:

            import os
            print(os.listdir(""))

            What do the instructions tell about using tensorflow?

            A robert-hhR 2 Replies Last reply Reply Quote 0
            • A Offline
              Adnan Sabovic 0 @robert-hh
              last edited by

              @robert-hh This is the output when I typed your commands in Pymakr terminal:

              >>> import os 
              >>> print(os.listdir(""))
              ['boot.py', 'esp32-cam', 'images', 'main.py', 'project.pymakr', 'show-test-images.py']
              

              I completely followed these instructions: https://github.com/mocleiri/tensorflow-micropython-examples/runs/5553454051?check_suite_focus=true

              After I set up everything and built tensorflow, all I needed to do is to choose the right firmware for my board. Once this job is finished, I supposed to be able to run the example (person detection), but then this problem occurs. The problem is detected after this line is called:

              person_detection_model_file = open ('person_detect_model.tflite', 'rb')
              

              which means that maybe the problem is related to model that is uploaded with tensorflow?

              1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @robert-hh
                last edited by

                @robert-hh you script tries to open the file person_detect_model.tflite at the local file system, but it does not exist. You have to create or upload it to the board.

                A 1 Reply Last reply Reply Quote 0
                • A Offline
                  Adnan Sabovic 0 @robert-hh
                  last edited by

                  @robert-hh I already have it. It is not possible to upload it via Pymark terminal in VS Code?

                  robert-hhR 1 Reply Last reply Reply Quote 0
                  • robert-hhR Offline
                    robert-hh @Adnan Sabovic 0
                    last edited by

                    @Adnan-Sabovic-0 Since you are not using the Pycom firmware, pymakr may not work. Try other tools for uploading like rshell https://pypi.org/project/rshell/ or mpremote https://pypi.org/project/mpremote/ . Both offer a REPL console as well. These are command line based tools, so they may look a little uncomfortable at the first moment. But once you get used to it, you'll see that it is way more robust than using an API like pymakr of Thonny.

                    A 1 Reply Last reply Reply Quote 0
                    • A Offline
                      Adnan Sabovic 0 @robert-hh
                      last edited by

                      @robert-hh I installed rshell and ran in my Ubuntu terminal. I am still confused how to upload here all files from the example folder. I can list them all:

                      on-examples/examples/person_test> ls -lthon-examples/tensorflow-micropytho
                        1316 Apr 15 12:15 main.py
                        9216 Apr 11 14:52 no_person_image_data.dat
                      300568 Apr 11 14:52 person_detect_model.tflite
                        9216 Apr 11 14:52 person_image_data.dat
                      

                      And then I tried to run REPL and import main, but again same error as before. Then I imported microlite from main file but after I imported main again, still no any message. Where did I make mistakes?

                      robert-hhR 1 Reply Last reply Reply Quote 0
                      • robert-hhR Offline
                        robert-hh @Adnan Sabovic 0
                        last edited by

                        @Adnan-Sabovic-0 The files on the board should be available under the path /esp32. In rshell, try:

                        ls /esp32

                        To put files there, just copy the to /esp32 with

                        cp source_file target_file

                        Target file names must start with /esp32/

                        A 1 Reply Last reply Reply Quote 0
                        • A Offline
                          Adnan Sabovic 0 @robert-hh
                          last edited by Adnan Sabovic 0

                          @robert-hh I have a small update, I am able to upload all the necessary files to my board. In my case it was ls /pyboard instead of ls /esp32. The new problem that occurred is related to memory allocation. Based on the code, it allocates 300568 bytes. Do you maybe know where can be a possible issue with memory part?

                          robert-hhR 1 Reply Last reply Reply Quote 0
                          • robert-hhR Offline
                            robert-hh @Adnan Sabovic 0
                            last edited by

                            @Adnan-Sabovic-0 Sometimes its /pyboard, sometimes /esp32. In case of a RAM shortage, use a firmware image with SPIRAM support, if available.

                            A 1 Reply Last reply Reply Quote 0
                            • A Offline
                              Adnan Sabovic 0 @robert-hh
                              last edited by

                              @robert-hh Do I need to upload a new firmware then and remove the existing one, or there is another way of using a firmware image with SPIRAM support?

                              robert-hhR 1 Reply Last reply Reply Quote 0
                              • robert-hhR Offline
                                robert-hh @Adnan Sabovic 0
                                last edited by

                                @Adnan-Sabovic-0 You have to upload the new firmware. But now, that you know how it is not a big thing.

                                A 1 Reply Last reply Reply Quote 0
                                • A Offline
                                  Adnan Sabovic 0 @robert-hh
                                  last edited by

                                  @robert-hh Yes, indeed! I uploaded the new firmware and now everything works as expected. Thanks a lot for help and advices that you gave me!

                                  1 Reply Last reply Reply Quote 0

                                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                  With your input, this post could be even better 💗

                                  Register Login
                                  • 1 / 1
                                  • First post
                                    Last post

                                  Pycom on Twitter

                                  Pycom