Articles in this Series

Preparatory Steps

Basic Classification (1/4) - Classifying Clothing on the Mac Mini M1 (this article)

Basic Classification (2/4) - Tensorflow Lite Model Conversion

Basic Classification (3/4) - Machine Learning on TI's EdgeAI Cloud

Interlude: TensorFlow Models on the Edge

Basic Classification (4/4) - EdgeAI Cloud - Jacinto ML Hardware Acceleration

Classification on the AI Edge 

(5) SK-TDA4VM:Remote Login, Jupyter Notebook and Tensorflow.js

(6) SK-TDA4VM Starter Kit: Fashion Classification DNN

(7) - Category List

 

Introduction

This is the first article, as part of a series of four, developed to better understand  TI’s recommended workflow for running machine learning inferencing algorithms on the SK-TDA4VM starter kit. The motivation for running this series has been discussed in the previous blog post SK-TDA4VM - On the Artificial Intelligence Edge. In this article I’ll be running the Tensorflow Fashion MNIST beginners tutorial on the Mac Mini M1, although any personal computer will do.

The first step in running the Fashion MNIST classification on the Mac M1 is to install Tensorflow and the Tensorflow metal plugin. The plugin accelerates inferencing, by using the M1’s neural engine, which performs ML inferencing  up to x15 faster on the GPU, compared to the 8-core CPU.

There are many Mac M1 tutorials online that describe how to install Tensorflow and Jupiter labs in a python virtual environment. The more up to date installation methods take advantage of the Tensorflow delegate architecture, which leverages  the M1’s GPU. Due to the continued evolution of Miniforge and Tensorflow on the Mac M1 I will only list the installation steps I followed here, a more up to date method should be found by Googling.

These are the steps I followed to enable machine learning on the  Apple Silicon Mac M1, natively.  The installation supports TensorFlow 2.6 GPU acceleration (tensorflow-metal PluggableDevice):

  1. Install Miniforge for OSX, using the arm 64 (Apple Silicon) architecture - miniforge3-MacOSX-arm64
  2. Create and activate a python (3.9.5) virtual environment.
  3. Install Tensorflow dependencies
  4. Install Tensorflow-macos
  5. Install Tensorflow-metal
  6. Install needed packages
    1. libjpeg
    2. Matplotlib
    3. jupyterlab

That’s it, at this point I was good to go . Although to actually get Tensorflow to run successfully I needed to upgrade MacOS to Monterey 12.0. Also, I installed the GNU Octave notebook extension for some upcoming DSP projects. 

 

The Fashion-MNIST dataset

Fashion-MNIST is a dataset of Zelando’s article images consisting of a training set of 60,000 examples and a test set of 10,000 examples. Each example is a 28x28 grayscale image, associated with a label from 10 classes. We intend Fashion-MNIST to serve as a direct drop-in replacement for the original MNIST dataset for benchmarking machine learning algorithms. It shares the same image size and structure of training and testing splits. - Reference: Fashion-NIST (https://github.com/zalandoresearch/fashion-mnist)

 

Jupiter Notebook Fashion-MNIST Classification 

Conclusion

In this article I have trained and used the Fashion-MNIST dataset to infer items of clothing on the Mac Mini M1, using the M1's GPU (Can we use the neural compute engine?). Hence, the first stage of running machine learning inferencing models on the  SK-TDA4VM starter kit has been completed. However, it should be noted that this first stage could have been implemented on any PC. The next stage requires converting the model created in this stage into a TensorFlow Lite model, which will be the topic of discussion in the next article in this series. 

Copyright © 2021 ReconTech. All Rights Reserved.
Joomla! is Free Software released under the GNU General Public License.