Help with Running SenseCraft AI Person Detection Model on Xiao Seeed Studio ESP32S3 Sense

Hi everyone,

I’m working on a project using the Xiao Seeed Studio ESP32S3 Sense module and I’m trying to run a person detection model shared by SenseCraft AI. Despite following the setup instructions and examples provided, I am encountering issues with running the model due to memory constraints.

Here are the specifics of my setup:

  • Module: Xiao Seeed Studio ESP32S3 Sense
  • Model: Person detection model from SenseCraft AI
  • Environment: Arduino IDE
  • Issue: I’m unable to fit the TensorFlow Lite model into the DRAM of the ESP32S3 module. The model is approximately 1.9 MB, and the module has 8 MB of PSRAM which I’m trying to utilize.

Here is a snippet of my code where I allocate memory for the tensor arena using ps_malloc to use PSRAM:

#include "esp_camera.h"
#include "FS.h"
#include "SD.h"
#include "SPI.h"
#include <TensorFlowLite_ESP32.h>
#include <tensorflow/lite/micro/all_ops_resolver.h>
#include <tensorflow/lite/micro/micro_error_reporter.h>
#include <tensorflow/lite/micro/micro_interpreter.h>
#include <tensorflow/lite/schema/schema_generated.h>
#include "model.h"

namespace {
  constexpr int kTensorArenaSize = 2000000; // 2MB
  static uint8_t* tensor_arena = nullptr; 
}

void setup() {
  Serial.begin(115200);
  tensor_arena = (uint8_t*)ps_malloc(kTensorArenaSize);
  if (tensor_arena == nullptr) {
    Serial.println("Failed to allocate tensor arena from PSRAM");
    return;
  }

  // Model setup and inference code
}

void loop() {
  // Inference handling code
}

Despite this, I still face issues with DRAM overflow during compilation, and the inference process does not execute as expected.

Has anyone here worked with TensorFlow Lite on the ESP32S3 module, particularly with large models? Any advice on optimizing memory usage or debugging tips would be greatly appreciated. Also, if you have specific recommendations for handling large TensorFlow Lite models on constrained devices like ESP32S3, please share.

Thank you in advance for your help!

Good Luck,… we cant even get tech support on a XIAO… maybe try joining the Seeed discord server for this one! I will put a link to this post over there and see if anyone bites!.. Good and Timly Question!

1 Like

You can go to this website 【SenseCraft AI upload the model to XIAO ESP32S3 Sense. It works for me and here is my experience~

  1. download this model, only this one suitable to XIAO ESP32S3 Sense

2.upload this model to its official website and burn it to XIAO

1 Like

Hi there,
I may be being Captain obvious, But is the PSram enabled in the IDE menu?
How about a screen shot of what options are set?
HTH
GL :slight_smile: PJ :v:

yes, the PSRAM enable option was active

Hi there,
Nice so looks like it is. I would look to the partition scheme next. Is that the largest. available for apps, I thought I read 4MB is available. maybe that would help the upload.
GL :slight_smile: PJ
:v:

Looking back also the BSP may have an issue with the SD lib you use if it’s the latest BSP 3.0x?
roll back to 2.0.17 see what that does.?

1 Like