Fix vote pipeline and similarity computation for empty masks - #30
Open
24f2000604 wants to merge 2 commits into
Open
Fix vote pipeline and similarity computation for empty masks#3024f2000604 wants to merge 2 commits into
24f2000604 wants to merge 2 commits into
Conversation
…rity inline Negative (empty-mask) reference examples no longer count toward the backward majority-vote threshold, similarity maps are computed per-reference instead of precomputed for all references, and the quantile fallback is cast to fp32 so it works under bf16 autocast. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes INSID3’s segmentation “vote pipeline” behavior when some or all reference masks are empty, preventing majority-vote candidate selection and prototype computation from breaking (or degenerating) on empty-mask inputs.
Changes:
- Ignore reference images whose masks are completely empty at the model input resolution, and return an all-negative prediction when all references are empty.
- Make
downsample_mask()avoid attempting a center-of-mass fallback for truly all-zero masks (which have no valid center). - Adjust candidate localization to compute backward votes robustly (including a bf16-safe forward-mask quantile fallback).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| utils/data.py | Prevents center-of-mass fallback logic from running on all-zero masks during mask downsampling. |
| models/insid3.py | Filters out empty reference masks before prototype/voting, adds an explicit empty-output path, and makes candidate localization more robust. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
281
to
285
| def _locate_candidates( | ||
| self, | ||
| sim_maps: list, | ||
| sim_maps: torch.Tensor, | ||
| ref_masks: torch.Tensor, | ||
| feat_tgt_deb: torch.Tensor, |
Author
There was a problem hiding this comment.
@copilot Fix the code for this review comment.
When a review comment includes a suggested change, apply the suggestion exactly.
Do not make changes beyond what is described in the linked review comment.
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.
fixed the voting when using multiple empty masks, majority vote breaks on completely empty masks. votes all the patches to be unselected . now all the reference images with empty masks will be ignored.