How it works...

In step 1, we loaded a sample image and resized its height and width to height_resized and width_resized, respectively. In step 2, we localized a face in the image by using the image_detect_faces() function from the image.libfacedetection library. It returns the left x,y coordinates of the detected face and its width and height. Then, in step 3, we drew a bounding box around the face. The rect() function draws a rectangle onto an image using pixel coordinates. In the previous three steps, we implemented face localization in an image. In step 4, we utilized this face localization technique to prepare a dataset that we will use to train our face recognizer/classifier model.

In step 5, we built a generator with data augmentation. ...

Get Deep Learning with R Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.