Today, from our geek lair comes a new update, utilizing the exported pre-trained machine learning models from Google’s latest Teachable Machine. It demonstrates the possibility of running image classification off a live camera feed on a resource constraint device that is available at an abundance — an Android communication device.


Things required to reproduce the example/demo:
- Any PC connected to the internet with the capability of saving files.
- A working Webcam hooked up to your PC.
- A relatively decent Android device that could access Google’s PlayStore.
- An OTG cable.
- A compatible USB device, e.g. Arduino Uno.
- Some distinct items use for image training.
Android Apps that are needed on your phone ( 2 & 3 are optional, but will make your life so much easier):
- TomatoCube USB TF Classifier – https://play.google.com/store/apps/details?id=com.tomatocube.usb.classification (Leave us a message so that we can send you a free promo code in play store!)
- Files by Google – https://play.google.com/store/apps/details?id=com.google.android.apps.nbu.files
- Google Drive – https://play.google.com/store/apps/details?id=com.google.android.apps.docs
There are two distinct steps required in running this demo/example.
Step 1: Generating a pre-trained machine learning models via Google’s Teachable Machine Website. (https://teachablemachine.withgoogle.com/train)
-
- Using a few different objects, create different classifications inputs.
- Train & test your model until a satisfactory result is achieved.
- Export your model targeting for a Tensorflow lite, floating-point model.
- Extract & place your files into your Google-Drive. “model_unquant.tflite” & “labels.txt”
- You may refer to our youtube video for live demo: https://youtu.be/CM5sdqEtmv8
Step 2: Running the Android App taking the exported model from Google’s Teachable Machine Website as it’s input. The inference results will be displayed in realtime on the screen. Any compatible USB device attached to the Android device will get the inference results as well.
On your Android device, download the “model_unquant.tflite” & “labels.txt” files from your Google drive & leave them in your download folder.
You may refer to our youtube video for live demo: https://youtu.be/rJJg7ds2d0M
-
- (Optional) You can verify that the files are correctly downloaded using the “Files” app.
- Connect your Arduino board to your Android device using an OTG cable and a micro USB cable.
- Launch “TomatoCube USB TF Classifier” app, making sure that the correct inferred results are shown on screen.
- Pull up the Bottom drawer & hit the “Connect USB” on-screen button.
- Using the following communication parameters, the Arduino board will get the inferred result via the Serial Interface.
-
-
- Baud rate: 115200bps
- Data Bits: 8 data bits
- Stop Bits: 1 stop bit
- Parity: No parity
-
-
We have also included two different Arduino Sketches for your convenience; you may refer to the images for hardware hookup:
- For an Arduino board with an attached SSD1306 OLED screen connected over the i2C communication line. – http://tomatocube.com/file_dir/misc_files/TF_ML/SerialOledPrint.ino
- For an Arduino Board with a Servo Motor Attached. – http://tomatocube.com/file_dir/misc_files/TF_ML/SerialServoCtrl.ino
Arduino Library:
- AsyncDelay – https://github.com/stevemarple/AsyncDelay
- Adafruit_GFX – https://github.com/adafruit/Adafruit-GFX-Library
- Adafruit_SSD1306 – https://github.com/adafruit/Adafruit_SSD1306

