| sd_ctx | R Documentation |
Loads a model and creates a context for image generation.
sd_ctx(
model_path = NULL,
vae_path = NULL,
taesd_path = NULL,
clip_l_path = NULL,
clip_g_path = NULL,
t5xxl_path = NULL,
diffusion_model_path = NULL,
control_net_path = NULL,
n_threads = 0L,
wtype = SD_TYPE$COUNT,
vae_decode_only = TRUE,
free_params_immediately = FALSE,
keep_clip_on_cpu = FALSE,
keep_vae_on_cpu = FALSE,
diffusion_flash_attn = TRUE,
rng_type = RNG_TYPE$CUDA,
prediction = NULL,
lora_apply_mode = LORA_APPLY_MODE$AUTO,
flow_shift = 0,
model_type = "sd1",
vram_gb = NULL,
device_layout = "mono",
diffusion_gpu = -1L,
clip_gpu = -1L,
vae_gpu = -1L,
verbose = FALSE
)
model_path |
Path to the model file (safetensors, gguf, or checkpoint) |
vae_path |
Optional path to a separate VAE model |
taesd_path |
Optional path to TAESD model for preview |
clip_l_path |
Optional path to CLIP-L model |
clip_g_path |
Optional path to CLIP-G model |
t5xxl_path |
Optional path to T5-XXL model |
diffusion_model_path |
Optional path to separate diffusion model |
control_net_path |
Optional path to ControlNet model |
n_threads |
Number of CPU threads (0 = auto-detect) |
wtype |
Weight type for quantization (see |
vae_decode_only |
If TRUE, only load VAE decoder (saves memory) |
free_params_immediately |
Free model params after first computation. If TRUE, the context can only be used for a single generation — subsequent calls will crash. Set to TRUE only when you need to save memory and will not reuse the context. Default is FALSE. |
keep_clip_on_cpu |
Keep CLIP model on CPU even when using GPU |
keep_vae_on_cpu |
Keep VAE on CPU even when using GPU |
diffusion_flash_attn |
Enable flash attention for diffusion model (default TRUE). Set to FALSE if you experience issues with specific GPU drivers or backends. |
rng_type |
RNG type (see |
prediction |
Prediction type override (see |
lora_apply_mode |
LoRA application mode (see |
flow_shift |
Flow shift value for Flux models |
model_type |
Model architecture hint: |
vram_gb |
Override available VRAM in GB. When set, disables auto-detection
and uses this value for strategy routing. Default |
device_layout |
GPU layout preset for multi-GPU systems. One of:
Ignored when |
diffusion_gpu |
Vulkan GPU device index for the diffusion model.
Default |
clip_gpu |
Vulkan GPU device index for CLIP/T5 text encoders.
Default |
vae_gpu |
Vulkan GPU device index for VAE encoder/decoder.
Default |
verbose |
If |
An external pointer to the SD context (class "sd_ctx") with
attributes model_type, vae_decode_only, vram_gb,
vram_total_gb, and vram_device.
## Not run:
ctx <- sd_ctx("model.safetensors")
imgs <- sd_txt2img(ctx, "a cat sitting on a chair")
sd_save_image(imgs[[1]], "cat.png")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.