| sd_generate | R Documentation |
Automatically selects the best generation strategy based on output resolution
and available VRAM (set via vram_gb in sd_ctx). For
txt2img, routes between direct generation, tiled sampling (MultiDiffusion),
or highres fix. For img2img (when init_image is provided), routes
between direct and tiled img2img.
sd_generate(
ctx,
prompt,
negative_prompt = "",
width = 512L,
height = 512L,
init_image = NULL,
strength = 0.75,
sample_method = SAMPLE_METHOD$EULER,
sample_steps = 20L,
cfg_scale = 7,
seed = 42L,
batch_count = 1L,
scheduler = SCHEDULER$DISCRETE,
clip_skip = -1L,
eta = 0,
hr_strength = 0.4,
vae_mode = "auto",
vae_tile_size = 64L,
vae_tile_overlap = 0.25,
cache_mode = c("off", "easy", "ucache"),
cache_config = NULL
)
ctx |
SD context created by |
prompt |
Text prompt describing desired image |
negative_prompt |
Negative prompt (default "") |
width |
Image width in pixels (default 512) |
height |
Image height in pixels (default 512) |
init_image |
Optional init image for img2img. If provided, runs img2img
instead of txt2img. Requires |
strength |
Denoising strength for img2img (default 0.75). Ignored for txt2img. |
sample_method |
Sampling method (see |
sample_steps |
Number of sampling steps (default 20) |
cfg_scale |
Classifier-free guidance scale (default 7.0) |
seed |
Random seed (-1 for random) |
batch_count |
Number of images to generate (default 1) |
scheduler |
Scheduler type (see |
clip_skip |
Number of CLIP layers to skip (-1 = auto) |
eta |
Eta parameter for DDIM-like samplers |
hr_strength |
Denoising strength for highres fix refinement pass (default 0.4). Only used when auto-routing selects highres fix. |
vae_mode |
VAE processing mode: |
vae_tile_size |
Tile size for VAE tiling (default 64) |
vae_tile_overlap |
Overlap for VAE tiling (default 0.25) |
cache_mode |
Step caching mode: |
cache_config |
Optional fine-tuned cache config from
|
When vram_gb is not set on the context, defaults to direct generation
(equivalent to calling sd_txt2img or sd_img2img
directly).
List of SD images (or single image for highres fix path).
## Not run:
# Simple — auto-routes based on detected VRAM
ctx <- sd_ctx("model.safetensors", model_type = "sd1",
vae_decode_only = FALSE)
imgs <- sd_generate(ctx, "a cat", width = 2048, height = 2048)
# Manual override — force 4 GB VRAM limit
ctx4 <- sd_ctx("model.safetensors", model_type = "sd1",
vram_gb = 4, vae_decode_only = FALSE)
imgs <- sd_generate(ctx4, "a cat", width = 2048, height = 2048)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.