Skip to content

charlie2951/mL_Rpi_ZeroW

Repository files navigation

Machine Learning on Raspberry Pi Zero/Zero-W

This repo provides a comprehensive guide and required tool to do machine learning task on Pi-Zero/Zero-W.

An older version of Keras is used. Currently tensorflow adapted Keras as front-end API. Keras always needs a backend tensor based package for running ML algorithms. Earlier Version V1.0.0 of Keras supports theano as backend but latest version uses Tensorflow. Officially tensorflow is not supported on Pi-Zero armV6 architecture. However, you can run inference using pre-trained TFLITE model. Here theano as tensor provider which works as a backend support for Keras.

  1. Installing Theano using pip package manager
pip3 install Theano==1.0.5
  1. Then clone this repo and move to the parent directory and install required dependencies for Keras
pip install requirements.txt
  1. Build Keras from source

    Move to keras-1.0 directory and run the following

sudo python setup.py install

The setup.py script will build and install Keras. During build process you may encounter error regarding scipy and pyml but they will not hamper the operation of Keras.

  1. To verify the installation, open a python terminal by typing python and then in Python console, import keras
import keras
keras.__version__

image


Now move to the parent git directory and run the test script called test_keras.py. This file contain one fully connected neural network (Dense layers). It will take approx 106sec to train the network and predict.

Note: Model training on Pi-Zero is challenging due to lower compuattional resources such as RAM size, speed etc. However, if you want to explore for fun then just go through it.
It is always advisable that train the model in PC/in google Colab-> convert it to Tensor flow LITE format (.tflite) and then run classification on Pi-Zero using TFLITE runtime.

Disclaimer: Source code of Keras-1.0 taken from Keras-1 repo

Tensorflow Lite Runtime for Running model trained on Tensorflow (tested on Pi-Zero only)

Navigate to the tflite_micro_rpi0 sub-directory for detailed instruction and installation

Machine Learning using Scikit-learn library on Pi-Zero


Install scikit-learn using pip
pip install scikit-learn==0.22

Releases

No releases published

Packages

No packages published

Languages