-
Notifications
You must be signed in to change notification settings - Fork 714
Sanitize non-finite matcher costs before Hungarian assignment #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+416
−13
Merged
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
731fef5
Initial plan
Copilot c03f83b
fix: sanitize non-finite matcher costs
Copilot dcb0609
test: document matcher replacement logic
Copilot c9dede7
Merge pull request #757 from roboflow/migration
Borda fa4b623
chore(pre-commit): ⬆ pre_commit autoupdate (#792)
pre-commit-ci[bot] ea65053
Merge branch 'develop' into copilot/fix-valueerror-matrix-entries
Borda 60aa02c
fix(matcher): warn on non-finite costs and expand test coverage
Borda 11ab8cd
fix(pre-commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 89c4b52
Update src/rfdetr/models/matcher.py
Borda 71d8015
Merge branch 'develop' into copilot/fix-valueerror-matrix-entries
Borda 1c2ef2d
fix(pre-commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 838c05f
fix: handle non-finite values in HungarianMatcher cost matrix and add…
Borda 6edc838
Potential fix for pull request finding
Borda 411834b
fix: warn once per matcher instance
Copilot 0bac0dc
refactor: extract matcher cost sanitization helper
Copilot c0e71f9
refactor: isolate matcher cost sanitization
Copilot 048adf1
docs: add matcher sanitization doctest
Copilot 05148d1
Merge branch 'develop' into copilot/fix-valueerror-matrix-entries
Borda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # ------------------------------------------------------------------------ | ||
| # RF-DETR | ||
| # Copyright (c) 2025 Roboflow. All Rights Reserved. | ||
| # Licensed under the Apache License, Version 2.0 [see LICENSE for details] | ||
| # ------------------------------------------------------------------------ | ||
|
|
||
| import pytest | ||
| import torch | ||
|
|
||
| from rfdetr.models.matcher import HungarianMatcher | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "invalid_value", | ||
| [ | ||
| pytest.param(float("nan"), id="nan"), | ||
| pytest.param(float("inf"), id="inf"), | ||
| ], | ||
| ) | ||
| def test_matcher_replaces_non_finite_costs_before_assignment(invalid_value: float) -> None: | ||
| """Matcher should sanitize non-finite costs so assignment still succeeds.""" | ||
| matcher = HungarianMatcher() | ||
| outputs = { | ||
| "pred_logits": torch.tensor([[[0.0], [10.0]]], dtype=torch.float32), | ||
| "pred_boxes": torch.tensor( | ||
| [ | ||
| [ | ||
| [invalid_value, 0.5, 0.2, 0.2], | ||
| [0.5, 0.5, 0.2, 0.2], | ||
| ] | ||
| ], | ||
| dtype=torch.float32, | ||
| ), | ||
| } | ||
| targets = [ | ||
| { | ||
| "labels": torch.tensor([0], dtype=torch.int64), | ||
| "boxes": torch.tensor([[0.5, 0.5, 0.2, 0.2]], dtype=torch.float32), | ||
| } | ||
| ] | ||
|
|
||
| matched_queries, matched_targets = matcher(outputs, targets)[0] | ||
|
|
||
| assert matched_queries.tolist() == [1] | ||
| assert matched_targets.tolist() == [0] |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.