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 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.