fix(gallery/flux.2): enable VAE encoder so image edits actually work

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 <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-7 [Claude Code]
This commit is contained in:
Ettore Di Giacinto
2026-05-07 23:18:08 +00:00
parent 3bc5ae8da6
commit e6916ae9b1

View File

@@ -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