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
)

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

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.

Value

A data.frame with columns: image_id and one column per class.


transforEmotion documentation built on Jan. 8, 2026, 5:06 p.m.