tfm.vision.anchor.AnchorLabeler

Labeler for dense object detector.

match_threshold a float number between 0 and 1 representing the lower-bound threshold to assign positive labels for anchors. An anchor with a score over the threshold is labeled positive.
unmatched_threshold a float number between 0 and 1 representing the upper-bound threshold to assign negative labels for anchors. An anchor with a score below the threshold is labeled negative.
box_coder_weights Optional list of 4 positive floats to scale y, x, h, and w when encoding box coordinates. If set to None, does not perform scaling. For Faster RCNN, the open-source implementation recommends using [10.0, 10.0, 5.0, 5.0].

Methods

label_anchors

View source

Labels anchors with ground truth inputs.

Args
anchor_boxes An ordered dictionary with keys [min_level, min_level+1, ..., max_level]. The values are tensor with shape [height_l, width_l, num_anchors_per_location * 4]. The height_l and width_l represent the dimension of the feature pyramid at l-th level. For each anchor box, the tensor stores [y0, x0, y1, x1] for the four corners.
gt_boxes A float tensor with shape [N, 4] representing ground-truth boxes. For each row, it stores [y0, x0, y1, x1] for four corners of a box.
gt_labels A integer tensor with shape [N, 1] representing ground-truth classes.
gt_attributes If not None, a dict of (name, gt_attribute) pairs. gt_attribute is a float tensor with shape [N, attribute_size] representing ground-truth attributes.
gt_weights If not None, a float tensor with shape [N] representing ground-truth weights.

Returns
cls_targets_dict An ordered dictionary with keys [min_level, min_level+1, ..., max_level]. The values are tensor with shape [height_l, width_l, num_anchors_per_location]. The height_l and width_l represent the dimension of class logits at l-th level.
box_targets_dict An ordered dictionary with keys [min_level, min_level+1, ..., max_level]. The values are tensor with shape [height_l, width_l, num_anchors_per_location * 4]. The height_l and width_l represent the dimension of bounding box regression output at l-th level.
attribute_targets_dict A dict with (name, attribute_targets) pairs. Each attribute_targets represents an ordered dictionary with keys [min_level, min_level+1, ..., max_level]. The values are tensor with shape [height_l, width_l, num_anchors_per_location * attribute_size]. The height_l and width_l represent the dimension of attribute prediction output at l-th level.
cls_weights A flattened Tensor with shape [num_anchors], that serves as masking / sample weight for classification loss. Its value is 1.0 for positive and negative matched anchors, and 0.0 for ignored anchors.
box_weights A flattened Tensor with shape [num_anchors], that serves as masking / sample weight for regression loss. Its value is 1.0 for positive matched anchors, and 0.0 for negative and ignored anchors.