tfm.vision.layers.BoxSampler

Creates a BoxSampler to sample positive and negative boxes.

num_samples An int of the number of sampled boxes per image.
foreground_fraction A float in [0, 1], what percentage of boxes should be sampled from the positive examples.
**kwargs Additional keyword arguments passed to Layer.

Methods

call

View source

Samples and selects positive and negative instances.

Args
positive_matches A bool tensor of shape of [batch, N] where N is the number of instances. For each element, True means the instance corresponds to a positive example.
negative_matches A bool tensor of shape of [batch, N] where N is the number of instances. For each element, True means the instance corresponds to a negative example.
ignored_matches A bool tensor of shape of [batch, N] where N is the number of instances. For each element, True means the instance should be ignored.

Returns
A tf.tensor of shape of [batch_size, K], storing the indices of the sampled examples, where K is num_samples.