當前位置: 首頁>>代碼示例>>Python>>正文


Python Matcher.BETWEEN_THRESHOLDS屬性代碼示例

本文整理匯總了Python中maskrcnn_benchmark.modeling.matcher.Matcher.BETWEEN_THRESHOLDS屬性的典型用法代碼示例。如果您正苦於以下問題:Python Matcher.BETWEEN_THRESHOLDS屬性的具體用法?Python Matcher.BETWEEN_THRESHOLDS怎麽用?Python Matcher.BETWEEN_THRESHOLDS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在maskrcnn_benchmark.modeling.matcher.Matcher的用法示例。


在下文中一共展示了Matcher.BETWEEN_THRESHOLDS屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: prepare_targets

# 需要導入模塊: from maskrcnn_benchmark.modeling.matcher import Matcher [as 別名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [as 別名]
def prepare_targets(self, proposals, targets):
        labels = []
        regression_targets = []
        for proposals_per_image, targets_per_image in zip(proposals, targets):
            matched_targets = self.match_targets_to_proposals(
                proposals_per_image, targets_per_image
            )
            matched_idxs = matched_targets.get_field("matched_idxs")

            labels_per_image = matched_targets.get_field("labels")
            labels_per_image = labels_per_image.to(dtype=torch.int64)

            # Label background (below the low threshold)
            bg_inds = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
            labels_per_image[bg_inds] = 0

            # Label ignore proposals (between low and high thresholds)
            ignore_inds = matched_idxs == Matcher.BETWEEN_THRESHOLDS
            labels_per_image[ignore_inds] = -1  # -1 is ignored by sampler

            # compute regression targets
            regression_targets_per_image = self.box_coder.encode(
                matched_targets.bbox, proposals_per_image.bbox
            )

            labels.append(labels_per_image)
            regression_targets.append(regression_targets_per_image)

        return labels, regression_targets 
開發者ID:Res2Net,項目名稱:Res2Net-maskrcnn,代碼行數:31,代碼來源:loss.py

示例2: prepare_targets

# 需要導入模塊: from maskrcnn_benchmark.modeling.matcher import Matcher [as 別名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [as 別名]
def prepare_targets(self, anchors, targets):
        labels = []
        regression_targets = []
        for anchors_per_image, targets_per_image in zip(anchors, targets):
            matched_targets = self.match_targets_to_anchors(
                anchors_per_image, targets_per_image, self.copied_fields
            )

            matched_idxs = matched_targets.get_field("matched_idxs")
            labels_per_image = self.generate_labels_func(matched_targets)
            labels_per_image = labels_per_image.to(dtype=torch.float32)

            # Background (negative examples)
            bg_indices = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
            labels_per_image[bg_indices] = 0

            # discard anchors that go out of the boundaries of the image
            if "not_visibility" in self.discard_cases:
                labels_per_image[~anchors_per_image.get_field("visibility")] = -1

            # discard indices that are between thresholds
            if "between_thresholds" in self.discard_cases:
                inds_to_discard = matched_idxs == Matcher.BETWEEN_THRESHOLDS
                labels_per_image[inds_to_discard] = -1

            # compute regression targets
            regression_targets_per_image = self.box_coder.encode(
                matched_targets.bbox, anchors_per_image.bbox
            )

            labels.append(labels_per_image)
            regression_targets.append(regression_targets_per_image)

        return labels, regression_targets 
開發者ID:Res2Net,項目名稱:Res2Net-maskrcnn,代碼行數:36,代碼來源:loss.py

示例3: prepare_targets

# 需要導入模塊: from maskrcnn_benchmark.modeling.matcher import Matcher [as 別名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [as 別名]
def prepare_targets(self, proposals, targets):
        labels = []
        regression_targets = []
        quad_regression_targets = []
        for proposals_per_image, targets_per_image in zip(proposals, targets):
            matched_targets = self.match_targets_to_proposals(
                proposals_per_image, targets_per_image
            )
            matched_idxs = matched_targets.get_field("matched_idxs")

            labels_per_image = matched_targets.get_field("labels")
            labels_per_image = labels_per_image.to(dtype=torch.int64)

            # Label background (below the low threshold)
            bg_inds = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
            labels_per_image[bg_inds] = 0

            # Label ignore proposals (between low and high thresholds)
            ignore_inds = matched_idxs == Matcher.BETWEEN_THRESHOLDS
            labels_per_image[ignore_inds] = -1  # -1 is ignored by sampler

            # compute regression targets
            regression_targets_per_image = self.box_coder.encode(
                matched_targets.bbox, proposals_per_image.bbox
            )
            # compute quad regression targets
            quad_regression_targets_per_image = self.quad_box_coder.encode(
                matched_targets.quad_bbox, proposals_per_image.bbox
            )

            labels.append(labels_per_image)
            regression_targets.append(regression_targets_per_image)
            quad_regression_targets.append(quad_regression_targets_per_image)

        return labels, regression_targets, quad_regression_targets 
開發者ID:Xiangyu-CAS,項目名稱:R2CNN.pytorch,代碼行數:37,代碼來源:loss.py

示例4: prepare_targets

