Add causal oracle person information screen
This commit is contained in:
+21
-3
@@ -14,6 +14,7 @@ from typing import Any
|
||||
import torch
|
||||
|
||||
LOCAL_FORMAT = "qwen-local-pooled-v1"
|
||||
ORACLE_FORMAT = "easycom-oracle-person-history-v1"
|
||||
MODALITIES = {"visual": ("visual",), "audio": ("audio",), "av": ("visual", "audio")}
|
||||
|
||||
|
||||
@@ -277,12 +278,14 @@ def _load_validated_payload(
|
||||
dataset: str,
|
||||
modalities: str,
|
||||
expected_contract: dict[str, Any] | None,
|
||||
oracle_analysis: bool = False,
|
||||
) -> tuple[torch.Tensor, torch.Tensor, dict[str, Any], dict[str, Any], dict[str, Any]]:
|
||||
if modalities not in MODALITIES:
|
||||
raise ValueError(f"Unknown local modalities: {modalities}")
|
||||
times, indices = reference_alignment(reference)
|
||||
payload = torch.load(path, map_location="cpu", weights_only=False)
|
||||
if not isinstance(payload, dict) or payload.get("format") != LOCAL_FORMAT:
|
||||
expected_format = ORACLE_FORMAT if oracle_analysis else LOCAL_FORMAT
|
||||
if not isinstance(payload, dict) or payload.get("format") != expected_format:
|
||||
raise ValueError(f"Invalid local feature format: {path}")
|
||||
if payload.get("sample_id") != sample_id or payload.get("dataset") != dataset:
|
||||
raise ValueError(f"Local sample/dataset mismatch: {path}")
|
||||
@@ -295,9 +298,22 @@ def _load_validated_payload(
|
||||
if local_times.shape != times.shape or not torch.allclose(local_times, times, atol=1e-7, rtol=0):
|
||||
raise ValueError(f"Local times mismatch: {path}")
|
||||
config = payload.get("config", {})
|
||||
if config.get("causal_policy") != "half-open-trailing-window" or config.get("uses_speech_labels") is not False:
|
||||
if oracle_analysis:
|
||||
if (
|
||||
dataset != "easycom"
|
||||
or config.get("causal_policy") != "fully-observed-half-open-5hz-bins"
|
||||
or config.get("uses_speech_labels") is not True
|
||||
or config.get("oracle_analysis") is not True
|
||||
):
|
||||
raise ValueError(
|
||||
f"Oracle features lack the explicit causal/oracle contract: {path}"
|
||||
)
|
||||
elif (
|
||||
config.get("causal_policy") != "half-open-trailing-window"
|
||||
or config.get("uses_speech_labels") is not False
|
||||
):
|
||||
raise ValueError(f"Local features lack the causal/no-speech-label contract: {path}")
|
||||
contract = {"format": LOCAL_FORMAT, "modalities": modalities, "config": config}
|
||||
contract = {"format": expected_format, "modalities": modalities, "config": config}
|
||||
if expected_contract is not None and contract != expected_contract:
|
||||
raise ValueError(f"Local encoder/pooling contract differs across sessions/checkpoint: {path}")
|
||||
return times, indices, payload, config, contract
|
||||
@@ -348,6 +364,7 @@ def load_frame_set_features(
|
||||
dataset: str,
|
||||
expected_contract: dict[str, Any] | None = None,
|
||||
track_max_gap_seconds: float | None = None,
|
||||
oracle_analysis: bool = False,
|
||||
) -> tuple[torch.Tensor, FramePersonFeatures, dict[str, Any]]:
|
||||
"""Load direct audio and the latest causal per-frame person set per 5 Hz row."""
|
||||
|
||||
@@ -358,6 +375,7 @@ def load_frame_set_features(
|
||||
dataset=dataset,
|
||||
modalities="av",
|
||||
expected_contract=expected_contract,
|
||||
oracle_analysis=oracle_analysis,
|
||||
)
|
||||
audio = payload.get("audio")
|
||||
audio_valid = payload.get("audio_valid")
|
||||
|
||||
Reference in New Issue
Block a user