feat: page-aware mAP scoring (thread page_aware through the pipeline)#158
Open
Divya-Bhargavi wants to merge 3 commits into
Open
feat: page-aware mAP scoring (thread page_aware through the pipeline)#158Divya-Bhargavi wants to merge 3 commits into
Divya-Bhargavi wants to merge 3 commits into
Conversation
* Page awareness in scoring * Evaluation configuratin, page_aware flag on the bboxIOUComparator. * Tests * Documentation
Builds on the page_aware BBoxIoUComparator: adds a page_aware flag to MAPCalculator and BBoxMAPAccumulator, and a bbox_page_aware flag to compare_with(add_bbox_metrics=True), so the end-to-end mAP path enforces page matching (a correct box on the wrong page scores as a miss). Default stays page-unaware for backward compatibility. - MAPCalculator/BBoxMAPAccumulator: page_aware param -> BBoxIoUComparator - compare_with / StructuredModel.compare_with: bbox_page_aware param - 11 tests across calculator, compare_with, and bulk accumulator paths - docs: page-aware mAP scoring section in bbox-map-metrics.md
Add TestPageAwareMultiPageAggregate to cover documents with several fields spread across pages. Existing page-aware tests are all single-field/single-box; these pin the aggregate mean_ap over a mix of correct- and wrong-page fields (0.5 mixed, 1.0 all-correct, 0.0 all-wrong) plus a page-unaware control that regresses if page-awareness stops being applied.
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.
Summary
Threads page-awareness through the mAP scoring pipeline, building on the
page_awareBBoxIoUComparatorfrom this base branch (sr/bbox-page-aware).That branch made the comparator page-aware, but the end-to-end mAP path still
constructed a plain
BBoxIoUComparator(), so a prediction with correctcoordinates on the wrong page would still score as a hit in
mean_ap. ThisPR closes that gap.
Changes
MAPCalculator(page_aware=...)— passes the flag to itsBBoxIoUComparator.BBoxMAPAccumulator(page_aware=...)— forwards toMAPCalculatorfor thebulk path.
compare_with(add_bbox_metrics=True, bbox_page_aware=...)(and theStructuredModelwrapper) — single-document path.Default stays
page_aware=False, so existing behavior is unchanged. Nodata-model change was needed: page-suffixed boxes
(
[[x1, y1], [x2, y2], page]/[x1, y1, x2, y2, page]) already flow from_bboxextras straight to the comparator.Behavior
With
page_aware=True, a field is a localization hit only when the page matchesand IoU ≥ threshold:
Page-unaware (default) ignores the page and scores the geometry only.
Usage
with page-suffixed rich values, e.g.
{"_value": "Acme", "_bbox": [[10, 20], [200, 50], 1]}.Testing
compare_with, and bulk accumulatorpaths (same-page hit, wrong-page miss, page-less miss, default-unaware).
ruff checkandruff format --checkclean on changed files.Stacked on
sr/bbox-page-aware; once that merges, this can retarget todev.By submitting this pull request, I confirm that you can use, modify, copy, and
redistribute this contribution, under the terms of your choice.