Conversation
- COCO derives Clone (additive, private fields unchanged) - PyCOCOeval::new copies coco_gt/coco_dt.inner directly instead of cloning the dataset and rebuilding the index via from_dataset - safe because every PyCOCO write path (dataset setter, derived*, without_image_dir) rebuilds the whole COCO, so inner's index is never stale - side effect: duplicate-id/unnamed-category warnings no longer reprint to stderr on every COCOeval() construction, since the clone carries the already-collected warnings instead of regenerating them - measured on a 1.5M-annotation RF-DETR-shaped workload: ctor -74%, end-to-end -11%; RSS unchanged (still a full copy) - 10/10 bit-identical vs main across ten configs - new test_clone_is_a_faithful_reindex fails on 2 injected defects (a hand-written Clone dropping img_cat_to_anns or warnings) --- Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
COCOeval ctor
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 optimizes the construction of the
COCOevalevaluator by having it clone an already-indexedCOCOobject instead of rebuilding the index from the dataset each time. This change significantly improves performance for large datasets, ensures warnings are not redundantly reprinted, and maintains correctness by verifying that the clone is a faithful, independent copy. The most important changes are as follows:Performance and Correctness Improvements
COCOevalconstructor now clones the fully-indexedCOCOobjects for both ground-truth and detection inputs, rather than rebuilding the index from the raw dataset. This results in a 74% faster constructor and an 11% faster end-to-end evaluation on large workloads, with no increase in memory usage. Warnings from index creation are no longer redundantly reprinted. [1] [2]Codebase Enhancements
COCOstruct inhotcoconow derivesClone, enabling efficient deep copies of the entire object, including its index maps and warnings.Testing and Validation
test_clone_is_a_faithful_reindex, to ensure that cloning aCOCOobject produces an exact and independent copy of all index maps and warnings, and that further mutations to the clone do not affect the original.Documentation
COCOevaland its impact on performance, memory usage, and warning handling.