TinyMLjs

This is a short version of myProof of Concept to train microcontroller sensors on the web instead of in the cloud or using complex installed software. On a cell phone you can train using the accelerometers. On your desktop computer train mouse movement
For Microcontrollers

Making TinyML truly client-side. Giving Makers full control of the process, user friendly, private and protected

Version 0.56.3-215 Note: WebSerial microcontroller connection works on Chrome or Edge for Mac, Android (Pixel Phones early verson) or Windows, only works on Edge for Linux
This website makes machine learning models from WebSerial connected micro-controller sensors using TensorflowJS. That model can be saved and converted to a tFlite model, then to a C-header model.h file using Tensorflow command line or Python converters. I simplify the conversion using a Gitpod. Finally the model.h file is combined with C/C++ code using an Arduino IDE ready library called RocksettaTinyML and compiled to the device for testing.

Presently, for complex vision or sound data it is easier to use EdgeImpulse.com as it will achieve the needed model compression that we have not yet achieved.





For microcontrollers


Label:
CSV FileName:


...
Machine Learning models often need very specific data.
Count CSV: Count Senses: Count Total:
Number of Samples/count: Number of Senses/sample:



Enter number of epochs: , Learning rate:
...

...


For Microcontrollers
    Try the following steps:
  1. Convert the exported model to Arduino ready c-header model.h file as well as a model.tflite file using one of the following methods:
  2. 1:tensorflowjs-to-arduino-for-tinymljs Best to install the modules needed to client-side do the conversions yourself. This github shows what you need to do. The installation might be different on your computer. I always find this hard to do at school.
    2: iPython Notebook TFJS to TFliteThis web based Google Colab iPython notebook (Needs a google login) loads the necessary code then you click on an upload button to load your tensorflowjs exported "model.json" and "model.weights.bin" files and it zips and downloads the tflite and c-header files.
    3:Use a Gitpod: https://github.com/hpssjellis/Gitpod-auto-tensorflowJS-to-arduino or direct load the gitpod: Gitpod Here A Gitpod browser docker like program that auto loads the necessaray python files and then runs a bash program to do the command line conversions. All code is easy to view, if you have a github account it loads fast.


  3. Use https://netron.app/ Use the online netron.app to check and visualize your downloaded model.tflite
  4. Once you have made a model.h file then install this Arduino Library RocksettaTinyML based on EloquentArduino to load the code onto your Arduino IDE.
  5. ...


Senses Labels (In the order collected):

For Microcontrollers

Aruino NiclaVision webSerial code that can be adapted for other microcontrollers

The "fancy" Arduino sketch for the Nano33BleSense is on the github here https://github.com/hpssjellis/tinyMLjs/blob/main/public/acceleration/a00-accell-nano33-fancy.txt


Use at your own risk!
By Jeremy Ellis @rocksetta
Github at https://github.com/hpssjellis/tinyMLjs/tree/main
Demo's Index at https://hpssjellis.github.io/tinyMLjs/public/index.html
This page should be at https://hpssjellis.github.io/tinyMLjs/public/acceleration/a00-best-acceleration.html

    A couple of gotchas (as of Jun 22, 2023):

  1. File names have to be in the format "name-lable.csv" or "name-lable (1).csv" or "name-lable (2).csv" etc. Unfortunately Android and iPhone don't auto make the numbering for you.
  2. Android and Apple device have an opposite orientation, so I have made negative all the android motion data so when your phone is on a table z = -9.8 m/s^2 etc. When looking veritacally at your phone y = -9.8 m/s^2. The auto detect of this only works if an Android phone is in mobile format not "desktop site"
  3. Real data has lots of rough data, machine learning models do not like missing data. If your results show "NaN" either your training data or classification data has errors. Note: If the loss is not changing your trained data probably has errors. The "clean,trim,fill" buttons might help.
  4. Presently a CSV label upload bug happens sometimes. Easy to fix by entering the correct labels in the correct order. I will try to fix the issue when I figure out what is causing it.