Buckets:
| """Build a deterministic, non-eligible KFGOD source-label review queue.""" | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| CANONICAL = { | |
| "bridge": "bridge", | |
| "small_vehicle": "vehicle", | |
| "truck": "large_vehicle", | |
| "bus": "large_vehicle", | |
| "fighter_aircraft": "aircraft", | |
| "large_civilian_aircraft": "aircraft", | |
| "large_military_aircraft": "aircraft", | |
| "small_civilian_aircraft": "aircraft", | |
| "helicopter": "aircraft", | |
| "motorboat": "vessel", "sailboat": "vessel", "tugboat": "vessel", | |
| "barge": "vessel", "fishing_boat": "vessel", "ferry": "vessel", | |
| "container_ship": "vessel", "oil_tanker": "vessel", "drill_ship": "vessel", | |
| "warship": "vessel", | |
| "storage_tank": "storage_tank", | |
| } | |
| QUOTA = {"small_vehicle": 8, "truck": 6, "bus": 6, "storage_tank": 8} | |
| for source_label in ("fighter_aircraft", "large_civilian_aircraft", "large_military_aircraft", "small_civilian_aircraft", "helicopter"): | |
| QUOTA[source_label] = 6 | |
| for source_label in ("motorboat", "sailboat", "tugboat", "barge", "fishing_boat", "ferry", "container_ship", "oil_tanker", "drill_ship", "warship"): | |
| QUOTA[source_label] = 6 | |
| def sha256(path: Path) -> str: | |
| return hashlib.sha256(path.read_bytes()).hexdigest() | |
| def ranked(records: list[dict], source_label: str) -> list[dict]: | |
| return sorted(records, key=lambda value: hashlib.sha256( | |
| f"kfgod-phase1-review-v1:{source_label}:{value['scene_id']}:{value['object_index']}".encode() | |
| ).hexdigest()) | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--manifest", type=Path, required=True) | |
| parser.add_argument("--output", type=Path, required=True) | |
| args = parser.parse_args() | |
| manifest = json.loads(args.manifest.read_text()) | |
| if manifest.get("status") != "provisional_external_source": | |
| raise ValueError("KFGOD must remain provisional") | |
| candidates: dict[str, list[dict]] = {} | |
| for record in manifest["records"]: | |
| if record["source_annotation_status"] != "PRESENT": | |
| continue | |
| label = args.manifest.parent / "labels" / f"{record['id']}.txt" | |
| for index, line in enumerate(label.read_text().splitlines()): | |
| fields = line.split() | |
| source_label = fields[8] | |
| if source_label not in CANONICAL: | |
| continue | |
| candidates.setdefault(source_label, []).append({ | |
| "scene_id": record["id"], | |
| "group": record["group"], | |
| "image": record["image"], | |
| "image_sha256": record["image_sha256"], | |
| "source_annotation": str(label), | |
| "source_annotation_sha256": record["source_annotation_sha256"], | |
| "object_index": index, | |
| "source_label": source_label, | |
| "canonical_class": CANONICAL[source_label], | |
| "vertices": [[float(fields[i]), float(fields[i + 1])] for i in range(0, 8, 2)], | |
| "difficulty": fields[9], | |
| "primary_source_annotation": "KFGOD published DOTA-OBB label", | |
| "project_review_status": "PENDING_INDEPENDENT_VISUAL_REVIEW", | |
| "training_eligible": False, | |
| "final_test_eligible": False, | |
| }) | |
| queue = [] | |
| for source_label, records in sorted(candidates.items()): | |
| selected = records if source_label == "bridge" else ranked(records, source_label)[:QUOTA[source_label]] | |
| queue.extend(selected) | |
| queue.sort(key=lambda value: (value["canonical_class"], value["source_label"], value["scene_id"], value["object_index"])) | |
| payload = { | |
| "schema_version": "1.0.0", | |
| "purpose": "Independent visual source-label audit only; this queue cannot grant eligibility or role assignment.", | |
| "manifest": str(args.manifest), | |
| "manifest_sha256": sha256(args.manifest), | |
| "selection": "All published bridge instances; deterministic per-source-label samples for each other mapped class.", | |
| "selection_quotas": QUOTA, | |
| "records": queue, | |
| } | |
| if args.output.exists(): | |
| raise FileExistsError(args.output) | |
| args.output.parent.mkdir(parents=True, exist_ok=True) | |
| args.output.write_text(json.dumps(payload, indent=2) + "\n") | |
| print(json.dumps({"records": len(queue), "all_bridge_records": len(candidates["bridge"])})) | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 4.42 kB
- Xet hash:
- c6b73395fce80ebccb5acd34396fb8fec8c7e831e05f4f52793a9e5e03802a4e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.