{result['width']:,} × {result['height']:,} px · {result['views']-1} local tiles
Scores are uncalibrated model outputs, not definitive evidence of image origin.
""")
def stats_card(state):
if not state:
return ""
attention = state["attention"]
layer = next(
(row[2] for row in state["parameters"] if row[1] == "Feature extraction layer"),
"24",
)
stats = [
(str(len(state["boxes"])), "Local tiles + 1 global view"),
(str(attention["l1_heads"].shape[0]), "L1 aggregation heads"),
(
f"{attention['patch'].shape[1]} × {attention['patch'].shape[2]}",
"Patch grid per tile",
),
(str(layer), "CLIP feature block"),
]
return card(
'
'
+ "".join(
f'
{escape(value)}{label}
'
for value, label in stats
)
+ "
"
)
def scale_legend():
return (
'
≤0.25×0.5×'
"1× uniform2×≥4×
"
)
def weight_chart(state, selection="mean", level="l1"):
if not state:
return ""
attention = state["attention"]
if level == "l2":
weights = attention["l2"]
labels = ["Global"] + [f"T{i+1}" for i in range(len(weights) - 1)]
title = "L2 View Weights"
else:
weights = (
attention["l1"]
if selection == "mean"
else attention["l1_heads"][int(selection.split("_")[-1]) - 1]
)
labels = [f"T{i+1}" for i in range(len(weights))]
title = "L1 Tile Weights · " + (
"Mean of 8 heads" if selection == "mean" else selection.replace("_", " ")
)
n = len(weights)
order = np.argsort(-weights, kind="stable")[:10]
maximum = max(float(weights.max()), 1 / n) * 1.12
width, left, track, row_height = 430, 63, 290, 32
height = 38 + row_height * len(order)
baseline = left + track * (1 / n) / maximum
svg = [
f''
)
ratio = float(weights.max()) * n
message = (
"Attention is nearly uniform, with no pronounced concentration. The heatmap does not exaggerate small differences."
if float(np.ptp(weights)) * n < 0.10
else f"The largest weight is {ratio:.2f}× uniform. Rankings show attention, not evidence of forgery."
)
if level == "l2":
message = (
f"The global view receives {float(weights[0])*100:.2f}%; the overlay shows local tiles only. "
+ message
)
return card(
f'
{title}
Normalized attention weights sum to 100% across all items.
'
+ "".join(svg)
+ scale_legend()
+ f'
{message}
'
)
def patch_matrix(state, tile_number):
if not state:
return ""
from attention import attention_levels, colors
index = int(tile_number) - 1
weights = state["attention"]["patch"][index]
palette = colors(attention_levels(weights, weights.size))
h, w = weights.shape
cells = []
for y in range(h):
for x in range(w):
color = "#%02x%02x%02x" % tuple(palette[y, x])
value = float(weights[y, x])
cells.append(
f''
f"Row {y+1}, column {x+1} · {value*100:.5f}% · {value*weights.size:.3f}× uniform"
)
return card(
f'
T{index+1} · Patch Attention Matrix
Hover to inspect exact weights. Each cell corresponds to 14 × 14 input pixels.
'
f'"
+ scale_legend()
+ '
Shared scale relative to uniform attention: gray is near uniform, blue is lower, and orange-red is higher.