Building an Image Classifier Running on Raspberry Pi
The tutorial starts by building the Physical network connecting Raspberry Pi to the PC via a router. After preparing their IPv4 addresses, SSH session is created for remotely accessing of the Raspberry Pi. After uploading the classification project using FTP, clients can access it using web browsers for classifying images.
This tutorial discusses using Raspberry Pi for receiving HTTP requests for classifying images and responding with the classification label. The tutorial starts by building the Physical network connecting Raspberry Pi to the PC via a router. After preparing their IPv4 addresses, SSH session is created for remotely accessing of the Raspberry Pi. After uploading the classification project using FTP, clients can access it using web browsers for classifying images.
Raspberry Pi is a single-board computer designed for being cheap enough so that it is affordable for students in the developing countries. Raspberry Pi supports coding with Python and this is why the term “PI” is available. Raspberry Pi 3 model B is the latest available version. It has a quad-core 1.2 GHz CPU, 1 GB RAM, Wi-Fi, Bluetooth, one HDMI port, 4 USB ports, Ethernet port, camera, and more.
Raspberry Pi comes without an operating system (OS) installed. The OS can be shipped on an SD card which inserted into the SD card slot of the board. The OS can be downloaded using NOOBS (New Out Of the Box Software) (https://www.raspberrypi.org/downloads/noobs) which is an OS manager to easily download and install OSs to Raspberry Pi. The official Raspberry Pi OS is called Raspbian which is a version of Linux designed specifically to Raspberry Pi. It comes with NOOBS. NOOBS also supports a list of OSs to choose from.
After installing the OS in the SD card, next is to run and access it. One way of accessing the Raspberry Pi is by connecting it using the Ethernet interface. Such connection can be direct by connecting it to the Ethernet interface of the PC. Some PCs just have wireless interfaces and not supports Ethernet at all. Others may have problems installing the drivers. For such reason, we can avoid connecting Raspberry Pi to the Ethernet interface of the PC and connect it to one of the Ethernet interfaces in a router. The PC can be connected to such router using Wi-Fi.
Assume that the local area network (LAN) in which the Raspberry Pi and the PC exist uses internet protocol version 4 (IPv4) addresses ranging from 192.168.1.1 to 192.168.1.254. That is the network address is 192.168.1.0 and the subnet mask is 255.255.255.0. Using the dynamic host configuration protocol (DHCP), IPv4 addresses are assigned dynamically to both the PC and the Raspberry Pi. We can easily know the IP address of the PC using ipconfig command in Windows (ifconfig in Linux). According to the following figure, the default gateway is set to 192.168.1.1 and the IPv4 address of the PC is 192.168.1.18.
In order to know the IPv4 address assigned to the Raspberry Pi Ethernet interface, a program called “Advanced IP Scanner” will be used. It can be downloaded from this page https://www.advanced-ip-scanner.com. This program receives a range of IPv4 addresses and searches for the active ones. For each IPv4 address in the range, the program returns its status, hostname, manufacturer, and media access control (MAC) address. Usually, either the hostname or the Manufacturer name of the Raspberry Pi will contain the word "raspberry". This helps us to determine which IP belongs to the Raspberry Pi. The following figure shows the IPv4 addresses assigned to the gateway interface of the router, PC, and Raspberry Pi Ethernet interface which is signed 192.168.1.19.
As a summary, the following figure shows the 3 devices (Raspberry Pi, router, and PC) in addition to the assigned IPv4 addresses. One Ethernet interface in the router is connected to the Ethernet interface of the Raspberry Pi using a straightforward cable. The router is connected to the PC wirelessly.
After establishing the physical connections, we need to access the Raspberry Pi from the PC. Secure shell (SSH) is a good option. The SSH session can be created using different software programs such as XMing, Putty, and MobaXterm. MobaXterm is an easy-to-use one which is available at this link https://mobaxterm.mobatek.net/download-home-edition.html. The following figure shows the main window of MobaXterm.
IMPORTANT: Before establishing the SSH session, an empty file named “ssh” without extension must be added to the root of the SD card. This is required in order to allow establishing SSH sessions with Raspberry Pi. This is done by inserting the SD card into the PC and adding such file. After inserting the SD card into the Raspberry Pi, we can start creating the SSH session.
The “Session” icon at the top-left of the icon bar is used for establishing sessions such as SSH, Telnet, and others. After clicking on it, the window will be displayed as given in the next figure.
After clicking the left-most SSH icon, MobaXterm asks for either the remote hostname or the IPv4 address of the Raspberry Pi in order to access the remote device. We can use the IPv4 address of the Ethernet interface of the Raspberry Pi which is 192.168.1.19 as given in the following figure.