| from __future__ import annotations
|
|
|
| import argparse
|
| import json
|
| from pathlib import Path
|
|
|
| SEMANTIC_ROOT_ID = "n00000"
|
| INSTANCE_ROOT_ID = "n00000#1"
|
|
|
|
|
| def iter_jsonl(path: Path):
|
| with path.open("r", encoding="utf-8") as handle:
|
| for line in handle:
|
| if line.strip():
|
| yield json.loads(line)
|
|
|
|
|
| def count_jsonl(path: Path) -> int:
|
| return sum(1 for _ in iter_jsonl(path))
|
|
|
|
|
| def main() -> None:
|
| parser = argparse.ArgumentParser(description="Verify COCOTree release.")
|
| parser.add_argument("--release-root", type=Path, default=Path("."))
|
| args = parser.parse_args()
|
| root = args.release_root.resolve()
|
| required = [
|
| "annotations/semantic_nodes.jsonl",
|
| "annotations/instance_nodes.jsonl",
|
| "annotations/semantic_edges.jsonl",
|
| "annotations/instance_edges.jsonl",
|
| "annotations/image_dual_tree_summary.jsonl",
|
| "metadata/dataset_stats.json",
|
| "samples/dual_tree_viewer.html",
|
| ]
|
| missing = [rel for rel in required if not (root / rel).is_file()]
|
| if missing:
|
| raise SystemExit(f"missing files: {missing}")
|
| stats = json.loads((root / "metadata" / "dataset_stats.json").read_text(encoding="utf-8"))
|
| checks = {
|
| "semantic_node_count": count_jsonl(root / "annotations" / "semantic_nodes.jsonl"),
|
| "instance_node_count": count_jsonl(root / "annotations" / "instance_nodes.jsonl"),
|
| "semantic_edge_count_including_root": count_jsonl(root / "annotations" / "semantic_edges.jsonl"),
|
| "instance_edge_count_including_root": count_jsonl(root / "annotations" / "instance_edges.jsonl"),
|
| "image_count": count_jsonl(root / "annotations" / "image_dual_tree_summary.jsonl"),
|
| }
|
| for key, got in checks.items():
|
| if got != int(stats[key]):
|
| raise SystemExit(f"{key} mismatch: {got} != {stats[key]}")
|
| print("COCOTree release OK")
|
|
|
|
|
| if __name__ == "__main__":
|
| main()
|
|
|