Supported Frameworks
Proton AI Core works with the following edge AI frameworks:- TensorFlow Lite for Microcontrollers (TFLM) — the primary framework for on-device inference on the ESP32-S3. It supports INT8 quantized models and integrates directly with the ESP-IDF and Arduino ecosystems.
- Edge Impulse — a cloud-based platform for model training, optimization, and deployment. Edge Impulse can generate a ready-to-flash Arduino or PlatformIO library for your trained model.
Additional framework support is planned with the Proton AI Platform.
Installing TensorFlow Lite Micro
- Arduino IDE
- PlatformIO
Open the Library Manager (Sketch → Include Library → Manage Libraries), search for
Arduino_TensorFlowLite, and install the latest available version.Library version availability varies between registries. For the latest ESP32-S3-specific optimizations, refer to the Espressif TFLite Micro fork: https://github.com/espressif/tflite-micro-esp-examples
Model Preparation
Before you can run inference on-device, you need to convert your trained model into a C byte array that can be compiled into your firmware.Obtain a .tflite model
Train or download a
.tflite model for your target task — for example, image classification or person detection. Espressif’s tflite-micro-esp-examples repository includes pre-built models to get you started.Convert the model to a C byte array
Use the This produces a
xxd command-line tool to generate a header file from your model file:model_data.h file containing a unsigned char array. When the input file is named model.tflite, xxd names the array model_tflite. Update the array name in your code if your filename differs.Running Inference
The snippet below shows a minimal TFLite Micro inference loop. It loads the model, allocates tensors, copies image data into the input tensor, invokes the interpreter, and reads the output score. This example assumes a float32 model; see the note below for INT8 quantized models.inference.cpp
For INT8 quantized models, the input tensor uses
input->data.int8 (or input->data.uint8 for unsigned quantization) and the output tensor uses output->data.int8. You must also apply the tensor’s quantization scale and zero-point to convert raw INT8 values to meaningful scores. INT8 models run significantly faster on the ESP32-S3 and are recommended for production use.Performance Tips
Getting the best inference speed on the ESP32-S3 requires a few deliberate choices at both the model and firmware levels:-
Allocate the tensor arena in PSRAM. Proton AI Core includes 8 MB of PSRAM. For large models, allocate the tensor arena dynamically using
heap_caps_mallocto avoid exhausting the 512 KB of internal SRAM:For small models that fit comfortably in internal SRAM, a static declaration (uint8_t tensor_arena[kTensorArenaSize]) is simpler and avoids heap fragmentation. - Quantize your models to INT8. INT8 quantization typically reduces model size by 4× and speeds up inference significantly compared to float32, with minimal accuracy loss.
-
Use
FRAMESIZE_QVGAor smaller for camera-based inference. Smaller input images reduce both pre-processing time and input tensor memory requirements. -
Run the CPU at maximum frequency. Enable the
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240option in yoursdkconfig(ESP-IDF) or setboard_build.f_cpu = 240000000Linplatformio.inito clock the dual-core Xtensa LX7 at 240 MHz.
