perf(movienet): vectorise eval matching; count frames missing from Image.zip

movienet_eval: replace the per-element dot() with numpy — actor references are
loaded once as an ndarray and scored with a single matmul, keeping a
whole-library gallery fast.

movienet_prep: count and report frames referenced by annotations but absent
from Image.zip instead of skipping them silently.
This commit is contained in:
2026-07-04 20:41:54 +02:00
parent 1f5acc25df
commit 65fee74585
2 changed files with 24 additions and 16 deletions
+9 -5
View File
@@ -133,20 +133,24 @@ def main():
image_zip = movienet_root / "Image.zip"
frame_cache: dict[str, np.ndarray] = {}
n_missing_in_zip = 0
print(f"[prep] extracting {len(needed_paths)} frames from Image.zip…", file=sys.stderr)
with zipfile.ZipFile(image_zip) as zf:
for img_path in needed_paths:
zip_entry = f"Image/{img_path}"
try:
data = zf.read(zip_entry)
arr = np.frombuffer(data, dtype=np.uint8)
img = cv2.imdecode(arr, cv2.IMREAD_COLOR)
if img is not None:
frame_cache[img_path] = img
except KeyError:
pass # file missing from zip, skip silently
n_missing_in_zip += 1 # frame referenced by an annotation but absent from Image.zip
continue
arr = np.frombuffer(data, dtype=np.uint8)
img = cv2.imdecode(arr, cv2.IMREAD_COLOR)
if img is not None:
frame_cache[img_path] = img
print(f"[prep] frames loaded: {len(frame_cache)}/{len(needed_paths)}", file=sys.stderr)
if n_missing_in_zip:
print(f"[prep] frames absent from Image.zip: {n_missing_in_zip}", file=sys.stderr)
per_actor_count: dict[str, int] = {}
gt_entries = []