Release KITTI-C2L v1.0.0: documented self-contained benchmark, loader and baselines
db613b6 verified Download code/tests/test_make_correction_animation.py from mcocheteux/KITTI-C2L-Dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/datasets/mcocheteux/KITTI-C2L-Dataset/resolve/main/code/tests/test_make_correction_animation.py
- Command line
-
hf download hf://datasets/mcocheteux/KITTI-C2L-Dataset/code/tests/test_make_correction_animation.py
-
curl -L -o test_make_correction_animation.py https://huggingface.co/datasets/mcocheteux/KITTI-C2L-Dataset/resolve/main/code/tests/test_make_correction_animation.py
1.74 kB
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| import pytest | |
| pytest.importorskip("matplotlib") | |
| pytest.importorskip("scipy") | |
| sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts")) | |
| from make_correction_animation import make_animation # noqa: E402 | |
| from PIL import Image # noqa: E402 | |
| from kitti_c2l.assets import generate_sequence_assets | |
| from kitti_c2l.generate import generate_sequence_rows | |
| from kitti_c2l.sequence_mapping import SequenceInfo | |
| from kitti_c2l.stages import STAGES | |
| from kitti_c2l.writer import write_assets, write_split | |
| def demo_data(fake_kitti_root: Path, tmp_path: Path) -> tuple[Path, Path]: | |
| seq_info = SequenceInfo(sequence="04", date="2011_09_30", drive="0016", start=0, end=3, frame_count=4, split="train") | |
| metadata_path = tmp_path / "train.parquet" | |
| write_split(generate_sequence_rows(seq_info, fake_kitti_root, stages=STAGES), metadata_path) | |
| assets_path = tmp_path / "frames_train.parquet" | |
| write_assets(generate_sequence_assets(seq_info, fake_kitti_root), assets_path) | |
| return metadata_path, assets_path | |
| def test_make_animation_writes_a_multi_frame_gif(demo_data: tuple[Path, Path], tmp_path: Path): | |
| metadata_path, assets_path = demo_data | |
| output_path = make_animation( | |
| metadata_path, assets_path, sequence="04", frame=1, stage=1, | |
| output_path=tmp_path / "anim.gif", num_steps=4, hold_frames=1, fps=10, | |
| ) | |
| assert output_path.exists() | |
| with Image.open(output_path) as gif: | |
| # PIL's GIF encoder dedups identical consecutive hold-frames, so the | |
| # exact count isn't reliable -- just check it's a genuine animation. | |
| assert gif.n_frames >= 2 | |
| assert gif.is_animated | |