vis4d.op.box.samplers

Init sampler module.

class CombinedSampler(*args, pos_strategy, neg_strategy, neg_pos_ub=3.0, floor_thr=-1.0, floor_fraction=0.0, num_bins=3, bg_label=0, **kwargs)[source]

Combined sampler. Can have different strategies for pos/neg samples.

Creates an instance of the class.

forward(matching)[source]

Sample boxes according to strategies defined in cfg.

Return type:

SamplingResult

static instance_balanced_sampling(idx_tensor, assigned_gts, assigned_gt_ious, sample_size)[source]

Sample indices with balancing according to matched GT instance.

Return type:

Tensor

iou_balanced_sampling(idx_tensor, assigned_gts, assigned_gt_ious, sample_size)[source]

Sample indices with balancing according to IoU with matched GT.

Return type:

Tensor

sample_within_intervals(idx_tensor, assigned_gt_ious, sample_size)[source]

Sample according to N iou intervals where N = num bins.

Return type:

Tensor

class PseudoSampler[source]

Pseudo sampler class (does nothing).

Init.

forward(matching)[source]

Sample boxes randomly.

Return type:

SamplingResult

class RandomSampler(*args, bg_label=0, **kwargs)[source]

Random sampler class.

Creates an instance of the class.

forward(matching)[source]

Sample boxes randomly.

Return type:

SamplingResult

class Sampler(batch_size, positive_fraction)[source]

Sampler base class.

Creates an instance of the class.

__call__(matching)[source]

Type declaration.

Return type:

SamplingResult

abstract forward(matching)[source]

Sample bounding boxes according to their struct.

Return type:

SamplingResult

class SamplingResult(sampled_box_indices: Tensor, sampled_target_indices: Tensor, sampled_labels: Tensor)[source]

Sampling result class. Stores expected result tensors.

sampled_box_indices (Tensor): Index of sampled boxes from input. sampled_target_indices (Tensor): Index of assigned target for each

positive sampled box.

sampled_labels (Tensor): {0, -1, 1} = {neg, ignore, pos}.

Create new instance of SamplingResult(sampled_box_indices, sampled_target_indices, sampled_labels)

sampled_box_indices: Tensor

Alias for field number 0

sampled_labels: Tensor

Alias for field number 2

sampled_target_indices: Tensor

Alias for field number 1

match_and_sample_proposals(matcher, sampler, proposal_boxes, target_boxes)[source]

Match proposals to targets and subsample.

First, match the proposals to targets (ground truth labels) using the matcher. It is usually IoU matcher. The matching labels the proposals with positive or negative to show whether they are matched to an object. Second, the sampler will choose proposals based on certain criteria such as total proposal number and ratio of postives and negatives.

Return type:

tuple[list[Tensor], list[Tensor], list[Tensor]]

Modules

vis4d.op.box.samplers.base

Interface for Vis4D bounding box samplers.

vis4d.op.box.samplers.combined

Combined Sampler.

vis4d.op.box.samplers.pseudo

Pseudo Sampler.

vis4d.op.box.samplers.random

Random Sampler.