CHAPTER 11Machine Learning with Images

So far in this book the training and classification of information has been based around either datasets of numbers or, as in Chapter 10, text.

In this chapter, we'll take a brief look at image processing and classification, starting with using a basic neural network and then extending that knowledge to use convolutional neural networks for image classification.

Over the last few years there have been huge leaps forward in image processing with machine learning. The addition of graphic processing units (GPUs) will speed up the training of models. To get an idea of how good things have gotten, take a look at the website This Person Does Not Exist (https://thispersondoesnotexist.com). Using the StyleGAN model developed by Nvidia, each of the images is generated and is not a real person, but they look alarmingly realistic!

What Is an Image?

In its basic form, a computer-based image is a grid of numbers. Each “square” is called a pixel. Figure 11.1 is an example of an 8 pixel by 8–pixel image.

Not overly artistic I agree, but it's a starting point. Let's assume this is an image of two colors: black and white. When there is a pixel colored black, then it's given the value of one, and all the others are zero. From a numeric point of view, our image looks like Figure 11.2.

What we have is a 1 bitmap image representation. Each bit represents the color, black or white.

Figure 11.1: An 8 x 8–pixel image

Figure 11.2: Numeric image of an ...

Get Machine Learning, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.