feat(degradations): model capture conditions, moving boxes with the pixels - #7
Merged
Merged
Conversation
…ixels A degradation takes the annotation as well as the image and returns both. This is the whole point: a rotation that moves ink but leaves boxes behind produces a dataset that looks fine and teaches a detector to be systematically wrong, and the failure is invisible until training underperforms for no obvious reason. - base.py: Degradation protocol, DegradationPipeline with per-degradation probabilities and a record of exactly what fired, and map_page(), which rebuilds an annotation through an arbitrary point mapping. - geometric.py: Rotation and PerspectiveWarp, each deriving an explicit forward homography and mapping every box, word and table cell through it. Rotated words gain polygons, since an axis-aligned box no longer describes them tightly. - photometric.py: sixteen degradations chosen for physical cause rather than visual effect - ink spread/erosion, bleed-through from the reverse of a thin sheet, downscaling (the failure mode that kills Arabic diacritics and that blur does not reproduce), JPEG artefacts, shadow, vignette, glare, stains and folds. - presets.py: clean/scan/photo/fax/archive, ordered along the physical capture chain, so a corpus is composed by capture condition rather than by an undifferentiated cloud of noise. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
6 of 9 in the v1.0.0 series. Base:
feat/document-engine.The design point
A degradation takes the annotation as well as the image, and returns both.
A rotation that moves ink 8° but leaves the boxes where they were produces a dataset that looks fine and teaches a detector to be systematically wrong. That failure is invisible until training underperforms for no obvious reason.
What
base.py—Degradationprotocol,DegradationPipelinewith per-degradation probabilities and a record of exactly what fired, andmap_page(), which rebuilds a whole annotation through an arbitrary point mapping.geometric.py—RotationandPerspectiveWarp, each deriving an explicit forward homography and pushing every box, word and table cell through it. Rotated words gain polygons, since an axis-aligned box no longer describes them tightly.photometric.py— sixteen degradations chosen for physical cause rather than visual effect: ink spread/erosion, bleed-through from the reverse of a thin sheet, downscaling (the failure mode that destroys Arabic diacritics and that blur does not reproduce), JPEG artefacts, shadow, vignette, glare, stains, folds.presets.py—clean/scan/photo/fax/archive, ordered along the physical capture chain (optics → shading → sampling → compression), so a corpus is composed by capture condition rather than by an undifferentiated cloud of noise.Verified
365 tests green (79 new). The central test measures the actual ink box in the degraded image and requires the annotation to track it at IoU > 0.8, rather than merely checking that something changed.