Clean images

We will also read the same 25 images without the black line and save them in trainy, as shown in the following code:

# Read image files without black linesetwd("~/Desktop/people")temp = list.files(pattern="*.jpg")mypic <- list()for (i in 1:length(temp)) {mypic[[i]] <- readImage(temp[i])}for (i in 1:length(temp)) {mypic[[i]] <- resize(mypic[[i]], 128, 128)}for (i in 1:length(temp)) {dim(mypic[[i]]) <- c(128, 128,3)}trainy <- combine(mypic)trainy <- aperm(trainy, c(4,1,2,3))par(mfrow = c(4,4), mar = rep(0, 4))for (i in 1:16) plot(as.raster(trainy[i,,,]))par(mfrow = c(1,1))

Here, after resizing and changing dimensions, we are combining the images, just like we did previously. We also need to make some adjustments to the dimensions ...

Get Advanced Deep Learning with R 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.