Revert to 512px default, remove diagnostic logging
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.
This commit is contained in:
+2
-9
@@ -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:
|
||||
|
||||
+1
-1
@@ -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=[
|
||||
|
||||
Reference in New Issue
Block a user