Conversation
- validate_results, geometry derive, and id assignment merged into a single loop over detections instead of five separate passes - image_id/category_id GT membership now probes self.imgs/self.cats (the index this COCO already built) instead of rebuilding a fresh HashSet of GT ids on every load_res_anns call - NaN score rejection, derive_from_bbox's rectangular polygon, the unconditional id reassignment, and once-per-kind mismatch warnings are all preserved in content, only fused into fewer passes - both the in-memory dict path and the numpy loadRes(ndarray) fast path share load_res_anns, so both benefit from one fix - measured on a 1.5M-annotation RF-DETR-shaped workload: loadRes -16% to -19% (non-overlapping ranges across two rep-count runs); end-to-end effect not distinguishable from run-to-run noise - 10/10 bit-identical vs main across ten configs - new tests load_res_anns_warns_once_per_mismatch_kind and load_res_anns_skips_category_check_when_gt_has_no_categories fail on 3 injected defects (dropped warn-once guard on each mismatch kind, dropped has_cats gate) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This branch has not been deployed
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.
This pull request significantly improves the performance and clarity of the
load_res_annsmethod in theCOCORust implementation by validating, deriving geometry, and assigning IDs in a single pass over the detections. It also introduces new regression tests to ensure correct warning behavior and removes unnecessary code. These changes lead to a measurable speedup for large workloads and maintain bit-identical evaluation results.Performance and Validation Improvements
load_res_annsfunction now validates, derives geometry, and assigns IDs in a single loop over the detection annotations, instead of five separate passes. It checks ground-truth (GT) membership using the existing index rather than rebuilding aHashSeteach time, resulting in a 16–19% speedup on large workloads. The method also ensures only one warning per mismatch kind (image/category), naming the first offender, and still immediately rejects NaN scores. [1] [2] [3]Codebase Simplification
validate_resultsmethod has been removed, with its logic fused into the main loop ofload_res_anns. This reduces code duplication and improves maintainability.Testing Enhancements
load_res_anns_warns_once_per_mismatch_kindensures that only one warning is issued per mismatch type and that the first offending annotation is reported.load_res_anns_skips_category_check_when_gt_has_no_categoriesensures that no category mismatch warnings are emitted if the GT set has no categories.Minor Cleanups
HashSet) have been removed fromcoco.rs.These changes collectively make the code faster, clearer, and better tested, especially for large-scale detection evaluation workloads.