Making TinyML truly client-side. Giving Makers full control of the process, user friendly, private and protected
Version 0.56.3-215 Note: Web Bluetooth (BLE) connection works on Chrome, Edge, Android, and potentially other browsers with BLE support. Requires HTTPS.
This website makes machine learning models from Web Bluetooth 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.
BLE Device Connection & Communication
Ready.
Data Collection & Preprocessing
Label:
CSV FileName:
Data Visualization & Classification
...
Machine Learning Model Training
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:
...
...
Try the following steps:
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:
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.
This 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.
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.
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.
...
Upload from a raw CSV file or an Arduino style microcontroller using Web Bluetooth (Android Pixel phones also work) or your cell phone motion sensor.
Keep the raw sensor data then Machine Learning train a tensorflowJS model for export or for live classification all on this single
vanilla Javascript webpage!
Show:
Hide: Load .csv files:
Following is the list of actual labels used in the same order as uploaded (comma-separated)
Note: expecting files to be named: "name-lable.csv" or "name-lable (1).csv" etc.
CSV Lables (careful):
Senses Labels (In the order collected):
Enter Labels (comma seperated):
...
Arduino/ESP32 BLE Sketch
The following sketch should be uploaded to your Arduino or ESP32 board. Make sure to delete any conflicting `ArduinoBLE` library if you are using ESP32 with `BLEDevice.h`.
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.
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"
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.
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.
**HTTPS Required for Web BLE:** Web Bluetooth, like Web Serial, only works on secure contexts (HTTPS). If testing locally, you will need to serve your page over HTTPS.
**BLE UUIDs:** The provided Arduino sketch and JavaScript use specific Service and Characteristic UUIDs (`19b10000-e8f2-537e-4f6c-d104768a1214`). Ensure your BLE device firmware uses these exact UUIDs for communication to work.