From e6916ae9b14feed3f4c2c4be63fb35332bc77833 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Thu, 7 May 2026 23:18:08 +0000 Subject: [PATCH] fix(gallery/flux.2): enable VAE encoder so image edits actually work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit stable-diffusion.cpp loads the VAE encoder weights only when the ctx is created with vae_decode_only=false. Our gosd wrapper defaults that flag to true, and the upstream flux2/flux2-klein code paths don't auto-flip it (sd_version_is_unet_edit / sd_version_is_control both return false for VERSION_FLUX2 and VERSION_FLUX2_KLEIN). The CLI compensates by flipping the flag whenever -r/--ref-image is passed, but on the server side we don't know that at load time. Result: requests to /v1/images/generations with `ref_images` against flux.2-dev / flux.2-klein-{4b,9b} would silently skip the encode step (first_stage_model.encoder + tae.encoder are dropped at load via ignore_tensors), and the output had no relation to the reference image — image-editing was effectively unsupported even though stable-diffusion.cpp itself supports it. Add `vae_decode_only:false` to the options of all three flux.2 gallery entries so the encoder is loaded on first launch. Verified on a live instance: a 64x64 striped reference image produces an output that preserves the 3-band layout, confirming the VAE encoder is now wired through. Signed-off-by: Ettore Di Giacinto Assisted-by: Claude:claude-opus-4-7 [Claude Code] --- gallery/index.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gallery/index.yaml b/gallery/index.yaml index 9cbc9e051..8e69be785 100644 --- a/gallery/index.yaml +++ b/gallery/index.yaml @@ -25280,6 +25280,7 @@ - sampler:euler - llm_path:stablediffusion-cpp/models/Mistral-Small-3.2-24B-Instruct-2506-Q4_K_M.gguf - offload_params_to_cpu:true + - vae_decode_only:false parameters: model: stablediffusion-cpp/models/flux2-dev-Q4_K_M.gguf step: 50 @@ -25323,6 +25324,7 @@ - sampler:euler - llm_path:stablediffusion-cpp/models/Qwen3-4B-Q4_K_M.gguf - offload_params_to_cpu:true + - vae_decode_only:false parameters: model: stablediffusion-cpp/models/flux-2-klein-4b-Q4_0.gguf step: 4 @@ -25366,6 +25368,7 @@ - sampler:euler - llm_path:stablediffusion-cpp/models/Qwen3-8B-Q4_K_M.gguf - offload_params_to_cpu:true + - vae_decode_only:false parameters: model: stablediffusion-cpp/models/flux-2-klein-9b-Q4_0.gguf step: 4