-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathb03_makerML_layers.ino
575 lines (471 loc) · 29.2 KB
/
b03_makerML_layers.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
/*
* b01_makerML_hello_world.ino
* simplifying TensorflowLite Micro Machine Learning for all makers
*
*
*
* By Jeremy Ellis
* Twitter @rocksetta
* Website https://rocksetta.com
* created Aug 20th, 2020
* Github https://github.com/hpssjellis/my-examples-for-the-arduino-portentaH7/tree/master/m09-Tensoflow
*
*
* Hashtags
* #TensorflowLiteMicro
* #TensorflowLiteForArduino
* #TinyMY
* #MakerML
*/
// By putting this model.h file here we can load everything as one file into the arduino IDER.
// Once it is working it is best to seperate this as a model.h file into it's own tabThis allows only one file for Arduino IDE, but you should seperate the following
// #include "model.h" // uncomment when below has been put into it's own tab
/////////////////////////////////// cut and paste to model.h tab /////////////////////////////////////////////////////////////////
#pragma once
const unsigned char model_tflite[] = {
0x1c, 0x00, 0x00, 0x00, 0x54, 0x46, 0x4c, 0x33, 0x00, 0x00, 0x12, 0x00,
0x1c, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00,
0x00, 0x00, 0x18, 0x00, 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00,
0x1c, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0xf4, 0x02, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0xa8, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x94, 0x0b, 0x00, 0x00,
0x90, 0x0b, 0x00, 0x00, 0x1c, 0x09, 0x00, 0x00, 0x9c, 0x08, 0x00, 0x00,
0x20, 0x05, 0x00, 0x00, 0x34, 0x03, 0x00, 0x00, 0x7c, 0x0b, 0x00, 0x00,
0x78, 0x0b, 0x00, 0x00, 0x74, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00,
0x38, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x08, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
0x6d, 0x69, 0x6e, 0x5f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5f,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x42, 0xf7, 0xff, 0xff,
0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x31, 0x2e, 0x31, 0x34,
0x2e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0f, 0x00, 0x00, 0x00, 0x4d, 0x4c, 0x49, 0x52, 0x20, 0x43, 0x6f, 0x6e,
0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x2e, 0x00, 0x00, 0x00, 0x0e, 0x00,
0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
0x3c, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x88, 0x0a, 0x00, 0x00, 0x10, 0x0a, 0x00, 0x00,
0xf4, 0x07, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00, 0x18, 0x04, 0x00, 0x00,
0x1c, 0x02, 0x00, 0x00, 0x64, 0x01, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00,
0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0xb0, 0x01, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e,
0x00, 0x00, 0x00, 0x00, 0x0e, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x00, 0xf6, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0x01, 0x00, 0x00, 0x00, 0xe0, 0xf5, 0xff, 0xff, 0xde, 0xfe, 0xff, 0xff,
0x00, 0x00, 0x00, 0x08, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0xf8, 0xf5, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x74, 0xf6, 0xff, 0xff,
0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0x48, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31,
0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x44, 0x65, 0x6e, 0x73, 0x65,
0x32, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
0xe8, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00,
0x08, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x56, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x0e, 0x01, 0x00, 0x00, 0x00,
0x08, 0xf7, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
0x21, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x44,
0x65, 0x6e, 0x73, 0x65, 0x31, 0x2f, 0x53, 0x69, 0x67, 0x6d, 0x6f, 0x69,
0x64, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0x64, 0x00, 0x00, 0x00, 0x7c, 0xf9, 0xff, 0xff, 0x00, 0x00, 0x0e, 0x00,
0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x10, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x28, 0xf7, 0xff, 0xff,
0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00,
0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00,
0xbc, 0xf7, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
0x21, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 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x5d, 0x61, 0x98, 0x3e, 0xe8, 0xf0, 0xb5, 0x3e,
0x26, 0x36, 0x88, 0xbe, 0x45, 0x57, 0x51, 0xc0, 0x00, 0x8a, 0x84, 0x3e,
0x2d, 0xad, 0x3c, 0x3e, 0x23, 0xca, 0x0f, 0x3f, 0xfd, 0x0d, 0x16, 0x3f,
0xcc, 0xb9, 0xdc, 0x3d, 0xea, 0xbf, 0xc9, 0x3e, 0x9a, 0xb0, 0xac, 0x3e,
0x58, 0xc5, 0x09, 0xbe, 0x71, 0x72, 0xfa, 0x3e, 0xd3, 0x20, 0xb6, 0x3e,
0x79, 0x5c, 0xfd, 0xc0, 0x5c, 0x33, 0xfa, 0x3e, 0x41, 0x41, 0xfc, 0x3e,
0xc8, 0x28, 0xb5, 0x3e, 0x5c, 0x2b, 0x26, 0x3f, 0x77, 0x71, 0x8b, 0x3f,
0x22, 0xfa, 0xff, 0xff, 0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31,
0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x44, 0x65, 0x6e, 0x73, 0x65,
0x32, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00, 0x00, 0x00, 0x00,
0x9c, 0xf9, 0xff, 0xff, 0x12, 0xfc, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
0x20, 0x03, 0x00, 0x00, 0xc5, 0xf6, 0x77, 0xbe, 0x4c, 0x85, 0x35, 0xbf,
0x54, 0x11, 0x20, 0xbf, 0xb7, 0xf4, 0x8e, 0xbe, 0xd5, 0xc5, 0x5b, 0xbe,
0xed, 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 0x57, 0x47, 0x06, 0xbf, 0xef, 0xb8, 0x8b, 0xbe,
0xcc, 0x39, 0xb0, 0xc0, 0x65, 0xbf, 0xb0, 0xc0, 0x6e, 0x01, 0x81, 0xbe,
0x4b, 0xce, 0x31, 0xbf, 0x2e, 0x65, 0x2d, 0xbf, 0x7f, 0xca, 0x7a, 0xbe,
0x74, 0xe0, 0xbb, 0xbe, 0xcf, 0x0e, 0xe9, 0xbe, 0x70, 0xea, 0x67, 0xbd,
0x02, 0x33, 0x69, 0xbf, 0xcd, 0x80, 0xa8, 0xbf, 0x93, 0xa8, 0x1f, 0x3e,
0x9a, 0xfd, 0xff, 0xff, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x64, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31,
0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x44, 0x65, 0x6e, 0x73, 0x65,
0x31, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00, 0x00, 0x00, 0x00,
0x14, 0xfd, 0xff, 0xff, 0x8a, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x67, 0x34, 0x29, 0xc0, 0xf6, 0xfd, 0xff, 0xff,
0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x50, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x39, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x44,
0x65, 0x6e, 0x73, 0x65, 0x32, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64,
0x64, 0x2f, 0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62,
0x6c, 0x65, 0x4f, 0x70, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
0x65, 0x00, 0x00, 0x00, 0x04, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x89, 0xed, 0x16, 0xbf,
0xeb, 0x24, 0x1f, 0xbf, 0xda, 0x91, 0x38, 0xbf, 0xce, 0x43, 0x0d, 0xbf,
0xa3, 0x5a, 0x6c, 0xbf, 0x8a, 0x25, 0x32, 0xbf, 0x3b, 0xcc, 0x20, 0xbf,
0x91, 0x0a, 0x11, 0xbf, 0x3c, 0xcc, 0x21, 0xbf, 0x59, 0xc6, 0x33, 0xbf,
0xda, 0x40, 0x19, 0xbf, 0x05, 0xe8, 0x36, 0xbf, 0x11, 0xe2, 0x2a, 0xbf,
0x47, 0x4d, 0x2d, 0xbf, 0x3b, 0x36, 0x8a, 0x3f, 0x61, 0x32, 0x2e, 0xbf,
0x81, 0x04, 0x08, 0xbf, 0x46, 0xec, 0x1c, 0xbf, 0x23, 0x8e, 0x29, 0xbf,
0xd3, 0x7c, 0x5c, 0xbf, 0xb5, 0x1a, 0x06, 0xbf, 0x31, 0x22, 0x31, 0xbf,
0xb2, 0x4c, 0x0c, 0xbf, 0x98, 0xfc, 0x2e, 0xbf, 0x25, 0xbe, 0xff, 0xbe,
0x29, 0xa9, 0x0d, 0xbf, 0x3f, 0x07, 0x02, 0xbf, 0xb0, 0xb5, 0x38, 0xbf,
0x2f, 0xb3, 0x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fe, 0x0d, 0x17, 0xbf, 0x6e, 0x09, 0x0e, 0xbf,
0xb1, 0xdc, 0x2f, 0xbf, 0xed, 0xe8, 0x15, 0xbf, 0xe8, 0x8e, 0x2c, 0xbf,
0xea, 0xfe, 0x36, 0xbf, 0x0c, 0xb3, 0x29, 0xbf, 0x74, 0xd1, 0x1b, 0xbf,
0x9f, 0x46, 0x6b, 0xbf, 0x0c, 0x00, 0x0c, 0xc0, 0x09, 0x4d, 0x2d, 0xbf,
0xec, 0xd8, 0x3b, 0xbf, 0xa7, 0xfb, 0x1e, 0xbf, 0xc5, 0x0e, 0x1e, 0xbf,
0xfc, 0x54, 0x49, 0xbf, 0x42, 0xd0, 0x1d, 0xbf, 0xf4, 0xc9, 0x24, 0xbf,
0x40, 0x99, 0x3b, 0xbf, 0x44, 0x50, 0x1b, 0xbf, 0xb9, 0x46, 0x2f, 0xbf,
0x3b, 0x61, 0x00, 0x40, 0x32, 0x70, 0x17, 0xbf, 0x37, 0x0a, 0x1c, 0xbf,
0xe2, 0x10, 0x29, 0xbf, 0x10, 0x13, 0x21, 0xbf, 0xd6, 0x10, 0xe0, 0xbe,
0x00, 0x00, 0x0e, 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00,
0x0c, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00,
0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31,
0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x44, 0x65, 0x6e, 0x73, 0x65,
0x31, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x2f, 0x52, 0x65,
0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70,
0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x00, 0x00, 0x00,
0x9c, 0xff, 0xff, 0xff, 0x14, 0x00, 0x18, 0x00, 0x04, 0x00, 0x00, 0x00,
0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00,
0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x12, 0x00, 0x00, 0x00, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x44, 0x65,
0x6e, 0x73, 0x65, 0x31, 0x5f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00,
0xfc, 0xff, 0xff, 0xff, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00
};
unsigned int model_tflite_len = 3048;
//////////////////////////////////// end cut and paste to model.h tab ///////////////////////////////////////////////////////////////
#include "Arduino.h"
//#include <TensorFlowLite.h>
#include <RocksettaTensorFlowLite.h>
/*================= Start Advanced Area ===============================*/
#include "tensorflow/lite/micro/all_ops_resolver.h"
//#include "tensorflow/lite/micro/kernels/micro_ops.h"
//#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
#include "tensorflow/lite/micro/micro_error_reporter.h" // may have issues on M4 core
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/version.h"
#include "tensorflow/lite/c/common.h"
//#include "tensorflow/lite/c/c_api.h" // has interesting funcitons, not in main library
// Start Debug.cc information ----------------------------------------------------------
#if defined (CORE_CM7) || defined (CORE_CM4) || defined (TEENSYDUINO) || defined (ARDUINO_NANO33BLE) || defined (YOUR_BOARD1) // CORE_CM7 is for the PortentaH7 outer core
// do abosolutely nothing the default works
// Note: NANO_33_BLE deprecated as MBED of 1.30, new name: ARDUINO_NANO33BLE
// Note: CORE_CM4 MBED of 1.30, moved above
#elif defined (NANO_33_BLE) || defined (YOUR_BOARD2) // CORE_CM4 is for the PortentaH7 inner core
#define DEBUG_SERIAL_OBJECT (Serial)
extern "C" void DebugLog(const char* s) {
static bool is_initialized = false;
if (!is_initialized) {
DEBUG_SERIAL_OBJECT.begin(9600);
is_initialized = true;
}
DEBUG_SERIAL_OBJECT.print(s);
}
#elif defined (__SAM3X8E__) || defined (YOUR_BOARD3) // Arduino UNO style boards
#define DEBUG_SERIAL_OBJECT (SerialUSB)
extern "C" void DebugLog(const char* s) {
static bool is_initialized = false;
if (!is_initialized) {
DEBUG_SERIAL_OBJECT.begin(9600);
is_initialized = true;
}
DEBUG_SERIAL_OBJECT.print(s);
}
#elif defined (SEEED_XIAO_M0) || defined (YOUR_BOARD4) // The new $5 USD Seeeduino XIAO board
#define CFG_TUSB_DEBUG
#else
// don't do any debugging until you figure out your board
extern "C" void DebugLog(const char* s) {
// Do not log debug info
}
#endif
/*
* nano_33_iot.build.board=SAMD_NANO_33_IOT // have not got it working yet
*
*/
// End Debug.cc information ----------------------------------------------------------
namespace { // Start namespace----------------------------------------------------------
// define needed variables
tflite::ErrorReporter* error_reporter = nullptr;
const tflite::Model* model = nullptr;
tflite::MicroInterpreter* interpreter = nullptr;
TfLiteTensor* input = nullptr;
TfLiteTensor* output = nullptr;
// Create an area of memory to use for input, output, and intermediate arrays.
constexpr int kTensorArenaSize = 2 * 1024; // I like 20 * 1024;
uint8_t tensor_arena[kTensorArenaSize];
} // END namespace----------------------------------------------------------
/*================= End Advanced Area ===============================*/
/*================= Start Smart Area ================================*/
void modelSetup(const unsigned char theModel[]){
// NOLINTNEXTLINE(runtime-global-variables)
static tflite::MicroErrorReporter micro_error_reporter;
error_reporter = µ_error_reporter;
// Map the model into a usable data structure. This doesn't involve any
// copying or parsing, it's a very lightweight operation.
model = tflite::GetModel(theModel); // name from the tflite converter model.h file
if (model->version() != TFLITE_SCHEMA_VERSION) {
TF_LITE_REPORT_ERROR(error_reporter,
"Model provided is schema version %d not equal "
"to supported version %d.",
model->version(), TFLITE_SCHEMA_VERSION);
return;
}
// This pulls in all the operation implementations we need.
// NOLINTNEXTLINE(runtime-global-variables)
static tflite::AllOpsResolver resolver;
/* // replace the above line if you know each operation to save space
static tflite::MicroMutableOpResolver<5> micro_op_resolver; // NOLINT
micro_op_resolver.AddBuiltin(tflite::BuiltinOperator_DEPTHWISE_CONV_2D,tflite::ops::micro::Register_DEPTHWISE_CONV_2D() );
micro_op_resolver.AddBuiltin(tflite::BuiltinOperator_MAX_POOL_2D,tflite::ops::micro::Register_MAX_POOL_2D() );
micro_op_resolver.AddBuiltin(tflite::BuiltinOperator_CONV_2D,tflite::ops::micro::Register_CONV_2D() );
micro_op_resolver.AddBuiltin(tflite::BuiltinOperator_FULLY_CONNECTED,tflite::ops::micro::Register_FULLY_CONNECTED() );
micro_op_resolver.AddBuiltin(tflite::BuiltinOperator_SOFTMAX,tflite::ops::micro::Register_SOFTMAX() );
*
*/
// Build an interpreter to run the model with.
static tflite::MicroInterpreter static_interpreter(model, resolver, tensor_arena, kTensorArenaSize, error_reporter);
interpreter = &static_interpreter;
// Allocate memory from the tensor_arena for the model's tensors.
TfLiteStatus allocate_status = interpreter->AllocateTensors();
if (allocate_status != kTfLiteOk) {
TF_LITE_REPORT_ERROR(error_reporter, "AllocateTensors() failed");
return;
}
// Obtain pointers to the model's input and output tensors.
input = interpreter->input(0);
output = interpreter->output(0);
}
float modelPredict(int32 myInput[]){ // like tensorflowJS const myPredictArray = await model.predict(xTrainingData).data()
// may have to change the types
// input->data.f[0] = myInput; // may have to edit this
input->data.f[0] = myInput[0];
input->data.f[1] = myInput[1];
// Run inference, and report any error
TfLiteStatus invoke_status = interpreter->Invoke();
// if (invoke_status != kTfLiteOk) {
// Serial.print("Error with input: " + String(myInput));
// }
return output->data.f[0]; // may have to edit this
}
/*================= End Smart Area ======================================*/
/*================= Start Maker Area ======================================*/
#define NUMBER_OF_INPUTS 2
#define NUMBER_OF_OUTPUTS 1
int myLed = LED_BUILTIN; // or 7 or 5 or LEDB etc
// helper function to convert tensor type integer to a string
String myTypeIntToString(int myType){
String myTensorType = "Not Set";
if (myType == 0){myTensorType = "kTfLiteNoType"; }
if (myType == 1){myTensorType = "kTfLiteFloat32"; }
if (myType == 2){myTensorType = "kTfLiteInt32"; }
if (myType == 3){myTensorType = "kTfLiteUInt8"; }
if (myType == 4){myTensorType = "kTfLiteInt64"; }
if (myType == 5){myTensorType = "kTfLiteString"; }
if (myType == 6){myTensorType = "kTfLiteBool"; }
if (myType == 7){myTensorType = "kTfLiteInt16"; }
if (myType == 8){myTensorType = "kTfLiteComplex64"; }
if (myType == 9){myTensorType = "kTfLiteInt8"; }
if (myType == 10){myTensorType = "kTfLiteFloat16"; }
if (myType == 11){myTensorType = "kTfLiteFloat64"; }
if (myType == 12){myTensorType = "kTfLiteComplex128"; }
return myTensorType;
}
void setup() {
randomSeed(analogRead(A0));
Serial.begin(9600);
pinMode(myLed, OUTPUT);
modelSetup(model_tflite);
}
void loop() {
Serial.println(" constexpr int kTensorArenaSize: " + String(kTensorArenaSize) );
Serial.println(" interpreter->arena_used_bytes(): " + String(interpreter->arena_used_bytes()) );
Serial.println(" interpreter.inputs_size(): " + String(interpreter->inputs_size()) );
Serial.println(" interpreter.outputs_size(): " + String(interpreter->outputs_size()) );
Serial.println(" interpreter.tensors_size(): " + String(interpreter->tensors_size()) );
Serial.println();
Serial.println(" input->type: " + String(input->type) + " = " + myTypeIntToString(input->type));
Serial.println(" input->dims->size: " + String(input->dims->size) );
int mySize = input->dims->size;
for (int i = 0; i < mySize; i++) {
int myIn = input->dims->data[i];
Serial.println( " input->dims->data[" + String(i) + "]: " + String(myIn) );
}
Serial.println( );
Serial.println("-----------------------------------------------------------" );
int myTotalBytes = 0;
for (size_t tensor_index = 0; tensor_index < interpreter->tensors_size(); tensor_index++) {
TfLiteTensor* tensor = interpreter->tensor(static_cast<int>(tensor_index));
Serial.print("Layer index: " + String(tensor_index) );
Serial.print(", Type: " + String(tensor->type)+ ": "+ myTypeIntToString(tensor->type) );
Serial.print(", # Nodes: " + String(tensor->dims->size) );
Serial.println(", Size in Bytes: " + String(tensor->bytes) );
myTotalBytes += tensor->bytes;
Serial.print("-----tensor->dims->data[k]" );
for (int k = 0; k < tensor->dims->size; k++) {
Serial.print(", data[" + String(k) + "]:" + String(tensor->dims->data[k]));
}
Serial.println( );
Serial.println( );
}
Serial.println("-----------------------------------------------------------" );
Serial.println(" output->type: " + String(output->type) + " = " + myTypeIntToString(output->type));
Serial.println(" output->dims->size: " + String(output->dims->size) );
int mySize2 = output->dims->size;
for (int i = 0; i < mySize2; i++) {
int myOut = output->dims->data[i];
Serial.println( " output->dims->data[" + String(i) + "]: " + String(myOut) );
}
Serial.println(" Total Added Bytes: " + String(myTotalBytes) );
Serial.println("-----------------------------------------------------------" );
Serial.println("-----------------------------------------------------------" );
Serial.println();
delay(3000);
}