tfm.vision.box_matcher.BoxMatcher
Stay organized with collections
Save and categorize content based on your preferences.
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.
Args |
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] .
|
Raises |
ValueError
|
If threshold not sorted,
or len(indicators) != len(threshold) + 1
|
Methods
__call__
View source
__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).
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-02-02 UTC.
[null,null,["Last updated 2024-02-02 UTC."],[],[],null,["# tfm.vision.box_matcher.BoxMatcher\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/models/blob/v2.15.0/official/vision/ops/box_matcher.py#L22-L202) |\n\nMatcher based on highest value. \n\n tfm.vision.box_matcher.BoxMatcher(\n thresholds: List[float],\n indicators: List[int],\n force_match_for_each_col: bool = False\n )\n\nThis class computes matches from a similarity matrix. Each column is matched\nto a single row.\n\nTo support object detection target assignment this class enables setting both\npositive_threshold (upper threshold) and negative_threshold (lower thresholds)\ndefining three categories of similarity which define whether examples are\npositive, negative, or ignored, for example:\n(1) thresholds=\\[negative_threshold, positive_threshold\\], and\nindicators=\\[negative_value, ignore_value, positive_value\\]: The similarity\nmetrics below negative_threshold will be assigned with negative_value,\nthe metrics between negative_threshold and positive_threshold will be\nassigned ignore_value, and the metrics above positive_threshold will be\nassigned positive_value.\n(2) thresholds=\\[negative_threshold, positive_threshold\\], and\nindicators=\\[ignore_value, negative_value, positive_value\\]: The similarity\nmetric below negative_threshold will be assigned with ignore_value,\nthe metrics between negative_threshold and positive_threshold will be\nassigned negative_value, and the metrics above positive_threshold will be\nassigned positive_value.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `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. |\n| `indicators` | A list of values representing match types (e.g. positive or negative or ignored match). len(`indicators`) must equal to len(`thresholds`) + 1. |\n| `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]`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|---------------------------------------------------------------------|\n| `ValueError` | If `threshold` not sorted, or len(indicators) != len(threshold) + 1 |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `__call__`\n\n[View source](https://github.com/tensorflow/models/blob/v2.15.0/official/vision/ops/box_matcher.py#L81-L188) \n\n __call__(\n similarity_matrix: tf.Tensor\n ) -\u003e Tuple[tf.Tensor, tf.Tensor]\n\nTries to match each column of the similarity matrix to a row.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------------------|--------------------------------------------------------------------------------------------------------------------------|\n| `similarity_matrix` | A float tensor of shape \\[num_rows, num_cols\\] or \\[batch_size, num_rows, num_cols\\] representing any similarity metric. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `matched_columns` | An integer tensor of shape \\[num_rows\\] or \\[batch_size, num_rows\\] storing the index of the matched column for each row. |\n| `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). |\n\n\u003cbr /\u003e"]]