From 1d024be9dab6d0289f72a86e3b3845edee21efc2 Mon Sep 17 00:00:00 2001 From: facok <128763816+facok@users.noreply.github.com> Date: Fri, 20 Mar 2026 17:06:17 +0800 Subject: [PATCH] Revert to 512px default, remove diagnostic logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 256 vs 512 difference (97.5% vs 97.3%) is within random variation — different image_size consumes different random numbers from the same seed, producing different images rather than a controlled comparison. Keep 512 consistent with LCS color calibration. Remove per-blur-level mean logging that was used during development. --- core/sharpness.py | 11 ++--------- nodes/sharpen.py | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/core/sharpness.py b/core/sharpness.py index 17a940f..265cdf1 100644 --- a/core/sharpness.py +++ b/core/sharpness.py @@ -100,7 +100,7 @@ def _apply_gaussian_blur(images: torch.Tensor, blur_sigma: float) -> torch.Tenso return blurred -def calibrate_sharpness(vae, num_samples: int = 64, image_size: int = 256, +def calibrate_sharpness(vae, num_samples: int = 64, image_size: int = 512, blur_levels: Tuple[float, ...] = (0, 0.5, 1, 2, 4, 8), batch_size: int = 8, lcs_data: LCSData = None) -> SharpnessData: @@ -179,19 +179,12 @@ def calibrate_sharpness(vae, num_samples: int = 64, image_size: int = 256, blur_labels_t = torch.tensor(blur_labels, dtype=torch.float32) print(f"[LCS Sharpness Calibration] Collected {X.shape[0]} vectors of dimension {X.shape[1]}") - # Check per-blur-level mean to see if blur affects brightness in latent space - for bl in blur_levels: - mask_bl = blur_labels_t == bl - level_mean = X[mask_bl].mean().item() - print(f"[LCS Sharpness Calibration] blur σ={bl}: latent mean={level_mean:.4f} (n={mask_bl.sum().item()})") - # Remove per-vector mean BEFORE PCA. # VAE encoding of blurred images shifts the latent mean (non-linear VAE effect). # Without this, PCA captures brightness drift as the dominant component. # Per-vector zero-mean forces PCA to find patterns in the relative channel # structure, not in the absolute level — isolating true sharpness. - X_per_mean = X.mean(dim=1, keepdim=True) # [N, 1] - X = X - X_per_mean + X = X - X.mean(dim=1, keepdim=True) # Optionally remove LCS color component to ensure sharpness PC1 is orthogonal to color if lcs_data is not None: diff --git a/nodes/sharpen.py b/nodes/sharpen.py index 6381c61..7fd0b65 100644 --- a/nodes/sharpen.py +++ b/nodes/sharpen.py @@ -61,7 +61,7 @@ class LCSSharpnessCalibrate(io.ComfyNode): inputs=[ io.Vae.Input("vae", tooltip="VAE model (calibration is cached per-VAE)"), LCS_DATA.Input("lcs_data", optional=True, tooltip="Optional: remove color component to prevent color shifts"), - io.Int.Input("image_size", default=256, min=256, max=1024, step=128, + io.Int.Input("image_size", default=512, min=256, max=1024, step=128, tooltip="Size of calibration images (higher = more patches averaged, may improve PCA)"), ], outputs=[