Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
agrimagsrl committed Jan 29, 2020
1 parent b4aa86c commit 708186e
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# EloquentTinyML

This Arduino library is here to simplify the deployment of Tensorflow Lite
for Microcontrollers models to Arduino boards using the Arduino IDE.

Including all the required files for you, the library exposes an eloquent
interface to load a model and run inferences.

## Install

Clone this repo in you Arduino libraries folder.

```bash
git clone https://github.com/eloquentarduino/EloquentTinyML.git
```


## Use

```cpp
#include <EloquentTinyML.h>
#include "sine_model.h"

#define NUMBER_OF_INPUTS 1
#define NUMBER_OF_OUTPUTS 1
#define TENSOR_ARENA_SIZE 2*1024

Eloquent::TinyML::TinyML<
NUMBER_OF_INPUTS,
NUMBER_OF_OUTPUTS,
TENSOR_ARENA_SIZE> ml(sine_model_quantized_tflite);


void setup() {
Serial.begin(115200);
}

void loop() {
float x = 3.14 * random(100) / 100;
float y = sin(x);
float input[1] = { x };
float predicted = ml.predict(input);

Serial.print("sin(");
Serial.print(x);
Serial.print(") = ");
Serial.print(y);
Serial.print("\t predicted: ");
Serial.println(predicted);
delay(1000);
}
```
21 changes: 17 additions & 4 deletions examples/SineExample/SineExample.ino
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
#include <EloquentTinyML.h>
#include "sine_model.h"

#define NUMBER_OF_INPUTS 1
#define NUMBER_OF_OUTPUTS 1
#define TENSOR_ARENA_SIZE 2*1024

Eloquent::TinyML::TinyML<1, 1, 2048> ml(sine_model_quantized_tflite);
Eloquent::TinyML::TinyML<
NUMBER_OF_INPUTS,
NUMBER_OF_OUTPUTS,
TENSOR_ARENA_SIZE> ml(sine_model_quantized_tflite);


void setup() {
Serial.begin(115200);
}

void loop() {
float input[1] = {random(10) > 5 ? 3.14/2 : 0};
float output = ml.predict(input);
float x = 3.14 * random(100) / 100;
float y = sin(x);
float input[1] = { x };
float predicted = ml.predict(input);

Serial.println(output);
Serial.print("sin(");
Serial.print(x);
Serial.print(") = ");
Serial.print(y);
Serial.print("\t predicted: ");
Serial.println(predicted);
delay(1000);
}

0 comments on commit 708186e

Please sign in to comment.