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 the matches into different types (e.g. positive or negative or ignored match). The list needs to be sorted, and will be prepended with -Inf and appended with +Inf.
indicators A list of values representing match types (e.g. positive or negative or ignored match). 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 [num_rows, num_cols] or [batch_size, num_rows, num_cols] representing any similarity metric.

Returns
matched_columns An integer tensor of shape [num_rows] or [batch_size, num_rows] storing the index of the matched column for each row.
match_indicators An integer tensor of shape [num_rows] or [batch_size, num_rows] storing the match type indicator (e.g. positive or negative or ignored match).