Giter Club home page Giter Club logo

adafruit_tflite's Introduction

Adafruit TensorFlow Lite Library Build Status

This is the Adafruit TensorFlow Lite Helper Library

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Limor Fried for Adafruit Industries.
Apache2 license to match TensorFlow, check license.txt for more information All text above must be included in any redistribution

To install, use the Arduino Library Manager and search for "Adafruit Tensorflow Lite" and install the library.

adafruit_tflite's People

Contributors

evaherrada avatar hpssjellis avatar ladyada avatar siddacious avatar tyeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_tflite's Issues

Pybadge error compiling example sketch micro_speech_arcarda

System information
Windows 10 laptop

TensorFlow installed from (source or binary): Both Arduino_TensorflowLite 2.1.0-ALPHA and Adafruit Tensorflow Lite 1.2.1 fronm the Arduino IDE libraries
Tensorflow version (commit SHA if source): dont know
Target platform (e.g. Arm Mbed OS, Arduino Nano 33 etc.): Pybadge M4 with external microphone
Describe the problem
got the following compile error:
Arduino: 1.8.13 (Windows 10), Board: "Adafruit pyBadge M4 Express (SAMD51), Enabled, 180 MHz (overclock), Fastest (-Ofast), 50 MHz (standard), TinyUSB, Off"
Multiple libraries were found for "Adafruit_ZeroDMA.h"
Used: C:\Users\Joanna\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.2\libraries\Adafruit_ZeroDMA
In file included from C:\Users\Joanna\Documents\Arduino\libraries\Adafruit_TensorFlow_Lite\examples\micro_speech_arcada\micro_speech_arcada.ino:22:
Not used: C:\Users\Joanna\Documents\Arduino\libraries\Adafruit_Zero_DMA_Library
audio_provider.h:19:10: fatal error: tensorflow/lite/c/c_api_internal.h: No such file or directory
19 | #include "tensorflow/lite/c/c_api_internal.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
tensorflow/lite/c/c_api_internal.h: No such file or directory

Please provide the exact steps when you ran into the problem
Setup new Arduino IDE
Added Adafruit https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
to boards manager url in preferences
Added Adafruit SAMD Boards 1.6.2
Added all Adafruit arcada libraries 2.5.0
Loaded Examples > Adafruit Tensorflow Lite > micro_speech_arcarda.

Got the attached error

Unable to compile tensorflow lite 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 shown below , on the adafruit website found here on my Circuit playground bluefruit microcontroller:

a2

  • I installed the Adafruit_Tensorflow_Lite library as mentioned in the site however it turns out that examples cannot compile because they have numerous missing files. So i downloaded this TensorFlow git hub repo and then transferred 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 repoor on google.[Note: i have found the am_bsp.h file in this repo but it still doesn't compile :

a1

  • Can anyone assist me in locating where i can find these files or a way to compile the example hello_world_arcada and micro_speech_arcada code mentioned in the adafruit website ?

  • 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;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.