T4.0 plus Teachable Machine

Hello, I'm curious if Teachable Machine could be used to build a model and used on T4.0? My experimentation has failed so far, and I don't see any other posts on this forum on the topic. My goal is to build a model for image classification. While searching this forum, the main reference for TensorFlow seems to be https://forum.pjrc.com/threads/57441-Tensorflow-on-Teensy which I have reviewed. I am using Arduino_TensorFlowLite_t4 but I agree with @randomvibe that it would be nice if a T4 friendly version of TFLite was added to teensyduino.

A quick overview on a boiled down test I did. In Teachable Machine, I started a new "Image Project" and selected "Embedded image model" [link]. I used two classes (Class 1 & Class 2) and uploaded several pictures in each class. Then trained the embedded model. After being satisfying with the model's performance, I selected "Export Model". On the resulting popup, I chose "Tensorflow Lite" and selected the model conversion type "TensorFlow Lite for Microcontrollers". After downloading the model, I unzipped it and ran "tmp_template_script.ino" which opened in Arduino IDE version 1.8.19. Trying to Verify the sketch generated by Teachable Machine results in the following compile error:

Compile error:
Code:
Arduino: 1.8.19 (Windows 10), TD: 1.56, Board: "Teensy 4.0, Serial, 528 MHz, Faster, US English"

tm_template_script: In function 'void loop()':

tm_template_script:114: warning: unused variable 'person_score' 

   int8_t person_score = output->data.uint8[kPersonIndex];

          ^

tm_template_script:115: warning: unused variable 'no_person_score' 

   int8_t no_person_score = output->data.uint8[kNotAPersonIndex];

          ^

Library Arduino_TensorFlowLite_t4 has been declared precompiled:

Precompiled library in "C:\Users\Me\Documents\Arduino\libraries\Arduino_TensorFlowLite_t4\src\imxrt1062\fpv5-d16-hard" not found

Precompiled library in "C:\Users\Me\Documents\Arduino\libraries\Arduino_TensorFlowLite_t4\src\imxrt1062" not found

The platform does not support 'compiler.libraries.ldflags' for precompiled libraries.

In file included from C:\Users\Me\Documents\Arduino\libraries\Arduino_TensorFlowLite_t4\src\tensorflow\lite\micro\kernels\detection_postprocess.cpp:19:0:

C:\Users\Me\Documents\Arduino\libraries\Arduino_TensorFlowLite_t4\src/third_party/flatbuffers/include/flatbuffers/flexbuffers.h: In member function 'double flexbuffers::Reference::AsDouble() const':

C:\Users\Me\Documents\Arduino\libraries\Arduino_TensorFlowLite_t4\src/third_party/flatbuffers/include/flatbuffers/flexbuffers.h:498:32: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]

 #pragma GCC diagnostic ignored "-Wnull-dereference"

                                ^

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Me\AppData\Local\Temp\arduino_build_37716/tm_template_script.ino.elf section `.data' will not fit in region `DTCM'

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: address 0x200a83a0 of C:\Users\Me\AppData\Local\Temp\arduino_build_37716/tm_template_script.ino.elf section `.bss' is not within region `DTCM'

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: address 0x200a83a0 of C:\Users\Me\AppData\Local\Temp\arduino_build_37716/tm_template_script.ino.elf section `.bss' is not within region `DTCM'

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: region `DTCM' overflowed by 164768 bytes

C:\Users\Me\AppData\Local\Temp\arduino_build_37716\sketch\tm_template_script.ino.cpp.o: In function `loop':

C:\Users\Me\Downloads\converted_tinyml\tm_template_script/tm_template_script.ino:101: undefined reference to `GetImage(tflite::ErrorReporter*, int, int, int, signed char*)'

collect2.exe: error: ld returned 1 exit status

Error compiling for board Teensy 4.0.

Removing the undefined reference to GetImage() throws a new compile error:
Code:
Arduino: 1.8.19 (Windows 10), TD: 1.56, Board: "Teensy 4.0, Serial, 528 MHz, Faster, US English"

tm_template_script: In function 'void loop()':

tm_template_script:114: warning: unused variable 'person_score' 

   int8_t person_score = output->data.uint8[kPersonIndex];

          ^

tm_template_script:115: warning: unused variable 'no_person_score' 

   int8_t no_person_score = output->data.uint8[kNotAPersonIndex];

          ^

Library Arduino_TensorFlowLite_t4 has been declared precompiled:

Precompiled library in "C:\Users\Me\Documents\Arduino\libraries\Arduino_TensorFlowLite_t4\src\imxrt1062\fpv5-d16-hard" not found

Precompiled library in "C:\Users\Me\Documents\Arduino\libraries\Arduino_TensorFlowLite_t4\src\imxrt1062" not found

The platform does not support 'compiler.libraries.ldflags' for precompiled libraries.

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Me\AppData\Local\Temp\arduino_build_37716/tm_template_script.ino.elf section `.data' will not fit in region `DTCM'

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: address 0x200a83a0 of C:\Users\Me\AppData\Local\Temp\arduino_build_37716/tm_template_script.ino.elf section `.bss' is not within region `DTCM'

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: address 0x200a83a0 of C:\Users\Me\AppData\Local\Temp\arduino_build_37716/tm_template_script.ino.elf section `.bss' is not within region `DTCM'

c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: region `DTCM' overflowed by 164768 bytes

collect2.exe: error: ld returned 1 exit status

Error compiling for board Teensy 4.0.
 
Back
Top