Help with P5.js and arduino using serial.js

Hello!

So I have been trying to reverse engineer this great example from the google team about interfacing TensorFlow models created in “teachable machine”, then using a p5.js sketch and the WebUSB library to send serial data to an Arduino to interface hardware. The example is called “Tiny Sorter”.

https://experiments.withgoogle.com/tiny-sorter/view

The Arduino sketch makes sense to me, it’s simply taking in serial data that it’s getting from the p5.js sketch, but I can’t figure out anything about how the p5.js sketch is:

  1. using the TensorFlow model
  2. making it’s decision based on the TensorFlow model and sending the data out via webUSB.

Do any of you awesome programming ninja’s have any suggestions as to what portion is taking in the TensorFlow model data, and what portion is determining what data is being sent out via serial using webUSB? I’ve been programming arduino for years, but I’m really new to p5.js. This kind of collaboration between platforms seems awesome!

The tutorial posts this as the p5 sketch,
https://editor.p5js.org/gbose/sketches/2BN5HQYNK