Run evaluator calibration independently on original simulator recordings
Browse files
v4_wan_gt_full7200_20261127/code/SHA256SUMS
CHANGED
|
@@ -10,4 +10,4 @@ ac5d51e2cfd9b71c6858405ca8e9262dcff5c0369afe5c464e7cbe968bb19a67 wan_v4_termina
|
|
| 10 |
b215f7d8f7f5507cd0b3e47bb285dec80b973de59c889224861a36ec7ca39642 wan_v4_baseline_renders.py
|
| 11 |
9fb09dbf96309f5a161ed27c1683c82567b781a2811a51b005203839c7eb170e wan_v4_baseline_scores.py
|
| 12 |
19b32b37d9c86cf237ceade55b69297c6bc9d4e1e53581dfc1e30f17c350adf1 wan_v4_tracks.py
|
| 13 |
-
|
|
|
|
| 10 |
b215f7d8f7f5507cd0b3e47bb285dec80b973de59c889224861a36ec7ca39642 wan_v4_baseline_renders.py
|
| 11 |
9fb09dbf96309f5a161ed27c1683c82567b781a2811a51b005203839c7eb170e wan_v4_baseline_scores.py
|
| 12 |
19b32b37d9c86cf237ceade55b69297c6bc9d4e1e53581dfc1e30f17c350adf1 wan_v4_tracks.py
|
| 13 |
+
febdc2f918bc26e9ffac75e2a7e963f47a4bd0d6678ad72385ae2d5baf954611 wan_v4_track_metrics.py
|
v4_wan_gt_full7200_20261127/code/wan_v4_track_metrics.py
CHANGED
|
@@ -70,20 +70,32 @@ def iso():
|
|
| 70 |
|
| 71 |
|
| 72 |
def setup(a):
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
panel=
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
tracker_protocol=wait(a,a.tracking/"protocol.json")
|
| 79 |
tp=read(tracker_protocol)
|
| 80 |
require(tp["registered_test"]==panel and set(tp["test"])==set(m["test"]) and
|
| 81 |
tp["truth_inputs_used_in_tracking"]==[] and tp["future_geometry_inputs"]==0 and tp["fps"]==24 and tp["frames"]==48 and
|
| 82 |
tp["frame_reader_sha256"]==sha(a.scorer),"Tracker registration does not preserve the sealed observation/evaluation contract")
|
|
|
|
|
|
|
|
|
|
| 83 |
registration={"purpose":"retrospective independent tracking check, with reference qualification frozen before processing generated tracks",
|
| 84 |
"selection":"historical fixed 15 plus five registered v4 examples from the complete-graph test subset; 19 paired and 1 GT-only",
|
| 85 |
"registered_test":panel,"six_arm":m["test"],"arms":list(ARMS),"raw_revision":m.get("raw_revision"),
|
| 86 |
-
"
|
| 87 |
"tracker_protocol_sha256":sha(tracker_protocol),"scorer_sha256":sha(a.scorer),"metric_source_sha256":sha(Path(__file__)),
|
| 88 |
"frame_convention":"48 decoded frames indexed 0..47 at 24 Hz; edit and contact frames refer to these original timestamps; distances in 256x256 visible silhouette centroid pixels",
|
| 89 |
"motion":"unique simulator recipient, fixed endpoints hit-1/hit+7, GT centroid shift >=2 pixels; direction <=45 degrees and magnitude 0.5..1.5 times GT",
|
|
@@ -200,24 +212,40 @@ def quiet_targets(truth,cut,n):
|
|
| 200 |
|
| 201 |
|
| 202 |
def score(a,sc,source,sid,arm,ref_record=None):
|
| 203 |
-
original=read(a.baselines/"scores"/(sid+".json"))
|
| 204 |
pack=a.inputs/(sid+".npz");scene=source["scenes"][sid]
|
| 205 |
inp_sha=sha(pack)
|
| 206 |
-
require(inp_sha==scene["sha256"]
|
| 207 |
with np.load(pack,allow_pickle=False) as z:
|
| 208 |
gt=z["gt"];cut=len(z["observed"])-1;n=len(z["palette"]);step=int(z["step"])
|
| 209 |
prefix_hash=hashlib.sha256(np.ascontiguousarray(z["rgb"]).tobytes()).hexdigest()
|
| 210 |
observed_hash=hashlib.sha256(np.ascontiguousarray(z["observed"]).tobytes()).hexdigest()
|
| 211 |
names=scene["object_names"]
|
| 212 |
-
require(cut==
|
|
|
|
|
|
|
|
|
|
| 213 |
if arm=="reference":
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
record={}
|
| 220 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
record=original["binding"]["clips"][arm]
|
| 222 |
require(record==original["six_arm_binding"]["clips"][arm],"Changed generated-clip binding")
|
| 223 |
folder=a.root/"full_pass"/("model" if arm in ("gt","previous","attention") else "baseline_panel/model")
|
|
@@ -234,10 +262,10 @@ def score(a,sc,source,sid,arm,ref_record=None):
|
|
| 234 |
slots,visible,localized,switched=overlap_measurements(gt,labels,valid,conf,prompted,n,cut)
|
| 235 |
if ref_record is not None:
|
| 236 |
require(provenance["prompt_frames_by_slot"]==ref_record["lineage"]["prompt_frames_by_slot"] and
|
| 237 |
-
provenance["prompted_slots"]==ref_record["lineage"]["prompted_slots"]
|
| 238 |
truth=sc.tracks(gt,n)
|
| 239 |
obs=[{int(k):xy[t,k] for k in np.flatnonzero(valid[t])} for t in range(NFR)]
|
| 240 |
-
hits=[];quiet=[]; events=
|
| 241 |
for hit in events:
|
| 242 |
if len(hit["recipients"])!=1:continue
|
| 243 |
k=hit["recipients"][0]; t=hit["frame"];lo,hi=t-1,t+7
|
|
@@ -258,8 +286,8 @@ def score(a,sc,source,sid,arm,ref_record=None):
|
|
| 258 |
onset_support_localized=localized_timing,motion_eligible=eligible,motion_endpoints_localized=localized_endpoints,
|
| 259 |
motion=m,eligible_tracker_motion_control=bool(m["direction_matched"] and localized_endpoints),
|
| 260 |
eligible_tracker_timing_control=bool(error is not None and abs(error)<=2 and localized_timing)))
|
| 261 |
-
if
|
| 262 |
-
require(not
|
| 263 |
for spec in quiet_targets(truth,cut,n):
|
| 264 |
k,lo,hi=(spec[s] for s in ("slot","start","end"))
|
| 265 |
endpoints=bool(valid[lo,k] and valid[hi,k]); full=bool(valid[lo:hi+1,k].all())
|
|
@@ -278,8 +306,9 @@ def score(a,sc,source,sid,arm,ref_record=None):
|
|
| 278 |
conditional.append({"slot":k,"reference_qualified_frames":len(frames),"tracker_assigned":int(valid[frames,k].sum()),
|
| 279 |
"same_slot_localized":int(localized[frames,k].sum()),"overlap_prefers_other_slot":int(switched[frames,k].sum()),
|
| 280 |
"unassigned":int((~valid[frames,k]).sum())})
|
| 281 |
-
return {"scene":sid,"arm":arm,"stratum":
|
| 282 |
-
"lineage":provenance,"
|
|
|
|
| 283 |
"reference_conditioned_identity":conditional,"blind_slot_onsets":detected,"hits":hits,"quiet_v4":quiet,
|
| 284 |
**({"localized_reference_frames":gate_frames} if arm=="reference" else {})}
|
| 285 |
|
|
@@ -428,7 +457,7 @@ def report(a,reg):
|
|
| 428 |
return result
|
| 429 |
|
| 430 |
|
| 431 |
-
def publish(a,reg,final=False):
|
| 432 |
if a.no_publish:return
|
| 433 |
from huggingface_hub import HfApi,CommitOperationAdd
|
| 434 |
api=HfApi(token=True)
|
|
@@ -436,6 +465,7 @@ def publish(a,reg,final=False):
|
|
| 436 |
for sid in reg["registered_test"]:
|
| 437 |
key="reference/"+sid+".json"
|
| 438 |
if (a.out/key).is_file():files[key]=a.out/key
|
|
|
|
| 439 |
for arm in ARMS if sid in reg["six_arm"] else ("gt",):
|
| 440 |
key="measurements/"+arm+"/"+sid+".json"
|
| 441 |
if (a.out/key).is_file():files[key]=a.out/key
|
|
@@ -494,13 +524,17 @@ def main():
|
|
| 494 |
p.add_argument("--root",type=Path,required=True)
|
| 495 |
p.add_argument("--tracking",type=Path,required=True,help="Directory containing SAM protocol, tracks and receipts")
|
| 496 |
p.add_argument("--output",type=Path)
|
| 497 |
-
p.add_argument("--baselines",type=Path)
|
|
|
|
|
|
|
|
|
|
| 498 |
p.add_argument("--scorer",type=Path,default=Path(__file__).with_name("wan_v4_score.py"))
|
| 499 |
p.add_argument("--reference-root",type=Path,action="append",default=[])
|
| 500 |
p.add_argument("--fetch-reference",action="store_true")
|
| 501 |
p.add_argument("--no-publish",action="store_true")
|
| 502 |
p.add_argument("--wait-minutes",type=float,default=2880)
|
| 503 |
a=p.parse_args()
|
|
|
|
| 504 |
a.inputs=a.root/"inputs_full";panel=a.root/"full_pass/baseline_panel"
|
| 505 |
a.out=a.output or panel/"prefix_tracking_metrics"
|
| 506 |
a.baselines=a.baselines or panel/"evaluation"
|
|
@@ -522,7 +556,7 @@ def main():
|
|
| 522 |
r=score(a,sc,m,sid,arm,refs[sid])
|
| 523 |
write(a.out/"measurements"/arm/(sid+".json"),dict(**r,reference_lock_sha256=seal),True)
|
| 524 |
print("Scored independent tracks",sid,flush=True)
|
| 525 |
-
if (reg["registered_test"].index(sid)+1)%4==0:publish(a,reg)
|
| 526 |
report(a,reg)
|
| 527 |
publish(a,reg,final=True)
|
| 528 |
print("Completed independently tracked-video metrics",a.out/"summary.json",flush=True)
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
def setup(a):
|
| 73 |
+
plan=read(wait(a,a.inputs/"plan.json"))
|
| 74 |
+
panel=plan.get("registered_test",plan["test"])
|
| 75 |
+
require(len(set(panel))==len(panel)==20 and all(len(s)==6 and s.isdigit() for s in panel),"Invalid panel")
|
| 76 |
+
scene_receipts={s:wait(a,a.inputs/"receipts"/(s+".json")) for s in panel}
|
| 77 |
+
scenes={s:read(p) for s,p in scene_receipts.items()}
|
| 78 |
+
paired=[s for s in panel if scenes[s]["graph_status"]=="ok"]
|
| 79 |
+
require(len(paired)==19 and all(v["graph_status"] in ("ok","unobserved_slots") for v in scenes.values()),"Expected 19 complete graphs and one GT-only case")
|
| 80 |
+
# Registration uses source receipts that exist even while the training inputs are streaming.
|
| 81 |
+
# Neither the optional completed input manifest nor the upstream mask registry contains generated videos/scores.
|
| 82 |
+
for p in (a.inputs/"manifest.json",a.controls/"manifest.json"):
|
| 83 |
+
if p.is_file():
|
| 84 |
+
registry=read(p)
|
| 85 |
+
require(registry["registered_test"]==panel and set(registry["test"])==set(paired),"Upstream panel registry mismatch")
|
| 86 |
+
m=dict(registered_test=panel,test=paired,scenes=scenes,raw_revision=plan["raw_revision"])
|
| 87 |
tracker_protocol=wait(a,a.tracking/"protocol.json")
|
| 88 |
tp=read(tracker_protocol)
|
| 89 |
require(tp["registered_test"]==panel and set(tp["test"])==set(m["test"]) and
|
| 90 |
tp["truth_inputs_used_in_tracking"]==[] and tp["future_geometry_inputs"]==0 and tp["fps"]==24 and tp["frames"]==48 and
|
| 91 |
tp["frame_reader_sha256"]==sha(a.scorer),"Tracker registration does not preserve the sealed observation/evaluation contract")
|
| 92 |
+
require(tp["raw_revision"]==plan["raw_revision"] and all(
|
| 93 |
+
tp["sources"][s][k]==scenes[s][k] for s in panel for k in ("sha256","step","frames","object_names","graph_split","graph_status","version")),
|
| 94 |
+
"Tracker source receipts differ from the registered inputs")
|
| 95 |
registration={"purpose":"retrospective independent tracking check, with reference qualification frozen before processing generated tracks",
|
| 96 |
"selection":"historical fixed 15 plus five registered v4 examples from the complete-graph test subset; 19 paired and 1 GT-only",
|
| 97 |
"registered_test":panel,"six_arm":m["test"],"arms":list(ARMS),"raw_revision":m.get("raw_revision"),
|
| 98 |
+
"input_plan_sha256":sha(a.inputs/"plan.json"),"panel_source_receipt_sha256":{s:sha(p) for s,p in scene_receipts.items()},
|
| 99 |
"tracker_protocol_sha256":sha(tracker_protocol),"scorer_sha256":sha(a.scorer),"metric_source_sha256":sha(Path(__file__)),
|
| 100 |
"frame_convention":"48 decoded frames indexed 0..47 at 24 Hz; edit and contact frames refer to these original timestamps; distances in 256x256 visible silhouette centroid pixels",
|
| 101 |
"motion":"unique simulator recipient, fixed endpoints hit-1/hit+7, GT centroid shift >=2 pixels; direction <=45 degrees and magnitude 0.5..1.5 times GT",
|
|
|
|
| 212 |
|
| 213 |
|
| 214 |
def score(a,sc,source,sid,arm,ref_record=None):
|
|
|
|
| 215 |
pack=a.inputs/(sid+".npz");scene=source["scenes"][sid]
|
| 216 |
inp_sha=sha(pack)
|
| 217 |
+
require(inp_sha==scene["sha256"],"Input registration mismatch")
|
| 218 |
with np.load(pack,allow_pickle=False) as z:
|
| 219 |
gt=z["gt"];cut=len(z["observed"])-1;n=len(z["palette"]);step=int(z["step"])
|
| 220 |
prefix_hash=hashlib.sha256(np.ascontiguousarray(z["rgb"]).tobytes()).hexdigest()
|
| 221 |
observed_hash=hashlib.sha256(np.ascontiguousarray(z["observed"]).tobytes()).hexdigest()
|
| 222 |
names=scene["object_names"]
|
| 223 |
+
require(cut==(step-1)//10==scene["frames"]-1 and n==len(names) and scene["step"]==step,"Mismatch in source cutoff or slots")
|
| 224 |
+
require(source["raw_revision"]==sc.RAW_REV,"Unpinned simulator dataset")
|
| 225 |
+
stratum="v4_test" if sc.scene_population(scene)=="v4" else "legacy_"+scene["graph_split"]
|
| 226 |
+
require(stratum in STRATA and (stratum!="v4_test" or scene["graph_split"]=="test"),"Unexpected registered split")
|
| 227 |
if arm=="reference":
|
| 228 |
+
require(ref_record is None,"Reference grading cannot consume a generated or prior score record")
|
| 229 |
+
targets=sc.chain(sid,a,cut,n)
|
| 230 |
+
tracker_receipt=read(wait(a,a.tracking/"receipts/reference"/(sid+".json")))
|
| 231 |
+
require(tracker_receipt["arm"]=="reference" and tracker_receipt["generation_weights"] is None and
|
| 232 |
+
tracker_receipt["video_receipt_sha256"] is None and tracker_receipt["status"]=="tracked",
|
| 233 |
+
"Expected independent pinned simulator reference receipt")
|
| 234 |
+
genuine=sc.reference_path(sid,a)
|
| 235 |
+
video=sha(genuine) if genuine is not None else tracker_receipt["video_sha256"]
|
| 236 |
+
require(len(video)==64 and video==tracker_receipt["video_sha256"],"Simulator RGB bytes disagree with tracker lineage")
|
| 237 |
+
reference_media_verified_by="source_file_and_tracker_receipt" if genuine is not None else "completed_pinned_reference_tracker_receipt"
|
| 238 |
record={}
|
| 239 |
else:
|
| 240 |
+
require(ref_record is not None and (a.out/"reference_lock.json").is_file(),"Generated data cannot be read before the reference lock")
|
| 241 |
+
targets=ref_record["simulator_targets"]
|
| 242 |
+
reference_media_verified_by=ref_record["reference_media_verified_by"]
|
| 243 |
+
original=read(wait(a,a.baselines/"scores"/(sid+".json")))
|
| 244 |
+
require(original["scene"]==sid and original["binding"]["input"]==inp_sha and original["stratum"]==stratum
|
| 245 |
+
and original["paired"]==(sid in source["test"]) and original["prefix_last_frame"]==cut
|
| 246 |
+
and original["six_arm_binding"]["scorer"]==sha(a.scorer) and original["targets"]==targets
|
| 247 |
+
and original["binding"]["compact"]==targets["compact_sha256"]
|
| 248 |
+
and original["binding"]["reference"] in (None,ref_record["lineage"]["video_sha256"]),"Sealed simulator reference and downstream evaluation disagree")
|
| 249 |
record=original["binding"]["clips"][arm]
|
| 250 |
require(record==original["six_arm_binding"]["clips"][arm],"Changed generated-clip binding")
|
| 251 |
folder=a.root/"full_pass"/("model" if arm in ("gt","previous","attention") else "baseline_panel/model")
|
|
|
|
| 262 |
slots,visible,localized,switched=overlap_measurements(gt,labels,valid,conf,prompted,n,cut)
|
| 263 |
if ref_record is not None:
|
| 264 |
require(provenance["prompt_frames_by_slot"]==ref_record["lineage"]["prompt_frames_by_slot"] and
|
| 265 |
+
provenance["prompted_slots"]==ref_record["lineage"]["prompted_slots"],"Reference/generated prompt slot set or event registration changed")
|
| 266 |
truth=sc.tracks(gt,n)
|
| 267 |
obs=[{int(k):xy[t,k] for k in np.flatnonzero(valid[t])} for t in range(NFR)]
|
| 268 |
+
hits=[];quiet=[]; events=targets["hits"]
|
| 269 |
for hit in events:
|
| 270 |
if len(hit["recipients"])!=1:continue
|
| 271 |
k=hit["recipients"][0]; t=hit["frame"];lo,hi=t-1,t+7
|
|
|
|
| 286 |
onset_support_localized=localized_timing,motion_eligible=eligible,motion_endpoints_localized=localized_endpoints,
|
| 287 |
motion=m,eligible_tracker_motion_control=bool(m["direction_matched"] and localized_endpoints),
|
| 288 |
eligible_tracker_timing_control=bool(error is not None and abs(error)<=2 and localized_timing)))
|
| 289 |
+
if stratum=="v4_test":
|
| 290 |
+
require(not targets["any_post_contact"],"Positive event logged in v4 negative cohort")
|
| 291 |
for spec in quiet_targets(truth,cut,n):
|
| 292 |
k,lo,hi=(spec[s] for s in ("slot","start","end"))
|
| 293 |
endpoints=bool(valid[lo,k] and valid[hi,k]); full=bool(valid[lo:hi+1,k].all())
|
|
|
|
| 306 |
conditional.append({"slot":k,"reference_qualified_frames":len(frames),"tracker_assigned":int(valid[frames,k].sum()),
|
| 307 |
"same_slot_localized":int(localized[frames,k].sum()),"overlap_prefers_other_slot":int(switched[frames,k].sum()),
|
| 308 |
"unassigned":int((~valid[frames,k]).sum())})
|
| 309 |
+
return {"scene":sid,"arm":arm,"stratum":stratum,"six_arm":sid in source["test"],"prefix_last_frame":cut,"intervention_step":step,
|
| 310 |
+
"lineage":provenance,"simulator_targets":targets,"reference_media_verified_by":reference_media_verified_by,
|
| 311 |
+
**({"original_score_sha256":sha(a.baselines/"scores"/(sid+".json"))} if arm!="reference" else {}),"raw_slot_coverage":slots,
|
| 312 |
"reference_conditioned_identity":conditional,"blind_slot_onsets":detected,"hits":hits,"quiet_v4":quiet,
|
| 313 |
**({"localized_reference_frames":gate_frames} if arm=="reference" else {})}
|
| 314 |
|
|
|
|
| 457 |
return result
|
| 458 |
|
| 459 |
|
| 460 |
+
def publish(a,reg,final=False,generated=False):
|
| 461 |
if a.no_publish:return
|
| 462 |
from huggingface_hub import HfApi,CommitOperationAdd
|
| 463 |
api=HfApi(token=True)
|
|
|
|
| 465 |
for sid in reg["registered_test"]:
|
| 466 |
key="reference/"+sid+".json"
|
| 467 |
if (a.out/key).is_file():files[key]=a.out/key
|
| 468 |
+
if not (final or generated):continue
|
| 469 |
for arm in ARMS if sid in reg["six_arm"] else ("gt",):
|
| 470 |
key="measurements/"+arm+"/"+sid+".json"
|
| 471 |
if (a.out/key).is_file():files[key]=a.out/key
|
|
|
|
| 524 |
p.add_argument("--root",type=Path,required=True)
|
| 525 |
p.add_argument("--tracking",type=Path,required=True,help="Directory containing SAM protocol, tracks and receipts")
|
| 526 |
p.add_argument("--output",type=Path)
|
| 527 |
+
p.add_argument("--baselines",type=Path,help="Six-arm score directory; only consulted in generated stage")
|
| 528 |
+
p.add_argument("--controls",type=Path,help="Optional upstream mask registration directory; default ROOT/baseline_masks")
|
| 529 |
+
p.add_argument("--repo",type=Path,help="JAIS repository holding compact simulator contact files; default ROOT/../repo")
|
| 530 |
+
p.add_argument("--compact-root",type=Path,action="append",default=[],help="Additional explicit simulator compact roots; repeat as needed")
|
| 531 |
p.add_argument("--scorer",type=Path,default=Path(__file__).with_name("wan_v4_score.py"))
|
| 532 |
p.add_argument("--reference-root",type=Path,action="append",default=[])
|
| 533 |
p.add_argument("--fetch-reference",action="store_true")
|
| 534 |
p.add_argument("--no-publish",action="store_true")
|
| 535 |
p.add_argument("--wait-minutes",type=float,default=2880)
|
| 536 |
a=p.parse_args()
|
| 537 |
+
a.repo=a.repo or a.root.parent/"repo";a.controls=a.controls or a.root/"baseline_masks"
|
| 538 |
a.inputs=a.root/"inputs_full";panel=a.root/"full_pass/baseline_panel"
|
| 539 |
a.out=a.output or panel/"prefix_tracking_metrics"
|
| 540 |
a.baselines=a.baselines or panel/"evaluation"
|
|
|
|
| 556 |
r=score(a,sc,m,sid,arm,refs[sid])
|
| 557 |
write(a.out/"measurements"/arm/(sid+".json"),dict(**r,reference_lock_sha256=seal),True)
|
| 558 |
print("Scored independent tracks",sid,flush=True)
|
| 559 |
+
if (reg["registered_test"].index(sid)+1)%4==0:publish(a,reg,generated=True)
|
| 560 |
report(a,reg)
|
| 561 |
publish(a,reg,final=True)
|
| 562 |
print("Completed independently tracked-video metrics",a.out/"summary.json",flush=True)
|