eloquentarduino / EloquentTensorFlowCortexM

Run TensorFlow on ARM Cortex-M chips without pain
2 stars 1 forks source link

Issue in the code of EloquentTensorFlowCortexM #1

Open Abdullah-Shahid01 opened 4 months ago

Abdullah-Shahid01 commented 4 months ago

Hi, I am trying to use the EloquentTensorFlowCortexM library to deploy a neural network model on the Sony Spresense, however, I am encountering an error which will not allow me to proceed. I have attached screenshots of the error message and my code here.

CODE:

include

include "irisModel.h"

define NUM_OPS 3

define ARENA_SIZE 2000

using Eloquent::CortexM::TensorFlow;

TensorFlow<NUM_OPS, ARENA_SIZE> tf;

void setup() { Serial.begin(115200); delay(2000);

Serial.println("TENSORFLOW IRIS");

tf.setNumInputs(4); tf.setNumOutputs(3);

tf.resolver.AddFullyConnected(); tf.resolver.AddSoftmax();

while (!tf.begin(irisModel).isOk()){ Serial.println(tf.exception.toString()); }

}

void loop() { if (!tf.predict(x0).isOk()) { Serial.println(tf.exception.toString()); return; }

Serial.print("expcted class 0, predicted class ");
Serial.println(tf.result());

// classify sample from class 1
if (!tf.predict(x1).isOk()) {
    Serial.println(tf.exception.toString());
    return;
}

Serial.print("expcted class 1, predicted class ");
Serial.println(tf.result());

// classify sample from class 2
if (!tf.predict(x2).isOk()) {
    Serial.println(tf.exception.toString());
    return;
}

Serial.print("expcted class 2, predicted class ");
Serial.println(tf.result());

// how long does it take to run a single prediction?
//Serial.print("It takes ");
//Serial.print(tf.benchmark.microseconds());
//Serial.println("us for a single prediction");

delay(1000);

}

ERROR:

/Users/abdullah/Documents/Arduino/libraries/EloquentTensorFlowCortexM/src/tensorflow/lite/micro/system_setup.cpp:68:39: error: expected template-name before '<' token 68 | class _RingBuffer : public RingBufferN<kSerialMaxInputLength + 1> { | ^ /Users/abdullah/Documents/Arduino/libraries/EloquentTensorFlowCortexM/src/tensorflow/lite/micro/system_setup.cpp:68:39: error: expected '{' before '<' token /Users/abdullah/Documents/Arduino/libraries/EloquentTensorFlowCortexM/src/tensorflow/lite/micro/system_setup.cpp:68:39: error: expected unqualified-id before '<' token /Users/abdullah/Documents/Arduino/libraries/EloquentTensorFlowCortexM/src/tensorflow/lite/micro/system_setup.cpp:73:20: error: aggregate 'test_over_serial::_RingBuffer test_over_serial::_ring_buffer' has incomplete type and cannot be defined 73 | static _RingBuffer _ring_buffer; | ^~~~

exit status 1

Compilation error: exit status 1

eloquentarduino commented 4 months ago

The recommended way to run TensorFlow models is detailed at https://eloquentarduino.com/posts/tensorflow-lite-tinyml-esp32. The post is focused on ESP32, but you can swap the TF runtime by chainging

#include <tflm_esp32.h>

with

#include <tflm_cortexm.h>

Let me know how it goes, since Cortex-M support is not 100% reliable.