image_scores_dir: Calculate image scores for all images in a directory (fast...

View source: R/image_scores.R

image_scores_dirR Documentation

Calculate image scores for all images in a directory (fast batch)

Description

This function scans a directory for image files and computes scores for each image using a Hugging Face CLIP model. It loads the model once and reuses text embeddings for speed, returning one row per image with the filename as image_id and probability columns for each class.

Usage

image_scores_dir(
  dir,
  classes,
  face_selection = "largest",
  pattern = "\\.(jpg|jpeg|png|bmp)$",
  recursive = FALSE,
  model = "oai-base",
  local_model_path = NULL,
  face_detector = c("yunet", "haar")
)

Arguments

dir

Path to a directory containing images.

classes

Character vector of labels/classes (length >= 2).

face_selection

Face selection strategy: "largest", "left", "right", or "none" (one row per image), "all" (one row per face, with faces of the same person sharing a person_id; see detect_faces), or a data frame from detect_faces (its faces in these images).

pattern

Optional regex to filter images (default supports common formats).

recursive

Whether to search subdirectories (default FALSE).

model

CLIP model alias or HuggingFace model id (see image_scores()).

local_model_path

Optional local path to a pre-downloaded model.

face_detector

"yunet" (default) or "haar"; see image_scores.

Value

A data.frame with columns: image_id and one column per class. With "all" or a data frame of faces, one row per face, with the columns of face_scores after image_id.


transforEmotion documentation built on Oct. 26, 2026, 5:07 p.m.