debrajsingha/dsp-repro-bundle / v0 /make_poster_figs.py
debrajsingha's picture
download
raw
2.84 kB
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams.update({"font.size": 13, "axes.spmttop": False} if False else {"font.size": 13})
TEAL = "#1F7A8C"; GOLD = "#C9A24A"; INK = "#14314A"
# Fig 1: ridge closed-form exactness (log scale of errors) + Alg1 MSE reduction
fig, ax = plt.subplots(1, 2, figsize=(9.2, 3.5))
labels = ["vs normal\nequation", "vs autograd\noptimum", "grad at\noptimum"]
errs = [2.7e-15, 3.6e-8, 9.4e-15]
ax[0].bar(labels, errs, color=[TEAL, GOLD, TEAL])
ax[0].set_yscale("log"); ax[0].axhline(1e-6, color="gray", ls="--", lw=1)
ax[0].set_ylabel("max abs error"); ax[0].set_title("Closed-form ridge Ŵ=T Pᵀ(PPᵀ+λI)⁻¹\nis the exact minimiser", fontsize=12)
ax[0].tick_params(axis="x", labelsize=10)
groups = ["synthetic\nmixture", "real DINOv2\ntokens"]
km = [0.003493, 4.313e-5]; fin = [0.002785, 1.607e-5]
x = np.arange(2); w = 0.36
ax[1].bar(x - w/2, km, w, label="K-Means init", color="#9bbfc9")
ax[1].bar(x + w/2, fin, w, label="+ridge refine (Alg.1)", color=TEAL)
for i in range(2):
g = (km[i]-fin[i])/km[i]*100
ax[1].text(x[i], max(km[i],fin[i])*1.02, f"−{g:.0f}%", ha="center", fontsize=11, color=INK, fontweight="bold")
ax[1].set_xticks(x); ax[1].set_xticklabels(groups); ax[1].set_yscale("log")
ax[1].set_ylabel("reconstruction MSE"); ax[1].set_title("Primitive Imbuing lowers recon error", fontsize=12)
ax[1].legend(fontsize=10, loc="lower left")
plt.tight_layout(); plt.savefig("outputs/fig_ridge.png", dpi=150); plt.close()
# Fig 2: semantic anchoring separation
fig, ax = plt.subplots(figsize=(4.6, 3.5))
ax.bar(["within\ncategory", "cross\ncategory"], [0.9967, 0.8952], color=[TEAL, "#c9a24a"])
ax.set_ylim(0.8, 1.02); ax.set_ylabel("cosine sim to anchor")
ax.annotate("", xy=(0, 0.9967), xytext=(1, 0.8952), arrowprops=dict(arrowstyle="<->", color=INK))
ax.text(0.5, 0.95, "separation\n0.102", ha="center", fontsize=11, color=INK, fontweight="bold")
ax.set_title("Semantic Anchoring:\nstable, separable per-category anchors\n(DINOv2 ViT-L/14, 5 exemplars)", fontsize=11)
plt.tight_layout(); plt.savefig("outputs/fig_anchor.png", dpi=150); plt.close()
# Fig 3: Table 1 target FID (DIOR)
fig, ax = plt.subplots(figsize=(4.6, 3.5))
methods = ["MIGC", "CC-Diff", "CC-Diff++", "DSP\n(ours)"]
fids = [89.20, 82.51, 82.62, 74.34]
colors = ["#9bbfc9", "#9bbfc9", "#9bbfc9", TEAL]
bars = ax.bar(methods, fids, color=colors)
ax.set_ylabel("Bootstrap FID ↓ (DIOR)"); ax.set_ylim(70, 92)
ax.annotate("−8.17 vs CC-Diff", xy=(3, 74.34), xytext=(1.3, 78),
arrowprops=dict(arrowstyle="->", color=INK), fontsize=11, color=INK, fontweight="bold")
ax.set_title("Claim 2 target (paper Table 1)\nnot re-measured here", fontsize=11)
plt.tight_layout(); plt.savefig("outputs/fig_fid.png", dpi=150); plt.close()
print("figs written")

Xet Storage Details

Size:
2.84 kB
·
Xet hash:
976a9009f0275302c88970077c3533346d9da08b13691591cf5bf6e36a830ffc

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.