# 需要導入模塊: from maskrcnn_benchmark.modeling.matcher import Matcher [as 別名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [as 別名]
def prepare_targets(self, anchors, targets):
        labels = []
        regression_targets = []
        for anchors_per_image, targets_per_image in zip(anchors, targets):
            matched_targets = self.match_targets_to_anchors(
                anchors_per_image, targets_per_image
            )

            matched_idxs = matched_targets.get_field("matched_idxs")
            labels_per_image = matched_idxs >= 0
            labels_per_image = labels_per_image.to(dtype=torch.float32)
            # discard anchors that go out of the boundaries of the image
            labels_per_image[~anchors_per_image.get_field("visibility")] = -1

            # discard indices that are between thresholds
            inds_to_discard = matched_idxs == Matcher.BETWEEN_THRESHOLDS
            labels_per_image[inds_to_discard] = -1

            # compute regression targets
            regression_targets_per_image = self.box_coder.encode(
                matched_targets.bbox, anchors_per_image.bbox
            )

            labels.append(labels_per_image)
            regression_targets.append(regression_targets_per_image)

        return labels, regression_targets 
開發者ID:clw5180,項目名稱:remote_sensing_object_detection_2019,代碼行數:29,代碼來源:loss.py

示例5: prepare_targets

# 需要導入模塊: from maskrcnn_benchmark.modeling.matcher import Matcher [as 別名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [as 別名]
def prepare_targets(self, anchors, targets):
        labels = []
        regression_targets = []
        for anchors_per_image, targets_per_image in zip(anchors, targets):
            matched_targets = self.match_targets_to_anchors(
                anchors_per_image, targets_per_image
            )

            matched_idxs = matched_targets.get_field("matched_idxs")
            labels_per_image = matched_idxs >= 0
            labels_per_image = labels_per_image.to(dtype=torch.float32)
            # discard anchors that go out of the boundaries of the image
            labels_per_image[~anchors_per_image.get_field("visibility")] = -1

            # discard indices that are between thresholds
            inds_to_discard = matched_idxs == Matcher.BETWEEN_THRESHOLDS
            labels_per_image[inds_to_discard] = -1

            # compute regression targets
            regression_targets_per_image = self.box_coder.encode(
                matched_targets.bbox, anchors_per_image.bbox
            )

            # print('regression_targets_per_image:', regression_targets_per_image)
            # label_np = labels_per_image.data.cpu().numpy()
            # print('rpn_labels:', labels_per_image.size(), np.unique(label_np), len(np.where(label_np==1)[0]), len(np.where(label_np==0)[0]))
            labels.append(labels_per_image)
            regression_targets.append(regression_targets_per_image)

        return labels, regression_targets 
開發者ID:clw5180,項目名稱:remote_sensing_object_detection_2019,代碼行數:32,代碼來源:loss.py

示例6: prepare_targets

# 需要導入模塊: from maskrcnn_benchmark.modeling.matcher import Matcher [as 別名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [as 別名]
def prepare_targets(self, anchors, targets):
        labels = []
        regression_targets = []
        for anchors_per_image, targets_per_image in zip(anchors, targets):
            matched_targets = self.match_targets_to_anchors(
                anchors_per_image, targets_per_image
            )

            matched_idxs = matched_targets.get_field("matched_idxs")
            labels_per_image = matched_targets.get_field("labels").clone()

            # Background (negative examples)
            bg_indices = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
            labels_per_image[bg_indices] = 0

            # discard indices that are between thresholds 
            # -1 will be ignored in SigmoidFocalLoss
            inds_to_discard = matched_idxs == Matcher.BETWEEN_THRESHOLDS
            labels_per_image[inds_to_discard] = -1

            labels_per_image = labels_per_image.to(dtype=torch.float32)
            # compute regression targets
            regression_targets_per_image = self.box_coder.encode(
                matched_targets.bbox, anchors_per_image.bbox
            )

            labels.append(labels_per_image)
            regression_targets.append(regression_targets_per_image)

        return labels, regression_targets 
開發者ID:zhangxiaosong18,項目名稱:FreeAnchor,代碼行數:32,代碼來源:retinanet_loss.py

示例7: prepare_targets

# 需要導入模塊: from maskrcnn_benchmark.modeling.matcher import Matcher [as 別名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [as 別名]
def prepare_targets(self, anchors, targets):
        labels = []
        regression_targets = []
        for anchors_per_image, targets_per_image in zip(anchors, targets):
            if len(targets_per_image) <= 0:
                device = anchors_per_image.bbox.device
                dummy_labels = torch.zeros(len(anchors_per_image),
                                           dtype=torch.float32,
                                           device=device)
                dummy_regression = torch.zeros((len(anchors_per_image), 4),
                                               dtype=torch.float32,
                                               device=device)
                labels.append(dummy_labels)
                regression_targets.append(dummy_regression)
                continue
            matched_targets = self.match_targets_to_anchors(
                anchors_per_image, targets_per_image
            )

            matched_idxs = matched_targets.get_field("matched_idxs")
            labels_per_image = matched_targets.get_field("labels").clone()

            # Background (negative examples)
            bg_indices = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
            labels_per_image[bg_indices] = 0

            # discard indices that are between thresholds 
            # -1 will be ignored in SigmoidFocalLoss
            inds_to_discard = matched_idxs == Matcher.BETWEEN_THRESHOLDS
            labels_per_image[inds_to_discard] = -1

            labels_per_image = labels_per_image.to(dtype=torch.float32)
            # compute regression targets
            regression_targets_per_image = self.box_coder.encode(
                matched_targets.bbox, anchors_per_image.bbox
            )

            labels.append(labels_per_image)
            regression_targets.append(regression_targets_per_image)
            
        return labels, regression_targets 
開發者ID:Lausannen,項目名稱:NAS-FCOS,代碼行數:43,代碼來源:loss.py


注:本文中的maskrcnn_benchmark.modeling.matcher.Matcher.BETWEEN_THRESHOLDS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。