Skip to content

Commit 921d83f

Browse files
EdgeImpulse example
1 parent 559fd35 commit 921d83f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* This example shows how to use the Eloquent library
3+
* to perform inference using the EdgeImpulse generated library
4+
*/
5+
#include <replace_with_edge_impulse_inferencing.h>
6+
#include <eloquent.h>
7+
#include <eloquent/tinyml/edgeimpulse.h>
8+
9+
10+
Eloquent::TinyML::EdgeImpulse::Impulse impulse;
11+
12+
13+
void setup() {
14+
Serial.begin(115200);
15+
delay(3000);
16+
Serial.println("Starting EdgeImpulse inference");
17+
Serial.println("Paste your feature vector in the Serial Monitor and get the predicted value");
18+
Serial.print("(expecting ");
19+
Serial.print(EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE);
20+
Serial.println(" comma-separated features)");
21+
}
22+
23+
24+
void loop() {
25+
float features[EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE] = {0};
26+
27+
if (!Serial.available())
28+
return;
29+
30+
for (int i = 0; i < EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE; i++)
31+
features[i] = Serial.readStringUntil(',').toFloat();
32+
33+
Serial.print("Predicted class: ");
34+
Serial.println(impulse.predict(features));
35+
Serial.print("Predicted label: ");
36+
Serial.println(impulse.getLabel());
37+
38+
// debug class probabilities and timing
39+
impulse.printTo(Serial);
40+
}

0 commit comments

Comments
 (0)