Add deterministic COCO -> ontology-v2 two‑mask converter with CLI, policy, reports and tests - #57
Merged
InsightofSPb merged 3 commits intoAug 19, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This PR adds a production-oriented converter for transforming COCO polygon annotations into the repository’s existing
heritage_facades_v2_12concepts_two_headsdataset contract.The converter preserves the independent main-semantic and ornament representations, resolves main-class overlaps deterministically, validates facade-disjoint splits, and records sufficient provenance for downstream training and evaluation.
What changed
Added the
ovs_heritage.coco_converterCLI with three commands:audit— complete read-only dataset preflight;convert— validated and transactional dataset conversion;validate— standalone output-manifest and artifact validation.Added the versioned conversion policy
ovs_heritage/configs/coco_conversion_v1.json.Mapped all 11 source COCO categories to the canonical ontology-v2 classes by name.
Preserved the two-mask representation:
main_masks/*.pngcontains semantic IDs from{0,1,2,3,4,5,6,7,9,10,11,255};ornament_masks/*.pngindependently contains{0,1,255};8is excluded from the main mask and represented through the ornament mask.Implemented the agreed deterministic main-class priority:
MISSING_ELEMENTSPALLINGCRACKDELAMINATIONCORROSIONREPAIRSADVERTISEMENTSTEXT_OR_IMAGESEFFLORESCENCEWATER_STAINReplaced the custom rasterizer with canonical COCO polygon decoding using
pycocotools.mask.frPyObjects,merge, anddecode.Added strict validation for malformed, non-finite, degenerate, zero-area, empty, and unsupported geometry.
Documented and reported the out-of-bounds coordinate policy: polygons are clipped to the COCO image grid, while geometry that decodes to an empty mask is rejected.
Added deterministic Label Studio filename resolution with the following order:
Added missing, ambiguous, normalized-name collision, and portable-output collision checks.
Added shared preflight validation used by both audit and conversion:
Added transactional output publishing:
Strengthened conversion-policy and manifest validation:
Added structured outputs:
manifest.jsonl;overlap_report.json;geometry_report.json;filename_resolution_report.json;conversion_summary.json;Added
pycocotools==2.0.8to the CPU GitHub Actions workflow.Safety and provenance
uint8PNG files and read back for verification.Testing
GitHub Actions completed successfully on commit
2a50f8ad719f914ccdc5638ec6d76b3c90d38e6c.Executed checks:
Results:
96 passed;All checks passed.The test suite covers canonical and multipart polygon rasterization, malformed geometry, class priority, annotation-order invariance, ornament independence, filename normalization and ambiguity, transactional rollback, audit preflight, policy validation, manifest validation, artifact validation, and facade leakage.
Remaining dataset-level verification
This PR validates the converter with synthetic fixtures and the complete repository CPU test suite. A full conversion of the real 329-image export is intentionally left for a separate dataset smoke test because it requires the complete source-image directory and reviewed facade metadata table.