scripts: figure generators + frame-regen script for the opencv5 report
make_figures.py gains the DE-landscape, calibration, and per-film leave-one-out holdout figures used by the experiment log. regen_frame_examples.sh replays all nine films with the shipped learned-boundary flood config and draws GT-aware TP/FP/FN frames, so every annotated image in the docs is reproducible.
This commit is contained in:
@@ -68,5 +68,51 @@ def fig_evolution():
|
||||
ax.set_ylim(0,18)
|
||||
fig.tight_layout(); fig.savefig(OUT/"scene_detector_evolution.png"); plt.close(fig)
|
||||
|
||||
fig_presence(); fig_macro(); fig_evolution()
|
||||
print("wrote:", *(p.name for p in sorted(OUT.glob("scene_*.png"))))
|
||||
import csv as _csv
|
||||
|
||||
# ── Figure 4: DE convergence (the 10-knob presence sweep) ────────────────────
|
||||
def fig_de():
|
||||
import json
|
||||
rows=[json.loads(l) for l in open("experiments/trajectories/lvface_opencv5_10knob.FINAL.jsonl")]
|
||||
f1=[r["f1"]*100 for r in rows]
|
||||
run_best=np.maximum.accumulate(f1)
|
||||
fig,ax=plt.subplots(figsize=(8,4.5))
|
||||
ax.scatter(range(len(f1)),f1,s=8,alpha=0.35,color="#9aa7b4",label="candidate")
|
||||
ax.plot(run_best,color="#3d7ea6",lw=2,label="best so far")
|
||||
ax.set_xlabel("DE evaluation"); ax.set_ylabel("macro presence F1 (%)")
|
||||
ax.set_title("10-knob presence sweep (Differential Evolution)")
|
||||
ax.legend(loc="lower right"); ax.set_ylim(0, max(f1)+8)
|
||||
ax.text(0.02,0.95,f"optimum {max(f1):.1f}%",transform=ax.transAxes,va="top",
|
||||
fontsize=10,bbox=dict(boxstyle="round",fc="#f4f4f4",ec="#ccc"))
|
||||
fig.tight_layout(); fig.savefig(OUT/"de_search_landscape.png"); plt.close(fig)
|
||||
|
||||
# ── Figure 5: calibration curve (similarity → P(match)) ──────────────────────
|
||||
def fig_calibration():
|
||||
sims,ps=[],[]
|
||||
with open("experiments/galleries/gallery_LVFace-B_Glint360K.h5.calib_cache.csv") as f:
|
||||
for r in _csv.DictReader(f):
|
||||
sims.append(float(r["similarity"])); ps.append(float(r["p_match"]))
|
||||
fig,ax=plt.subplots(figsize=(6.5,4.5))
|
||||
ax.plot(sims,ps,color="#3d7ea6",lw=2)
|
||||
ax.axhline(0.485,ls="--",color="#e07a5f",lw=1,label="shipped threshold 0.485")
|
||||
ax.set_xlabel("cosine similarity"); ax.set_ylabel("calibrated P(match)")
|
||||
ax.set_title("LVFace-B Glint360K calibration"); ax.set_xlim(-1,1); ax.legend()
|
||||
fig.tight_layout(); fig.savefig(OUT/"calibration_curves.png"); plt.close(fig)
|
||||
|
||||
# ── Figure 6: holdout F1 by film (learned detector, LOO) ─────────────────────
|
||||
def fig_holdout():
|
||||
order=np.argsort(FL)
|
||||
fig,ax=plt.subplots(figsize=(8,4.5))
|
||||
y=np.arange(len(FILMS))
|
||||
ax.barh(y,[FL[i] for i in order],color="#3d7ea6")
|
||||
ax.set_yticks(y); ax.set_yticklabels([FILMS[i] for i in order])
|
||||
ax.set_xlabel("presence F1 (%), learned detector (LOO)")
|
||||
ax.set_title("Per-film presence F1 — leave-one-out")
|
||||
ax.axvline(np.mean(FL),ls="--",color="#333",lw=1)
|
||||
ax.text(np.mean(FL)+1,0.2,f"macro {np.mean(FL):.1f}%",fontsize=9)
|
||||
for i,idx in enumerate(order): ax.text(FL[idx]+0.5,i,f"{FL[idx]:.0f}",va="center",fontsize=8)
|
||||
ax.set_xlim(0,100)
|
||||
fig.tight_layout(); fig.savefig(OUT/"holdout_f1_by_film.png"); plt.close(fig)
|
||||
|
||||
fig_presence(); fig_macro(); fig_evolution(); fig_de(); fig_calibration(); fig_holdout()
|
||||
print("wrote:", *(p.name for p in sorted(OUT.glob("*.png"))))
|
||||
|
||||
Reference in New Issue
Block a user