Repository navigation
Count integer segmentation labels directly in mean IoU - #900
Open
snygginghani wants to merge 1 commit into
Open
snygginghani wants to merge 1 commit into
snygginghani wants to merge 1 commit into
Conversation
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
Mean IoU builds three general-purpose histograms of integer class IDs for each image. Count valid IDs directly with
numpy.bincountand remove duplicate copies of the reference mask. The integer path preserves class bounds and the existing treatment of ignored positions. Non-integer labels use the existing histogram path.Benchmark and validation
I used the two ADE20K fixture masks (512×683 and 364×500), repeated 16 times each. For reproducible predictions, I reduced label IDs by one and shifted each prediction by its one-based index along alternating axes. This exercises the normal 150-class ADE20K label reduction path on 8.5 million pixels.
.compute()with encoding and decodingThese are alternating-run medians on Windows 11, Intel Core i5-12400F and NumPy 2.4.6. Every result matched exactly. Benchmarked with
num_labels=150,ignore_index=255,reduce_labels=True, andnan_to_num=0.python -m pytest tests/test_mean_iou_histogram.py -qpassed both cases, covering ignored pixels, out-of-range labels and the single-class boundary. Black, isort, flake8 andgit diff --checkpassed. This change is limited to histogram work. Label remapping is covered separately by #810.AI assistance was used to investigate and prepare the patch, tests and benchmark.