From 15821a1c988f6b06301b2c2c1061d81814c4e5a9 Mon Sep 17 00:00:00 2001 From: DCCONSTRUCTIONS Date: Sat, 25 Jul 2026 21:20:13 +0300 Subject: [PATCH] fix: honor official RELLIS train sequence split --- src/k1link/datasets/rellis_qualification.py | 10 ++++-- tests/test_rellis_qualification.py | 40 +++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/k1link/datasets/rellis_qualification.py b/src/k1link/datasets/rellis_qualification.py index b7bffea..fd12473 100644 --- a/src/k1link/datasets/rellis_qualification.py +++ b/src/k1link/datasets/rellis_qualification.py @@ -437,8 +437,14 @@ def _stratified_pairs( groups: dict[str, list[tuple[str, str]]] = {} for pair in pairs: groups.setdefault(pair[0].split("/", 1)[0], []).append(pair) - if sorted(groups) != ["00000", "00001", "00002", "00003", "00004"]: - raise RellisAdmissionError("RELLIS train split does not cover every sequence") + if ( + len(groups) < 2 + or any( + sequence not in {"00000", "00001", "00002", "00003", "00004"} + for sequence in groups + ) + ): + raise RellisAdmissionError("RELLIS train split sequence coverage is incompatible") selected: list[tuple[str, str]] = [] remaining = frame_count sequence_ids = sorted(groups) diff --git a/tests/test_rellis_qualification.py b/tests/test_rellis_qualification.py index 5e51e0b..5baeca7 100644 --- a/tests/test_rellis_qualification.py +++ b/tests/test_rellis_qualification.py @@ -57,6 +57,46 @@ def test_rellis_height_calibration_uses_only_stratified_train_frames( assert len(result["identity_sha256"]) == 64 +def test_rellis_calibration_accepts_the_official_train_sequence_subset( + tmp_path: Path, +) -> None: + scan_path = tmp_path / "scans.zip" + label_path = tmp_path / "labels.zip" + pairs: list[tuple[str, str]] = [] + train_sequences = ("00000", "00002", "00003", "00004") + with ( + zipfile.ZipFile(scan_path, "w") as scans, + zipfile.ZipFile(label_path, "w") as labels, + ): + for sequence_id in train_sequences: + for frame_number in range(2): + point_member = ( + f"{sequence_id}/os1_cloud_node_kitti_bin/{frame_number:06d}.bin" + ) + label_member = ( + f"{sequence_id}/os1_cloud_node_semantickitti_label_id/" + f"{frame_number:06d}.label" + ) + point_bytes, label_bytes = _frame(1.3) + scans.writestr(f"Rellis-3D/{point_member}", point_bytes) + labels.writestr(f"Rellis-3D/{label_member}", label_bytes) + pairs.append((point_member, label_member)) + + result = calibrate_rellis_sensor_height( + scan_path, + label_path, + tuple(pairs), + archive_identity="b" * 64, + frame_count=8, + ) + + calibrated_sequences = { + item["frame_id"].split("-")[1] for item in result["frame_estimates"] + } + assert calibrated_sequences == set(train_sequences) + assert "00001" not in calibrated_sequences + + def test_rellis_archive_index_rejects_path_traversal(tmp_path: Path) -> None: archive = tmp_path / "unsafe.zip" with zipfile.ZipFile(archive, "w") as target: