View source on GitHub |
Matcher based on highest value.
tfm.vision.box_matcher.BoxMatcher(
thresholds: List[float],
indicators: List[int],
force_match_for_each_col: bool = False
)
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.
Raises | |
---|---|
ValueError
|
If threshold not sorted,
or len(indicators) != len(threshold) + 1
|
Methods
__call__
__call__(
similarity_matrix: tf.Tensor
) -> Tuple[tf.Tensor, tf.Tensor]
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). |