fix(metrics): align detection files by page number
AF
12h ago+86+86+01234567890123456789-2-2-0123456789
Summary
ObjectDetectionEvalProcessor.from_json_files validates prediction and ground-truth pages in page-number order, but then constructs tensors and image dimensions using their original JSON order. Two valid files containing the same pages in different orders therefore compare boxes from different pages and report incorrect detection metrics.
Sort both freshly loaded page lists once before validation and reuse that ordering for tensor conversion and image dimensions. Input files are unchanged.
Validation
- Added 11 native JSON-to-metrics regression cases. On the unchanged base, 6 fail and 5 pass; all 11 pass with this fix.
- Covers independent prediction/target permutations across three pages with distinct sizes and boxes, single-page behavior, page-number mismatch validation, and unchanged input-file contents.
- Pinned Ruff 0.15.10 check and format checks and
git diff --checkpass. - The full optional-dependency test suite was not run.
Checklist
- Added regression tests for the behavior change.
- Kept this change limited to detection page alignment.
- Apply the
buglabel.