TensorFlowLite_ESP32 version.h

I am using TensorFlowLite_ESP32 library and i am following intructions on the link of the authors. it says that i must include these:

#include "tensorflow/lite/micro/micro_mutable_op_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"

But version.h is nowhere to be found. The problem results like this:

C:\University\Do an co dien tu\testcode\testcode11\testcode11.ino:8:10: fatal error: tensorflow/lite/version.h: No such file or directory
    8 | #include "tensorflow/lite/version.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: tensorflow/lite/version.h: No such file or directory

Can someone help me on this? Here's my full code

#include <Arduino.h>
#include <TensorFlowLite_ESP32.h>
#include "pid_ann_model.h"
#include "tensorflow/lite/micro/all_ops_resolver.h"
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/version.h"
#include "PID_v1.h"

#define MOTOR_PIN 5 

const int tensor_arena_size = 2 * 1024;
uint8_t tensor_arena[tensor_arena_size];

double Setpoint, Input, Output;
double Kp, Ki, Kd;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);

// TensorFlow Lite
tflite::MicroErrorReporter micro_error_reporter;
tflite::AllOpsResolver resolver; 
const tflite::Model* model;
tflite::MicroInterpreter* interpreter;
TfLiteTensor* input_tensor;
TfLiteTensor* output_tensor;

void setup() {
  Serial.begin(115200);
  pinMode(MOTOR_PIN, OUTPUT);

  model = tflite::GetModel(pid_ann_model);
  if (model->version() != TFLITE_SCHEMA_VERSION) {
    Serial.println("Phiên bản model không khớp!");
    return;
  }

  static tflite::MicroInterpreter static_interpreter(model, resolver, tensor_arena, tensor_arena_size, &micro_error_reporter);
  interpreter = &static_interpreter;

  if (interpreter->AllocateTensors() != kTfLiteOk) {
    Serial.println("Lỗi cấp phát bộ nhớ!");
    return;
  }

  input_tensor = interpreter->input(0);
  output_tensor = interpreter->output(0);

  Setpoint = 50.0;
  myPID.SetMode(AUTOMATIC);

  Serial.println("TensorFlowLite_ESP32 đã khởi động thành công!");
}

void loop() {
  Input = analogRead(A0) * (100.0 / 1023.0);
    
  double error = Setpoint - Input;
  static double last_error = 0;
  double integral = error * 0.1;
  double derivative = (error - last_error) / 0.1;
  last_error = error;

  input_tensor->data.f[0] = error;
  input_tensor->data.f[1] = integral;
  input_tensor->data.f[2] = derivative;

  if (interpreter->Invoke() != kTfLiteOk) {
    Serial.println("Lỗi khi chạy mô hình!");
    return;
  }

  Kp = output_tensor->data.f[0];
  Ki = output_tensor->data.f[1];
  Kd = output_tensor->data.f[2];

  myPID.SetTunings(Kp, Ki, Kd);

  myPID.Compute();

  analogWrite(MOTOR_PIN, Output);

  Serial.print("Kp: "); 
  Serial.print(Kp);
  Serial.print(" Ki: "); 
  Serial.print(Ki);
  Serial.print(" Kd: ");
  Serial.print(Kd);
  Serial.print(" Output: "); 
  Serial.println(Output);

  delay(100);
}

Hi @anhkhoi041.

Please provide a the link to those instructions in a reply here on the forum topic. That might provide the forum helpers with some valuable context that will allow us to more effectively assist you.

Here's the link I'm following. Hope this help

Get started with microcontrollers | Google AI Edge | Google AI for Developers

Those instructions are for using the "LiteRT for Microcontrollers" C++ library, not for the "TensorFlowLite_ESP32" Arduino library. Although the two codebases are related, they are not the same. So the "LiteRT for Microcontrollers" C++ library documentation won't necessarily be perfectly applicable to the "TensorFlowLite_ESP32" Arduino library

You should use the examples provided by the "TensorFlowLite_ESP32" library developer as a reference to learn how to use that library. You will find them listed under the File > Examples > TensorFlowLite_ESP32 menu in Arduino IDE.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.