refactor(presence): execute the extinction_sec/anneal_sec withdrawal
docs/SPEC.md specified this removal, listed its parts, and ended "grep
for both names and expect no survivors". There were about forty.
docs/requirements.md meanwhile recorded both constants as Withdrawn and
"deleted rather than retained at zero", on the grounds that a field
naming a mechanism the pipeline no longer has is actively misleading.
Neither statement was true of the code: Config still carried
extinction_sec 57.4 and anneal_sec 35.5, --extinction and --anneal still
parsed, and SceneTrackerFunc still ran its keep-alive in both shipped
pipelines, announcing its timeout at every startup.
SceneTrackerFunc is replaced by FrameAnnotationFunc, which is stateless:
same ports, same output type, no keep-alive. Presence belongs to
TrackRegistry (AR-012), where a window is the extent of a track an actor
owned and ends at the last sighting (AR-013). The keep-alive answered
that question a second time and answered it worse, by re-opening exactly
the trailing cool-down AR-013 refuses.
Visible change: --verbosity standard's frames[].identified listed every
actor inside the keep-alive, including ones absent from the frame. It
now lists what was matched in that frame. Minimal and xray output is
untouched -- both were already built from registry claims and never
consulted this node. No schema bump: the published extraction block
reports track_extinction_sec, a different knob that bounds
re-association and never extends a claim.
TrackRegistry::Config::extinction_sec is renamed track_extinction_sec to
match the Config field feeding it, so the grep SPEC.md asks for now
returns nothing rather than one confusing false positive.
Two targets turned out to have been silently dead, both since the
AR-007/AR-008 tracker redesign, and both for the same reason -- they
construct FaceTrackerFunc from a Config alone, a signature that stopped
existing when association moved into probability space:
- scene_preview is fixed here. It now mirrors main.cpp's construction
order exactly (matcher, then registry, then tracker) and wires the
registry's claims into the sink, which it was not doing. DP-001 says
modes are front-ends that must not fork pipeline logic; this one had
forked it and then rotted.
- sae_kpn is not fixed. Restructuring the seam so the tracker can reach
a calibration that only exists once the matcher is built is VR-011's
rewrite, not a patch, and presence claims do not cross the seam at all
today. It is now behind SAE_BUILD_KPN_BINDINGS=OFF with the reason
recorded, so `cmake --build` succeeds and the breakage is attributed
rather than rediscovered.
That second one is worth stating plainly: VR-002 ("replay drives the
real KPN nodes, not a reimplementation") is marked Done, and the module
that makes replay possible has not compiled for some time. The .so in a
stale build/ predates the change.
Python side: the two names are gone from optimize.py, replay.py and
run_holdout_all_models.py as Config keys. anneal_sec survives as
REPLAY_LOCAL_KEYS -- it still configures replay.py's own windowing,
which is a Python reimplementation that no longer matches the sink and
is documented as such. That divergence is VR-011's.
TRACES: AR-012, AR-013 | DP-001 | SR-002
This commit is contained in:
+33
-10
@@ -6,14 +6,14 @@ TRACES: VR-002 | PR-002
|
||||
|
||||
Reads an embedding dump (scripts/optimizer/SCHEMA.md), feeds each frame as an
|
||||
EmbeddedSceneFrame into a Python-assembled KPN network wiring the *real* C++
|
||||
face_tracker → identity_matcher → scene_tracker, and returns the same presence-window
|
||||
face_tracker → identity_matcher → frame_annotation, and returns the same presence-window
|
||||
JSON that scene_analyze's result_sink produces (minimal schema). No decode, no GPU
|
||||
embedding — only the cheap downstream tail runs, so a sweep can vary Config knobs
|
||||
freely. See [[kpn-python-replay-optimizer]].
|
||||
|
||||
CLI:
|
||||
python scripts/optimizer/replay.py --dump film.h5 --gallery gallery.json \
|
||||
--out replayed.json [--prob-threshold 0.99] [--anneal 10] ...
|
||||
--out replayed.json [--prob-threshold 0.99] [--anneal-sec 10] ...
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -164,7 +164,7 @@ def replay(dump_path: str, gallery: str, cfg: dict, build_dir: str, stop: bool =
|
||||
sae_kpn.add_face_tracker(net, "tracker", cfg, cap)
|
||||
sae_kpn.add_identity_matcher(net, "matcher", gallery, cfg, cap,
|
||||
stamp["model_name"], stamp["model_sha256"])
|
||||
sae_kpn.add_scene_tracker(net, "scene", cfg, cap)
|
||||
sae_kpn.add_frame_annotation(net, "scene", cap)
|
||||
net.connect("replay", 0, "tracker", 0)
|
||||
net.connect("tracker", 0, "matcher", 0)
|
||||
net.connect("matcher", 0, "scene", 0)
|
||||
@@ -207,10 +207,26 @@ def replay(dump_path: str, gallery: str, cfg: dict, build_dir: str, stop: bool =
|
||||
|
||||
|
||||
def build_minimal(annotations, movie, fps, cfg) -> dict:
|
||||
"""Reproduce result_sink's minimal schema: per-actor annealed [start,end] windows.
|
||||
"""Per-actor [start,end] windows, built by annealing per-frame detections.
|
||||
|
||||
Mirrors ResultSinkFunc::build_actor_windows — merge each actor's detection
|
||||
timestamps into windows, bridging gaps shorter than anneal_sec.
|
||||
TRACES: VR-011 | PR-002
|
||||
|
||||
This NO LONGER mirrors ResultSinkFunc, and the docstring used to claim it
|
||||
did. The sink builds a window from a TrackRegistry claim -- the extent
|
||||
[first_seen, last_seen] of a track an actor owned (AR-012) -- so a window
|
||||
starts when the actor appeared rather than when recognition first
|
||||
succeeded, and interior gaps are absorbed by the track surviving them.
|
||||
This function still bridges gaps between isolated accepted frames, which is
|
||||
what anneal_sec did before AR-012/AR-013 withdrew it.
|
||||
|
||||
So a replayed window and a pipeline window are answers to different
|
||||
questions, and a sweep tuned against this one is not tuning the shipped
|
||||
behaviour. That is VR-011's job -- "rewrite the replay harness for the
|
||||
post-AR-012 output contract" -- and it is a rewrite, not an edit, because
|
||||
the registry's claims do not cross the Python seam at all today.
|
||||
|
||||
`anneal_sec` is therefore replay-local now: it configures THIS function and
|
||||
is no longer forwarded to the C++ Config, which has no such field.
|
||||
"""
|
||||
anneal = float(cfg.get("anneal_sec", 10.0))
|
||||
info = {} # actor_idx -> identity fields
|
||||
@@ -261,8 +277,12 @@ def build_minimal(annotations, movie, fps, cfg) -> dict:
|
||||
# a stale entry here silently inert rather than loudly wrong.
|
||||
CFG_KEYS = ["detector_conf", "prob_threshold", "match_prior",
|
||||
"track_alpha", "track_min_iou", "track_assoc_min_prob",
|
||||
"track_extinction_sec",
|
||||
"extinction_sec", "anneal_sec"]
|
||||
"track_extinction_sec"]
|
||||
|
||||
# Swept like a Config key but consumed entirely in Python, by build_minimal.
|
||||
# Kept separate so nobody has to guess which of these the pipeline actually
|
||||
# reads: everything in CFG_KEYS crosses the seam, and nothing here does.
|
||||
REPLAY_LOCAL_KEYS = ["anneal_sec"]
|
||||
|
||||
|
||||
def main():
|
||||
@@ -273,7 +293,7 @@ def main():
|
||||
p.add_argument("--out", required=True, help="output presence JSON")
|
||||
p.add_argument("--raw-out", help="also write raw per-frame annotations (JSONL, with bboxes) here")
|
||||
p.add_argument("--build-dir", default=str(REPO / "build"))
|
||||
for k in CFG_KEYS:
|
||||
for k in CFG_KEYS + REPLAY_LOCAL_KEYS:
|
||||
p.add_argument(f"--{k.replace('_','-')}", type=float, default=None)
|
||||
# per-film gallery expansion: promotes pose-varied views of confidently-identified
|
||||
# actors into an in-memory annex, recovering ~+4 recall at no precision cost.
|
||||
@@ -285,7 +305,10 @@ def main():
|
||||
p.add_argument("--require-gallery-stamp", action="store_true")
|
||||
args = p.parse_args()
|
||||
|
||||
cfg = {k: getattr(args, k) for k in CFG_KEYS if getattr(args, k) is not None}
|
||||
# Both lists go into one dict: config_from_dict reads C++ keys with a
|
||||
# contains() check and ignores the rest, and build_minimal reads its own.
|
||||
cfg = {k: getattr(args, k)
|
||||
for k in CFG_KEYS + REPLAY_LOCAL_KEYS if getattr(args, k) is not None}
|
||||
if args.expand_gallery:
|
||||
cfg["expand_gallery"] = True
|
||||
if args.require_gallery_stamp:
|
||||
|
||||
Reference in New Issue
Block a user