TFLite to C++ Array ESP32

Ive been building a custom model for detection, and eventually tracking using YOLO11n. Building is fine, but when I try and convert the model down to a C++ array (for use on an ESP32S2 chip) Im seeing the file size jump significantly. So Im wondering if there is something I need to tweak in the model building.

Ill try and put in anything that could be relevant:

  • Initial image sizes: ~768x576 PNG files
  • Number used for the model: 100 images (for both training and validation)
  • Labeled with Label-Studio and exported out to YOLO format (manually created the yaml file)
  • Ultralytics version: 8.4.21

Training command:
yolo task=detect mode=train model="yolo11n.pt" data="dataset.yaml" epochs=50 imgsz=96 device=mps nms=false

Converting to TFLite:
yolo export model="/weights/best.pt" format=tflite imgsz=96 half=True int8=True device=mps data="dataset.yaml"

Image Size is set to 96 since thats all the model will see due to processing limits on the ESP32.

So after building the model:
best.pt → 5.2M
best_int8.tflite → 2.7M

Since I need to convert this to a c++ array:
xxd -i “/weights/best_saved_model/best_int8.tflite” > iris.cpp
iris.cpp → 16M

So Im trying to figure out why the model jumps in size when changing to the c++ array.

Ill move down to a 5n instead of the 11n model for training and check the sizes after that.

v5n: Looks like Id need to build a new conda env and build the 5n model. Ill try 8n for now:
This model is NOT forwards compatible with YOLOv8 at ``https://github.com/ultralytics/ultralytics``.

v8 cpp ended up at 19M