sd_txt2img_highres: High-resolution image generation via patch-based pipeline

View source: R/pipeline.R

sd_txt2img_highresR Documentation

High-resolution image generation via patch-based pipeline

Description

Generates a large image by independently rendering overlapping patches at the model's native resolution, then stitching them with linear blending. An optional img2img harmonization pass can smooth seams further.

Usage

sd_txt2img_highres(
  ctx,
  prompt,
  negative_prompt = "",
  width = 2048L,
  height = 2048L,
  tile_size = NULL,
  overlap = 0.125,
  img2img_strength = NULL,
  sample_method = SAMPLE_METHOD$EULER,
  sample_steps = 20L,
  cfg_scale = 7,
  seed = 42L,
  scheduler = SCHEDULER$DISCRETE,
  clip_skip = -1L,
  eta = 0,
  vae_mode = "auto",
  vae_auto_threshold = 1048576L,
  vae_tile_size = 64L,
  vae_tile_overlap = 0.25
)

Arguments

ctx

SD context created by sd_ctx

prompt

Text prompt

negative_prompt

Negative prompt (default "")

width

Target image width in pixels

height

Target image height in pixels

tile_size

Patch size in pixels. NULL = auto-detect from model_type attribute on ctx (512 for SD1/SD2, 1024 for SDXL/Flux/SD3). Must be divisible by 8.

overlap

Overlap between patches as fraction of tile_size, 0.0-0.5 (default 0.125).

img2img_strength

If not NULL, run a final img2img pass over the stitched image at this denoising strength (e.g. 0.3) to harmonize seams. Requires vae_decode_only = FALSE in the context. Default NULL (disabled).

sample_method

Sampling method (see SAMPLE_METHOD)

sample_steps

Number of sampling steps (default 20)

cfg_scale

Classifier-free guidance scale (default 7.0)

seed

Base random seed. Each patch gets seed + patch_index. Use -1 for random.

scheduler

Scheduler type (see SCHEDULER)

clip_skip

Number of CLIP layers to skip (-1 = auto)

eta

Eta parameter for DDIM-like samplers

vae_mode

VAE tiling mode for the harmonization pass (default "auto": VRAM-aware, see sd_txt2img).

vae_auto_threshold

Pixel area fallback threshold for auto VAE tiling when VRAM query is unavailable

vae_tile_size

Tile size for VAE tiling (default 64)

vae_tile_overlap

Overlap for VAE tiling (default 0.25)

Value

SD image (list with width, height, channel, data)

Examples

## Not run: 
ctx <- sd_ctx("sd15.safetensors", model_type = "sd1")
img <- sd_txt2img_highres(ctx, "a panoramic mountain landscape",
                          width = 2048, height = 1024)
sd_save_image(img, "panorama.png")

## End(Not run)

sd2R documentation built on March 30, 2026, 5:08 p.m.