fix: honor official RELLIS train sequence split

This commit is contained in:
DCCONSTRUCTIONS 2026-07-25 21:20:13 +03:00
parent 41e347d20a
commit 15821a1c98
2 changed files with 48 additions and 2 deletions

View File

@ -437,8 +437,14 @@ def _stratified_pairs(
groups: dict[str, list[tuple[str, str]]] = {} groups: dict[str, list[tuple[str, str]]] = {}
for pair in pairs: for pair in pairs:
groups.setdefault(pair[0].split("/", 1)[0], []).append(pair) groups.setdefault(pair[0].split("/", 1)[0], []).append(pair)
if sorted(groups) != ["00000", "00001", "00002", "00003", "00004"]: if (
raise RellisAdmissionError("RELLIS train split does not cover every sequence") 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]] = [] selected: list[tuple[str, str]] = []
remaining = frame_count remaining = frame_count
sequence_ids = sorted(groups) sequence_ids = sorted(groups)

View File

@ -57,6 +57,46 @@ def test_rellis_height_calibration_uses_only_stratified_train_frames(
assert len(result["identity_sha256"]) == 64 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: def test_rellis_archive_index_rejects_path_traversal(tmp_path: Path) -> None:
archive = tmp_path / "unsafe.zip" archive = tmp_path / "unsafe.zip"
with zipfile.ZipFile(archive, "w") as target: with zipfile.ZipFile(archive, "w") as target: