occupancy: average mIoU over the classes present, not all 17 - #3
Open
egeboy35 wants to merge 1 commit into
Open
Conversation
egeboy35
force-pushed
the
fix/occupancy-miou-excludes-absent-classes
branch
from
September 1, 2026 12:28
b8cb879 to
a3bdf64
Compare
summarize() computes
iou = tp / max(tp + fp + fn, 1)
mIoU = mean(iou)
A class that appears in neither the ground truth nor the prediction has
union 0, so the clamp turns its undefined IoU into 0/1 = 0, and the mean
divides by the full class count anyway. The reported number is therefore
mIoU_reported = mIoU_official * n_present / NUM_SEMANTIC
Occ3D-nuScenes averages over the classes actually present (np.nanmean over
per_class_iu), so any comparison against a published number is scaled by
however many of the 17 classes the scene happened to contain.
Measured on this machine with a perfect prediction -- the prediction IS the
ground truth, so the only correct answer is 1.0:
classes present reported correct
3 / 17 0.1765 1.0
9 / 17 0.5294 1.0
17 / 17 1.0000 1.0
The identity above holds exactly in each row.
Absent classes are now excluded from the mean (they report nan in
per_class, so a reader can tell "the model missed it" from "it was never
there"), and summarize() returns classes_present / num_classes so a number
can be read without guessing which scene it came from. The verbose line
prints the same counts, and the "best classes" list drops nan before
sorting -- nan compares False against everything and would otherwise land
in arbitrary positions.
Nothing changes when every class is present: the existing self-test still
reports 1.000 and 0.000. A third case is added for a scene with few
classes; reverting the fix turns it from 1.000 to 0.235 and trips its
assert.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
egeboy35
force-pushed
the
fix/occupancy-miou-excludes-absent-classes
branch
from
September 1, 2026 12:43
a3bdf64 to
9d21af4
Compare
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.
OccupancyEvaluator.summarize()computesA class that appears in neither the ground truth nor the prediction has union 0. The clamp turns its undefined IoU into
0/1 = 0, and the mean then divides by the full class count anyway — so the reported number isOcc3D-nuScenes averages over the classes actually present (
np.nanmeanoverper_class_iu), so any comparison against a published number is scaled by however many of the 17 classes the scene happened to contain.Measured
A perfect prediction — the prediction is the ground truth, so the only correct answer is 1.0:
The identity above holds exactly in each row.
This matters most where the suite is weakest: a scene containing only a few classes, or a baseline that only ever predicts a subset.
run_eval.pyprints the depth→occupancy baseline's mIoU directly above a table of published SOTA numbers, and those are not on the same scale.The change
Absent classes are excluded from the mean. They report
naninper_class, so a reader can tell "the model missed it" from "it was never there", andsummarize()now returnsclasses_present/num_classesso a number can be read without guessing which scene produced it. The verbose line prints the same counts.The "best classes" list drops
nanbefore sorting —nancomparesFalseagainst everything and would otherwise land in arbitrary positions.Verification
Nothing changes when every class is present: the existing self-test still reports
1.000and0.000. A third case is added for a scene with few classes; reverting the fix turns it from1.000to0.235and trips its assert.🤖 Generated with Claude Code