Skip to content

generate_video() missing hires params — cannot use LTX 2.3 Spatial Latent Upscaler #24

Description

@martinbu69

Bug Description

The C API (stable-diffusion.h) defines sd_hires_params_t inside sd_vid_gen_params_t for the trained Spatial Latent Upscaler (e.g. LTX 2.3's ltx-2.3-spatial-upscaler-x2-1.1.safetensors). The ctypes struct in the Python bindings already has this field, but generate_video() does not accept or pass through the hires parameters.
Note: The constructor's upscaler_path is for ESRGAN pixel upscalers only and causes a segfault when used with the LTX spatial upscaler.

Patch

Three changes to stable_diffusion.py:

1. New parameters in generate_video() signature

hires: bool = False,
hires_path: str = "",
hires_upscaler: Union[str, SDHiresUpscaler, int, float] = "model",
hires_scale: float = 2.0,
hires_width: int = 0,
hires_height: int = 0,
hires_steps: int = 0,
hires_denoising_strength: float = 0.7,
hires_upscale_tile_size: int = 128,

2. Build hires struct before params

hires_upscaler = self._validate_and_set_input(
    hires_upscaler, SD_HIRES_UPSCALER_MAP, "hires_upscaler"
)
_hires_params = sd_cpp.sd_hires_params_t(
    enabled=hires,
    path=hires_path.encode("utf-8"),
    upscaler=hires_upscaler,
    scale=hires_scale,
    width=hires_width,
    height=hires_height,
    steps=hires_steps,
    denoising_strength=hires_denoising_strength,
    upscale_tile_size=hires_upscale_tile_size,
)

3. Pass to sd_vid_gen_params_t

hires=_hires_params

Usage

pipe.generate_video(
    prompt="A sunset over the ocean",
    hires=True,
    hires_path="/path/to/ltx-2.3-spatial-upscaler-x2-1.1.safetensors",
    hires_upscaler="model",
    hires_scale=2.0,
    hires_steps=15,
)

Tested with LTX 2.3 — produces x2 upscaled output (768×512 → 1536×1024).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions