Donald J. Norris
Machine Learning with the Raspberry Pi
Experiments with Data and Computer Vision
Donald J. Norris
Barrington, NH, USA
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/978-1-4842-5173-7 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-5173-7 e-ISBN 978-1-4842-5174-4
https://doi.org/10.1007/978-1-4842-5174-4
Donald J. Norris 2020
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Table of Contents
About the Author and About the Technical Reviewer
About the Author
Donald J. Norris
is an avid electronics hobbyist and maker. He is also an electronics engineer with an advanced degree in Production Management. Don is retired from civilian government service with the US Navy, where he specialized in acoustics and digital signal processing. He also has more than a dozen years experience as a professional software developer using C, C#, C++, Python, and Java, and 5 years experience as a certified IT security consultant.
About the Technical Reviewer
Ahmed Fawzy Gad
is a machine learning engineer who holds B.Sc. and M.Sc. in Information Technology. Ahmed is a teaching assistant and a researcher who is interested in machine/deep learning, computer vision, and Python. He is a machine learning technical reviewer and consultant helping others do their projects. Ahmed contributes written tutorials and articles to a number of blogs including Paperspace , Real Python , KDnuggets , Heartbeat , and Towards Data Science .
Ahmed has authored three books titled TensorFlow: A Guide to Build Artificial Neural Networks Using Python(Lambert 2017) , Practical Computer Vision Applications Using Deep Learning with CNNs(Apress, 2018) , and Building Android Apps in Python Using Kivy with Android Studio(Apress, 2019) .
He welcomes you to connect with him through LinkedIn ( linkedin.com/in/AhmedFGad ), Facebook ( fb.com/AhmedFGadd ), and e-mail ( ahmed.f.gad@gmail.com ).
Donald J. Norris 2020
D. J. Norris Machine Learning with the Raspberry Pi https://doi.org/10.1007/978-1-4842-5174-4_1
1. Introduction to machine learning (ML) with the Raspberry Pi (RasPi)
This chapter will provide you with introductions to both RasPi and ML. The RasPi discussion will be first, which will help you understand the hardware platform that will be used to run all the books demonstrations. An introductory ML discussion follows, which will provide you with a framework to comprehend what ML is all about and why it is such an exciting and rapidly evolving field of study.
RasPi introduction
You will need to use a RasPi in order to run this books demonstrations. In the next few sections, I will show you how to set up and configure a RasPi 3 Model B or B+ as a workstation that will run the scripts and programs required for the various ML demonstrations. Figure shows a RasPi 3 Model B+ , which is used in this book.
Figure 1-1
Raspberry Pi 3 Model B+
There are a few differences between the RasPi 3 Model B and B+. They are basically the same except that the B+ has a slightly faster processor clock speed increase and has some improvements in the wireless functions as compared to the B model. Neither of these improvements will have a significant impact on running this books projects if you use a B instead of a B+ model.
I will not discuss what constitutes a RasPi single-board computer because that is already adequately covered by many available books and blogs. As mentioned earlier, I used a RasPi 3 Model B+ in a workstation configuration. This setup is where a RasPi is connected with a USB keyboard, USB mouse, and HDMI monitor. In my setup, the RasPi is powered by a 2.2A, 5V supply with a micro USB connector.
The RasPi does not use a mechanical disk drive for implementing a file system which includes an operating system (OS). All recent RasPi versions rely on using a pluggable micro SD card to serve as the secondary storage. While it is possible to connect a traditional disk drive to a RasPi, it will only serve as an auxiliary storage device and not as the primary storage for the OS or as the bootable partition. I will next show you how to download and install an OS on a micro SD card in order to enable the RasPi to serve as a functional ML microcontroller.
Undoubtedly the simplest way to get up and running is to purchase a preprogrammed micro SD card. Such cards are ready to go and only need to be configured to match your particular workstation configuration, including your WiFi network. The WiFi configuration process will be discussed in a later section, but first I would like to discuss how to create your own micro SD card if you so desire.
The micro SD card software to be loaded is known as a Raspbian Image and is available without charge from many online web sites, with my recommended site being the Raspberry Pi Foundation site at raspberrypi.org . The latest OS Image is always available from the Downloads section of the web site. There are two types of the OS Image that you can download. The first type is named NOOBS, which is an abbreviation for New Out of the Box Software. There are two versions of NOOBS available. One version is named NOOBS, and the other version is named NOOBS Lite. Both versions are identified as v3.0.0 as of the time of this writing. NOOBS has an easy operating system installer which contains the Raspbian OS as well as another popular OS named LibreELEC . Additionally, the NOOBS version provides a selection of alternative operating systems which are subsequently downloaded from the Internet and installed. NOOBS Lite contains the same operating system installer without Raspbian pre-loaded and no LibreELEC option. However, this version provides the same operating system selection menu allowing Raspbian and other OS Images to be downloaded and installed.