Fix Ego4D target compatibility in local baselines

This commit is contained in:
Xin Wang
2026-08-28 15:03:31 +08:00
parent 4abbde4f52
commit 0f6a72cfdf
5 changed files with 134 additions and 16 deletions
+31
View File
@@ -181,6 +181,30 @@ class Ego4DLocalWorkflowTests(unittest.TestCase):
if name != "baseline_seed0":
self.assertEqual(train[train.index("--local-modalities") + 1], name.split("_")[0])
def test_ego4d_noncanonical_binary_rows_are_preserved(self):
target_path = self.root / "targets" / f"{self.names[0]}.npy"
targets = np.load(target_path)
targets[3] = 0
targets[4] = [1, 1, 0]
np.save(target_path, targets)
data = load_session_data(
self.root / "features",
self.root / "targets",
self.names[0],
dataset="ego4d",
expected_mode="open-stream-replay",
)
self.assertTrue(torch.equal(data.targets[3], torch.zeros(3)))
self.assertTrue(
torch.equal(data.targets[4], torch.tensor([1.0, 1.0, 0.0]))
)
self.assertEqual(data.feature_metadata["num_noncanonical_target_rows"], 2)
output = io.StringIO()
with contextlib.redirect_stdout(output):
runner.preflight(runner.parse_args(self.runner_args(["--variants", "baseline"])))
self.assertIn("constraint: 2/60 ([0,0,0]=1, [1,1,0]=1)", output.getvalue())
def test_family_preflight_catches_missing_test_sidecar_before_training(self):
(self.root / "local" / f"{self.names[1]}.pt").unlink()
with patch("run_ego4d_local_baselines.subprocess.run") as run:
@@ -219,6 +243,13 @@ class Ego4DLocalWorkflowTests(unittest.TestCase):
self.assertFalse((self.root / "checkpoints").exists())
def test_full_cpu_family_round_trip_and_summary(self):
# EgoSpeak's LSTR MCE consumes the released Ego4D rows as binary
# weights. Preserve noncanonical rows, and do not derive transitions
# when that auxiliary objective is disabled.
target_path = self.root / "targets" / f"{self.names[0]}.npy"
targets = np.load(target_path)
targets[3] = 0
np.save(target_path, targets)
self.split_feature_layout()
env = dict(os.environ, OMP_NUM_THREADS="1", MKL_NUM_THREADS="1", OPENBLAS_NUM_THREADS="1")
completed = subprocess.run([sys.executable, str(runner.REPO / "run_ego4d_local_baselines.py"),