Datasets:
File size: 1,993 Bytes
735d8c5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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()
|