Skip to content

Question about exhaustive_voting #63

@HuangSenPKU

Description

@HuangSenPKU

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions