Because of the memory capacity, i can only put the input data 500row.
But my tflite model(ver1_1.h) input shape is (4500,12), so i have to make the data repeat infinitly.
This is my code. Please somebody help me...
#include <TensorFlowLite.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 <tensorflow/lite/version.h>
#include "ver1_1.h"
tflite::MicroErrorReporter tflErrorReporter;
tflite::AllOpsResolver tflOpsResolver;
const tflite::Model* tflModel = nullptr;
tflite::MicroInterpreter* tflInterpreter = nullptr;
TfLiteTensor* tflInputTensor = nullptr;
TfLiteTensor* tflOutputTensor = nullptr;
const uint32_t tensorArenaSize = 60 * 1024;
uint8_t tensorArena[tensorArenaSize];
tflite::MicroErrorReporter micro_error_reporter;
tflite::AllOpsResolver resolver;
const int inputSize = 4500 * 12 * sizeof(float);
const int outputSize = sizeof(float);
int led = LED_BUILTIN;
float data[500][12] = { { ... }, { ... }, ... , { ... } };
void setup() {
Serial.begin(9600);
digitalWrite(led, HIGH);
tflInterpreter = new tflite::MicroInterpreter(tflModel, resolver, tensorArena, tensorArenaSize, µ_error_reporter);
tflInterpreter->AllocateTensors();
float* inputData = tflInterpreter->input(0)->data.f;
float* outputData = tflInterpreter->output(0)->data.f;
for (int i=0; i<4500; i++) {
for (int j=0; j<12; j++) {
*inputData++ = data[i][j];
}
}
tflInterpreter->Invoke();
Serial.println(*outputData);
pinMode(led, OUTPUT);
if (*outputData>=0.5) {
digitalWrite(led, HIGH);
} else {
for (int fadeValue=0; fadeValue<=255; fadeValue+=5) {
analogWrite(led, fadeValue);
}
}
};
void loop() {
}