tfm.vision.box_matcher.BoxMatcher

Matcher based on highest value.

This class computes matches from a similarity matrix. Each column is matched to a single row.

To support object detection target assignment this class enables setting both positive_threshold (upper threshold) and negative_threshold (lower thresholds) defining three categories of similarity which define whether examples are positive, negative, or ignored, for example: (1) thresholds=[negative_threshold, positive_threshold], and indicators=[negative_value, ignore_value, positive_value]: The similarity metrics below negative_threshold will be assigned with negative_value, the metrics between negative_threshold and positive_threshold will be assigned ignore_value, and the metrics above positive_threshold will be assigned positive_value. (2) thresholds=[negative_threshold, positive_threshold], and indicators=[ignore_value, negative_value, positive_value]: The similarity metric below negative_threshold will be assigned with ignore_value, the metrics between negative_threshold and positive_threshold will be assigned negative_value, and the metrics above positive_threshold will be assigned positive_value.

thresholds A list of thresholds to classify boxes into different buckets. The list needs to be sorted, and will be prepended with -Inf and appended with +Inf.
indicators A list of values to assign for each bucket. len(indicators) must equal to len(thresholds) + 1.
force_match_for_each_col If True, ensures that each column is matched to at least one row (which is not guaranteed otherwise if the positive_threshold is high). Defaults to False. If True, all force matched row will be assigned to indicators[-1].

ValueError If threshold not sorted, or len(indicators) != len(threshold) + 1

Methods

__call__

View source

Tries to match each column of the similarity matrix to a row.

Args
similarity_matrix A float tensor of shape [N, M] representing any similarity metric.

Returns
A integer tensor of shape [N] with corresponding match indices for each of M columns, for positive match, the match result will be the corresponding row index, for negative match, the match will be negative_value, for ignored match, the match result will be ignore_value.