facebookresearch / facebookresearch/OrienterNet

Question about exhaustive_voting

Open
#63 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
577
Forks
66
PR merge metrics
No merged PRs in 30d

Description

Hello, why is `valid_bev.unsqueeze(1)` used in `f_bev = f_bev.masked_fill(~valid_bev.unsqueeze(1), 0.0)` in the `exhaustive_voting` function, while `valid_bev.float()[None]` is used in `valid_templates = self.template_sampler(valid_bev.float()[None])`?

def exhaustive_voting(self, f_bev, f_map, valid_bev, confidence_bev=None):
if self.conf.normalize_features:
f_bev = normalize(f_bev, dim=1)
f_map = normalize(f_map, dim=1)

# Build the templates and exhaustively match against the map.
if confidence_bev is not None:
f_bev = f_bev * confidence_bev.unsqueeze(1)
f_bev = f_bev.masked_fill(~valid_bev.unsqueeze(1), 0.0)
templates = self.template_sampler(f_bev)
with torch.autocast("cuda", enabled=False):
scores = conv2d_fft_batchwise(
f_map.float(),
templates.float(),
padding_mode=self.conf.padding_matching,
)
if self.conf.add_temperature:
scores = scores * torch.exp(self.temperature)
# Reweight the different rotations based on the number of valid pixels in each
# template. Axis-aligned rotation have the maximum number of valid pixels.
valid_templates = self.template_sampler(valid_bev.float()[None) > (1 - 1e-4)

num_valid = valid_templates.float().sum((-3, -2, -1))
scores = scores / num_valid[..., None, None]
return scores

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.