Remove vision_strength

Scrap the gray-fade vision strength control. mask_padding and the
downscale-only vision cap are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ethanfel
2026-06-25 03:52:02 +02:00
co-authored by Claude Opus 4.8
parent b713592e37
commit 32cbe915f7
2 changed files with 2 additions and 19 deletions
-1
View File
@@ -48,7 +48,6 @@ downstream of this node — that works generically at the sampler level.)
| `image1…N` | IMAGE | Optional reference images; slots grow as you connect them. |
| `mask1…N` | MASK | Optional per-image mask; crops `imageN` to the masked bounding box. |
| `mask_padding` | FLOAT | Context kept around the mask, as a fraction of image size per side (`0` = tight, default). |
| `vision_strength` | FLOAT | How strongly references influence the result. `1.0` = full; lower fades toward neutral gray (`0.0` ≈ text-only). |
| `vision_megapixels` | FLOAT | Max size before the vision encoder; references are downscaled to this cap, never upscaled (default `1.0`). |
Output is a standard `CONDITIONING` for the Krea2 sampler. With no images connected it
+2 -18
View File
@@ -60,13 +60,6 @@ class TextEncodeKrea2:
"image size added on EACH side. 0 = tight crop to the mask; 0.1 = ~10% "
"margin of surroundings. Only applies when a mask is connected.",
}),
"vision_strength": ("FLOAT", {
"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.05,
"tooltip": "How strongly each reference image influences the result. 1.0 = full; "
"lower fades the image toward neutral gray (which Qwen3-VL reads as ~no "
"signal) so the VLM keys off it less. 0.0 = effectively text-only. For "
"stronger-than-full influence, raise vision_megapixels instead.",
}),
},
}
@@ -123,15 +116,7 @@ class TextEncodeKrea2:
return image[:, y0:y1 + 1, x0:x1 + 1, :]
@staticmethod
def _apply_vision_strength(image, strength):
"""Lerp the reference toward neutral gray (0.5). Qwen3-VL normalizes with
mean/std 0.5, so 0.5 gray -> ~zero vision signal; strength dials influence."""
if strength >= 1.0:
return image
return (0.5 + strength * (image - 0.5)).clamp(0.0, 1.0)
def encode(self, clip, prompt, vision_megapixels=1.0, mask_padding=0.0, vision_strength=1.0, **kwargs):
def encode(self, clip, prompt, vision_megapixels=1.0, mask_padding=0.0, **kwargs):
images = self._collect_indexed(kwargs, "image")
masks = self._collect_indexed(kwargs, "mask")
ordered = sorted(images.keys())
@@ -152,8 +137,7 @@ class TextEncodeKrea2:
height = round(samples.shape[2] * scale_by)
s = comfy.utils.common_upscale(samples, width, height, "area", "disabled")
vl = self._apply_vision_strength(s.movedim(1, -1)[:, :, :, :3], vision_strength)
images_vl.append(vl)
images_vl.append(s.movedim(1, -1)[:, :, :, :3])
if len(ordered) > 1:
image_prompt += "Picture {}: <|vision_start|><|image_pad|><|vision_end|>".format(slot + 1)