Unable to compile examples on adafruit circuitplayground bluefruit due to missing files in Adafruit_Tensorflow_Lite library

  • I am unable to compile the examples , hello_world_arcada and micro_speech_arcada , on the adafruit website found here on my Circuit playground bluefruit microcontroller.

  • I installed the Adafruit_Tensorflow_Lite library in my arduino ide as mentioned in the site however it turns out that when compiling the examples they have numerous missing files. So i downloaded this tensorflow git hub repo and then transfered the missing files into the Adafruit_Tensorflow_Lite library.

  • I am now facing this error for the missing files : am_bsp.h,am_mcu_apollo.h, am_util.h , i cannot locate these files on the repo or on google.

Can anyone let me know where i can find these files or a way to compile the code ?

  • The error is shown in the pic below of the missing file am_bsp.h when using Arduino IDE to compile:

  • My code is shown below:
#include <TensorFlowLite.h>
#include "Adafruit_TFLite.h"
#include "Adafruit_Arcada.h"

#include "output_handler.h"
#include "sine_model_data.h"

// Create an area of memory to use for input, output, and intermediate arrays.
// Finding the minimum value for your model may require some trial and error.
const int kTensorAreaSize  (2 * 1024);

// This constant represents the range of x values our model was trained on,
// which is from 0 to (2 * Pi). We approximate Pi to avoid requiring additional
// libraries.
const float kXrange = 2.f * 3.14159265359f;

// Will need tuning for your chipset
const int kInferencesPerCycle = 200;
int inference_count = 0;

Adafruit_Arcada arcada;
Adafruit_TFLite ada_tflite(kTensorAreaSize);

// The name of this function is important for Arduino compatibility.
void setup() {
  Serial.begin(115200);
  //while (!Serial) yield();

  arcada.arcadaBegin();
  // If we are using TinyUSB we will have the filesystem show up!
  arcada.filesysBeginMSD();
  arcada.filesysListFiles();
  // Set the display to be on!
  arcada.displayBegin();
  arcada.setBacklight(255);
  arcada.display->fillScreen(ARCADA_BLUE);
  
  if (! ada_tflite.begin()) {
    arcada.haltBox("Failed to initialize TFLite");
    while (1) yield();
  }
  if (arcada.exists("model.tflite")) {
    arcada.infoBox("Loading model.tflite from disk!");
    if (! ada_tflite.loadModel(arcada.open("model.tflite"))) {
      arcada.haltBox("Failed to load model file");
    }
  } else if (! ada_tflite.loadModel(g_sine_model_data)) {
    arcada.haltBox("Failed to load default model");
  }
  Serial.println("\nOK");

  // Keep track of how many inferences we have performed.
  inference_count = 0;
}

// The name of this function is important for Arduino compatibility.
void loop() {
  // Calculate an x value to feed into the model. We compare the current
  // inference_count to the number of inferences per cycle to determine
  // our position within the range of possible x values the model was
  // trained on, and use this to calculate a value.
  float position = static_cast<float>(inference_count) /
                   static_cast<float>(kInferencesPerCycle);
  float x_val = position * kXrange;

  // Place our calculated x value in the model's input tensor
  ada_tflite.input->data.f[0] = x_val;

  // Run inference, and report any error
  TfLiteStatus invoke_status = ada_tflite.interpreter->Invoke();
  if (invoke_status != kTfLiteOk) {
    ada_tflite.error_reporter->Report("Invoke failed on x_val: %f\n",
                           static_cast<double>(x_val));
    return;
  }

  // Read the predicted y value from the model's output tensor
  float y_val = ada_tflite.output->data.f[0];

  // Output the results. A custom HandleOutput function can be implemented
  // for each supported hardware target.
  HandleOutput(ada_tflite.error_reporter, x_val, y_val);

  // Increment the inference_counter, and reset it if we have reached
  // the total number per cycle
  inference_count += 1;
  if (inference_count >= kInferencesPerCycle) inference_count = 0;
}

What is arduino board you selected in IDE?

Adafruit Circuit Playground Bluefruit

My look into using Tensorflow lite is that it was written for the ESP32 and the BLE32. I've not seen mention of the Tensorflow lite library being compatible with the nRF52840. Perhaps asking Adafruit, Issues · adafruit/Adafruit_TFLite · GitHub, they might answer?

The 2nd thing that the adafruity tensor flow lite library loads is #include <TensorFlowLite.h>.

I found that the RPi and the Beaglebone Black are a lot better at using ML algorithms like TensorFlow Lite.

There are using a demo of the 2 examples i mentioned in the question right here in the link

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