Skip to content

Fix NaN-confidence panic in non-maximum suppression - #3775

Open
Rachit2323 wants to merge 3 commits into
huggingface:mainfrom
Rachit2323:fix-nms-nan-panic
Open

Rachit2323 wants to merge 3 commits into
huggingface:mainfrom
Rachit2323:fix-nms-nan-panic

Conversation

@Rachit2323

Copy link
Copy Markdown

Problem

NMS sorts boxes by confidence using partial_cmp(..).unwrap(). This crashes
(panics) if any box has a NaN confidence.

Fix

Use f32::total_cmp instead — it handles NaN safely and never panics.
(The same file already uses total_cmp at model.rs:752.)

Changes

  • object_detection.rs — fixed both NMS functions
  • yolo/model.rs — fixed the same bug in the yolo example
  • nms_tests.rs — added tests for NaN confidence

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant