setup_modules: Setup Required Python Modules

View source: R/setup_modules.R

setup_modulesR Documentation

Setup Required Python Modules

Description

Builds the Python environment for transforEmotion ahead of first use and downloads the default models, so the first analysis call does not wait on either. Calling it is optional: every function sets up what it needs on first use.

Usage

setup_modules(
  extras = character(),
  download_models = TRUE,
  models = character()
)

Arguments

extras

Character vector of optional feature sets to install together with the core packages:

"rag"

LlamaIndex packages used by rag()

"youtube"

pytubefix, used by video_scores() for YouTube URLs

"audio"

av (PyAV, with FFmpeg), used by speech_scores() to read audio

"findingemo"

findingemo-light, used by the FindingEmo dataset functions

"gpu"

bitsandbytes, used for 4-bit quantization of EVA-CLIP-8B

download_models

Logical. Download the default text, image and sentence-similarity models into the Hugging Face cache (about 1 GB), the face recognition model detect_faces uses (10 MB), and, when extras includes "rag", the default embedding model and TinyLLAMA used by rag() (about 2.3 GB), and, when extras includes "audio", the LAION CLAP model used by speech_scores (about 800 MB). Default TRUE. Skipped when HF_HUB_OFFLINE is set.

models

Character vector of additional Hugging Face model IDs to download, such as "facebook/bart-large-mnli". Use it to prepare models for offline use (see setup_cache).

Details

Python requirements are declared with py_require. reticulate resolves them with uv into a cached environment, so after the first run later sessions start in under a second. No conda installation or manual uv installation is needed; reticulate downloads uv when it is not on the PATH.

PyTorch is installed as a CPU-only build unless an NVIDIA GPU is detected. Set TE_FORCE_CPU=1 to always use the CPU build, or TRANSFOREMOTION_USE_GPU=1 to always use the CUDA build. The choice is made when the package is loaded, so set either variable in .Renviron or before library(transforEmotion), in a new R session.

Value

Invisibly returns NULL.

Author(s)

Alexander P. Christensen <alexpaulchristensen@gmail.com>

Examples

## Not run: 
# Core packages and default models
setup_modules()

# Also install the packages rag() needs
setup_modules(extras = "rag")

# Prepare an additional model for offline use
setup_modules(models = "facebook/bart-large-mnli")

## End(Not run)


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