Download TorchScript model files for Stable Diffusion
Description
Downloads the required model files (e.g., UNet, decoder, text encoder)
for a given Stable Diffusion model using hfhub::hub_download().
Usage
download_model(model_name = "sd21",
devices = list(unet = "cpu", decoder = "cpu", text_encoder = "cpu"),
unet_dtype_str = NULL, overwrite = FALSE, show_progress = TRUE,
download_models = FALSE)
Arguments
model_name: Name of the model (e.g., “sd21” for stable-diffusion-2-1)devices: Either a single device string or a named list with elements ‘unet’, ‘decoder’, ’text_encoder’; optionally ’encoder’unet_dtype_str: Optional: “float16” or “float32” (only applies if unet uses CUDA)overwrite: If TRUE, force re-download of model filesshow_progress: Show download progress messagesdownload_models: If TRUE, download the model files from HuggingFace
Details
Files are cached by hfhub (typically ~/.cache/huggingface/hub/).
Legacy files in the old R_user_dir() location are also recognized.
Value
A named list of full file paths, keyed by component name.
Examples
paths <- download_model("sd21")