diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..3f92d58 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,12 @@ +{ + "permissions": { + "allow": [ + "WebFetch(domain:arxiv.org)", + "WebFetch(domain:www.arxiv.org)", + "WebFetch(domain:github.com)", + "Bash(gh api:*)", + "WebFetch(domain:api.github.com)", + "WebFetch(domain:raw.githubusercontent.com)" + ] + } +} diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..8928f14 Binary files /dev/null and b/__pycache__/__init__.cpython-312.pyc differ diff --git a/core/__pycache__/__init__.cpython-310.pyc b/core/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..d0d646a Binary files /dev/null and b/core/__pycache__/__init__.cpython-310.pyc differ diff --git a/core/__pycache__/__init__.cpython-312.pyc b/core/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..097d3c3 Binary files /dev/null and b/core/__pycache__/__init__.cpython-312.pyc differ diff --git a/core/__pycache__/calibration.cpython-310.pyc b/core/__pycache__/calibration.cpython-310.pyc new file mode 100644 index 0000000..76b9e65 Binary files /dev/null and b/core/__pycache__/calibration.cpython-310.pyc differ diff --git a/core/__pycache__/calibration.cpython-312.pyc b/core/__pycache__/calibration.cpython-312.pyc new file mode 100644 index 0000000..b2a9676 Binary files /dev/null and b/core/__pycache__/calibration.cpython-312.pyc differ diff --git a/core/__pycache__/color_space.cpython-310.pyc b/core/__pycache__/color_space.cpython-310.pyc new file mode 100644 index 0000000..65dc778 Binary files /dev/null and b/core/__pycache__/color_space.cpython-310.pyc differ diff --git a/core/__pycache__/color_space.cpython-312.pyc b/core/__pycache__/color_space.cpython-312.pyc new file mode 100644 index 0000000..be93df2 Binary files /dev/null and b/core/__pycache__/color_space.cpython-312.pyc differ diff --git a/core/__pycache__/defaults.cpython-310.pyc b/core/__pycache__/defaults.cpython-310.pyc new file mode 100644 index 0000000..64676f6 Binary files /dev/null and b/core/__pycache__/defaults.cpython-310.pyc differ diff --git a/core/__pycache__/defaults.cpython-312.pyc b/core/__pycache__/defaults.cpython-312.pyc new file mode 100644 index 0000000..427293a Binary files /dev/null and b/core/__pycache__/defaults.cpython-312.pyc differ diff --git a/core/__pycache__/diagnostics.cpython-312.pyc b/core/__pycache__/diagnostics.cpython-312.pyc new file mode 100644 index 0000000..9f585a4 Binary files /dev/null and b/core/__pycache__/diagnostics.cpython-312.pyc differ diff --git a/core/__pycache__/lcs_data.cpython-310.pyc b/core/__pycache__/lcs_data.cpython-310.pyc new file mode 100644 index 0000000..b08c80a Binary files /dev/null and b/core/__pycache__/lcs_data.cpython-310.pyc differ diff --git a/core/__pycache__/lcs_data.cpython-312.pyc b/core/__pycache__/lcs_data.cpython-312.pyc new file mode 100644 index 0000000..6c2bec5 Binary files /dev/null and b/core/__pycache__/lcs_data.cpython-312.pyc differ diff --git a/core/__pycache__/patchify.cpython-310.pyc b/core/__pycache__/patchify.cpython-310.pyc new file mode 100644 index 0000000..347d1b7 Binary files /dev/null and b/core/__pycache__/patchify.cpython-310.pyc differ diff --git a/core/__pycache__/patchify.cpython-312.pyc b/core/__pycache__/patchify.cpython-312.pyc new file mode 100644 index 0000000..b02eab2 Binary files /dev/null and b/core/__pycache__/patchify.cpython-312.pyc differ diff --git a/core/__pycache__/timestep.cpython-310.pyc b/core/__pycache__/timestep.cpython-310.pyc new file mode 100644 index 0000000..71e041c Binary files /dev/null and b/core/__pycache__/timestep.cpython-310.pyc differ diff --git a/core/__pycache__/timestep.cpython-312.pyc b/core/__pycache__/timestep.cpython-312.pyc new file mode 100644 index 0000000..6bc10bd Binary files /dev/null and b/core/__pycache__/timestep.cpython-312.pyc differ diff --git a/core/calibration.py b/core/calibration.py index e0cb2b7..76919ff 100644 --- a/core/calibration.py +++ b/core/calibration.py @@ -53,6 +53,9 @@ def calibrate(vae, num_colors=512, image_size=512, batch_size=8): """ device = comfy.model_management.intermediate_device() + print(f"\n[LCS Calibration] Starting calibration for {num_colors} colors...") + print(f"[LCS Calibration] Image size: {image_size}x{image_size}, Batch size: {batch_size}") + # Step 1: Sample colors uniformly from HSV (full saturation, full value for diversity) colors = [] for i in range(num_colors): @@ -68,6 +71,9 @@ def calibrate(vae, num_colors=512, image_size=512, batch_size=8): vectors = [] pbar = comfy.utils.ProgressBar(num_colors) + num_batches = (num_colors + batch_size - 1) // batch_size + print(f"[LCS Calibration] Encoding {num_colors} color images in {num_batches} batches...") + for batch_start in range(0, num_colors, batch_size): batch_end = min(batch_start + batch_size, num_colors) batch_colors = colors[batch_start:batch_end] @@ -95,8 +101,10 @@ def calibrate(vae, num_colors=512, image_size=512, batch_size=8): # Stack all vectors: [N, 64] X = torch.stack(vectors, dim=0).float() + print(f"[LCS Calibration] Collected {X.shape[0]} patch vectors of dimension {X.shape[1]}") # Step 4: PCA + print("[LCS Calibration] Computing PCA...") mean = X.mean(dim=0) # [64] X_centered = X - mean # SVD for PCA @@ -104,9 +112,16 @@ def calibrate(vae, num_colors=512, image_size=512, batch_size=8): # Top 3 components: B = V[:, :3] (columns are principal directions) basis = Vh[:3].T # [64, 3] (Vh rows are right singular vectors) + # Variance explained + total_var = (S ** 2).sum() + explained = (S[:3] ** 2) / total_var + print(f"[LCS Calibration] Top 3 components explain {explained.sum():.1%} variance") + print(f"[LCS Calibration] PC1: {explained[0]:.1%}, PC2: {explained[1]:.1%}, PC3: {explained[2]:.1%}") + # Step 5: Encode 8 anchor colors → LCS coords + print("[LCS Calibration] Encoding 8 anchor colors...") anchor_lcs_list = [] - for r, g, b in ANCHOR_COLORS_RGB: + for i, (r, g, b) in enumerate(ANCHOR_COLORS_RGB): img = torch.zeros(1, image_size, image_size, 3, dtype=torch.float32, device="cpu") img[0, :, :, 0] = r img[0, :, :, 1] = g @@ -123,6 +138,9 @@ def calibrate(vae, num_colors=512, image_size=512, batch_size=8): # Compute hue angles for 6 chromatic anchors anchor_angles = _compute_anchor_angles(anchor_lcs, basis, mean) + print(f"[LCS Calibration] Complete! Basis shape: {basis.shape}") + print(f"[LCS Calibration] Anchor LCS coords:\n{anchor_lcs}") + return LCSData( basis=basis, mean=mean, diff --git a/data/lcs_bc7957e0.safetensors b/data/lcs_bc7957e0.safetensors new file mode 100644 index 0000000..847f0bc Binary files /dev/null and b/data/lcs_bc7957e0.safetensors differ diff --git a/nodes/__pycache__/__init__.cpython-312.pyc b/nodes/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..a73e2a9 Binary files /dev/null and b/nodes/__pycache__/__init__.cpython-312.pyc differ diff --git a/nodes/__pycache__/calibrate.cpython-312.pyc b/nodes/__pycache__/calibrate.cpython-312.pyc new file mode 100644 index 0000000..8ebd826 Binary files /dev/null and b/nodes/__pycache__/calibrate.cpython-312.pyc differ diff --git a/nodes/__pycache__/intervene.cpython-312.pyc b/nodes/__pycache__/intervene.cpython-312.pyc new file mode 100644 index 0000000..e328955 Binary files /dev/null and b/nodes/__pycache__/intervene.cpython-312.pyc differ diff --git a/nodes/__pycache__/observe.cpython-312.pyc b/nodes/__pycache__/observe.cpython-312.pyc new file mode 100644 index 0000000..978154b Binary files /dev/null and b/nodes/__pycache__/observe.cpython-312.pyc differ