-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Hi,
I'm using the auto_delin function with the dlib70 model.
I wrote this wrapper function:
get_individually_aligned_faces <- function(x)
{
stimuli <- read_stim(path = x$path, pattern = c("-A\\.","-HC\\.","-HO\\.","-N\\.","-S\\.")) # filter out "NM" (neutral with covid mask) images, by providing specific patterns
face_model <- auto_delin(stimuli, "dlib70", replace = F) # get faces dlib70 model
dtmp <- draw_tem(face_model) |> plot() # draw face template from model
patch_fill <- patch(face_model, width = 1, height = 10) # get the background color of the face image, to be used when adjusting the face location
horized <- face_model |> horiz_eyes(fill = patch_fill) # align by eyes
horized_plot <- horized |> plot()
aligned <- face_model |> horiz_eyes(fill = patch_fill) |> align(procrustes = TRUE, fill = patch_fill) # align using procrustes (average location of all images)
aligned_plot <- aligned |> plot()
stim_list <- list(fm = face_model,tmp = dtmp,hrz = horized,hrzplot = horized_plot,alg = aligned,algplot = aligned_plot) # save everything
}And I'm calling it for different subsets of images using purrr::map (actually, within each subset, I have 4 or 5 images for each face identify that are saved in the same directory and are called from the same path on each run of my function).
For some reason, the auto_delin function runs fine for some subsets of images, but not for others. I'm getting the following error, suggesting there's a problem with creating a matrix for some of the images (in this case, image F-061):
Error in mutate():
! Problem while computing params = purrr::map(.x = data, .f = ~get_individually_aligned_faces(.x)).
ℹ The error occurred in group 10: image_id = "F-061".
Caused by error in purrr::map():
ℹ In index: 1.
Caused by error in matrix():
! length of 'dimnames' [2] not equal to array extent
Backtrace:
- ... %>% unnest_wider(params)
- purrr::map(.x = data, .f = ~get_individually_aligned_faces(.x))
- purrr:::map_("list", .x, .f, ..., .progress = .progress)
- .f(.x[[i]], ...)
- global get_individually_aligned_faces(.x)
- webmorphR.dlib::auto_delin(stimuli, "dlib70", replace = F)
- webmorphR.dlib::dlib_auto_delin(stimuli, model, replace, model_path)
- base::matrix(...)
All images come from the same database (the subsetting is just for easier debugging) and are of the same file type (JPG). Within each subset, there are the same number of files (either 4 or 5) per face identity.
Any suggestions?
Thanks.