fix(nn): correct center-coordinate IoU in Sophon YOLO NMS - #159
Open
nquyencubas523-cloud wants to merge 1 commit into
Open
fix(nn): correct center-coordinate IoU in Sophon YOLO NMS#159nquyencubas523-cloud wants to merge 1 commit into
nquyencubas523-cloud wants to merge 1 commit into
Conversation
Preserve center-format output while correcting per-box corner calculation. Add CPU regressions for duplicate and neighboring boxes, score order, output coordinates and threshold boundaries. Fixes #158 Signed-off-by: Nquyen Cubas <nquyencubas523@gmail.com>
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
Fix Sophon YOLO NPU postprocessing so NMS compares overlap using each box's center coordinates. Unequal full-body and partial-body detections can now suppress correctly at the configured threshold, while adjacent unequal boxes avoid an inflated overlap calculation.
Related issue
Closes #158.
Root cause
The NPU decoder emits center-format
x, y, width, height. NMS previously interpretedx, yas upper-left corners. The output parser subsequently converts centers to upper-left coordinates, so saved event coordinates were correct even though the earlier NMS calculation was wrong.The fix converts each center to its own edges only during IoU calculation. The surviving coordinates, score ordering, strict
IoU > thresholdcomparison, and output contract remain unchanged.Scope
In scope
Out of scope
Risk tags
Type of change
Area
Candidate identity
0dab89eea2e84835e0852dc10d2115e201237a03f535c487ca951e68ca9ab7f32ad754bfb5bdb23606eba0b56f1486b2e88547d47eae8641881666599e82f7bd05734e4d8fe6bc2e1f1b9ff97e51baee26f010c83b625c5eb3c7eef4d3ea266033589286be14c46a7a7bd7ca0bc87f7c5a5d2cf95fd7e09cc1aa33d2No source changes, amendments, or rebases occurred after validation.
Verification
Parent baseline
Existing BM1688 installation: normal authenticated picture-task inference reproduced one same-person double detection in a set of 59 identical input images, with NMS 0.35 and task confidence 0.8. This is a measured deployed-version baseline, not a full build/test of the parent commit. A separate full parent suite was not run.
Candidate checks
Initial build attempts failed on host tool availability/compatibility. Task-local tools resolved those failures; failed and successful attempts are retained in private evidence. No tracked third-party files or global host configuration were changed.
Risk-based evidence
--store-dirargument to the production provisioner and reportsunknown; direct provisionerstatusreturnedvalid, and protected CEM v2 loading and real inference succeeded.acda69e87a64d481427d9c2b185a8bbf116b2dcdaf12409a2208728655881860, matching the verified package. Existing protected model bytes and authorization certificates were preserved; direct provisioner status is valid and model initialization/inference succeeded. The temporary engine, picture task and algorithm were cleaned up.Documentation impact
Compatibility and deployment impact
Configuration and model formats are unchanged. Corrected overlap can change detection selection when box sizes differ. These samples do not establish universal recall in crowded or heavily occluded scenes.
Third-party code and assets
Security and release checklist
Signed-off-by:according to the DCO-style requirement inCONTRIBUTING.md.CONTRIBUTING.mdandCODE_OF_CONDUCT.md.Acceptance and cleanup
[nn][sophon][nms].Notes for reviewers
Regression cases cover unequal duplicate boxes, reversed confidence order, translated coordinates, adjacent unequal boxes, strict threshold boundaries, touching/separate boxes, and empty/single input. Saved integer boxes alone cannot prove the exact floating-point IoU used before NMS; acceptance above uses actual before/after inference.