Spaces:
Running on Zero
Running on Zero
Download tests/test_import_colmap.py from junaid-simamdigital/Simam3D-GPU: direct link, hf CLI and curl.
- Browser
- Download file 2.01 kB
-
https://huggingface.co/spaces/junaid-simamdigital/Simam3D-GPU/resolve/main/tests/test_import_colmap.py
- Command line
-
hf download hf://spaces/junaid-simamdigital/Simam3D-GPU/tests/test_import_colmap.py
-
curl -L -o test_import_colmap.py https://huggingface.co/spaces/junaid-simamdigital/Simam3D-GPU/resolve/main/tests/test_import_colmap.py
2.01 kB
| import json | |
| from unittest.mock import patch | |
| from import_colmap import import_colmap | |
| from validate_capture_manifest import validate_capture_manifest | |
| def test_import_colmap_builds_valid_world_to_camera_manifest(tmp_path): | |
| (tmp_path / "images").mkdir(exist_ok=True) | |
| (tmp_path / "images" / "one.png").write_bytes(b"one") | |
| (tmp_path / "images" / "two.png").write_bytes(b"two") | |
| cameras = tmp_path / "cameras.txt" | |
| cameras.write_text("# Camera list\n1 PINHOLE 640 480 500 500 320 240\n", encoding="utf-8") | |
| images = tmp_path / "images.txt" | |
| images.write_text("\n".join([ | |
| "# Images", "1 1 0 0 0 0 0 0 1 images/one.png", "", "2 1 0 0 0 -1 0 0 1 images/two.png", "", | |
| ]), encoding="utf-8") | |
| manifest_path = tmp_path / "capture.json" | |
| manifest = import_colmap(cameras, images, tmp_path, {"2"}) | |
| manifest_path.write_text(json.dumps(manifest), encoding="utf-8") | |
| valid, errors = validate_capture_manifest(manifest_path, check_files=True) | |
| assert valid is True, errors | |
| assert manifest["views"][1]["split"] == "held_out" | |
| assert len(manifest["views"][0]["sha256"]) == 64 | |
| def test_import_colmap_rejects_unknown_camera_model(tmp_path): | |
| cameras = tmp_path / "cameras.txt" | |
| cameras.write_text("1 UNKNOWN 10 10 1 2 3\n", encoding="utf-8") | |
| images = tmp_path / "images.txt" | |
| images.write_text("1 1 0 0 0 0 0 0 1 image.png\n", encoding="utf-8") | |
| try: | |
| import_colmap(cameras, images, tmp_path) | |
| except ValueError as exc: | |
| assert "unsupported COLMAP camera model" in str(exc) | |
| else: | |
| raise AssertionError("unknown camera model should fail") | |
| def test_import_colmap_cli_requires_held_out_split(): | |
| from import_colmap import main | |
| with patch("import_colmap.Path.is_file", return_value=False): | |
| try: | |
| main(["cameras.txt", "images.txt", ".", "capture.json"]) | |
| except SystemExit as exc: | |
| assert exc.code == 2 | |
| else: | |
| raise AssertionError("CLI should require held-out views") | |