Datasets:
Download code/utils/dataset.py from govtech/municipalbench-full: direct link, hf CLI and curl.
- Browser
- Download file 809 Bytes
-
https://huggingface.co/datasets/govtech/municipalbench-full/resolve/main/code/utils/dataset.py
- Command line
-
hf download hf://datasets/govtech/municipalbench-full/code/utils/dataset.py
-
curl -L -o dataset.py https://huggingface.co/datasets/govtech/municipalbench-full/resolve/main/code/utils/dataset.py
809 Bytes
| """Manifest-based raster resolution shared by inference, EDA and handoffs.""" | |
| from pathlib import Path | |
| IMAGE_SUFFIXES = {".jpg", ".jpeg", ".png", ".webp", ".bmp", ".tif", ".tiff"} | |
| def resolve_local_images(manifest: list[dict], image_dir: Path) -> dict[str, Path]: | |
| resolved = {} | |
| seen = set() | |
| for row in manifest: | |
| image_id = row["image_id"] | |
| if image_id in seen: | |
| raise ValueError(f"duplicate manifest image_id: {image_id}") | |
| seen.add(image_id) | |
| source = row.get("gcs_path") | |
| if not isinstance(source, str): | |
| continue | |
| filename = Path(source).name | |
| candidate = image_dir / filename | |
| if candidate.suffix.lower() in IMAGE_SUFFIXES and candidate.is_file(): | |
| resolved[image_id] = candidate | |
| return resolved | |