Skip to content

Fix vote pipeline and similarity computation for empty masks - #30

Open
24f2000604 wants to merge 2 commits into
visinf:mainfrom
24f2000604:main
Open

Fix vote pipeline and similarity computation for empty masks#30
24f2000604 wants to merge 2 commits into
visinf:mainfrom
24f2000604:main

Conversation

@24f2000604

Copy link
Copy Markdown

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.

24f2000604 and others added 2 commits July 29, 2026 19:24
…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>
Copilot AI review requested due to automatic review settings July 29, 2026 23:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread models/insid3.py
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,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

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.

2 participants