当前位置: 首页>>代码示例>>Python>>正文


Python Matcher.BELOW_LOW_THRESHOLD属性代码示例

本文整理汇总了Python中maskrcnn_benchmark.modeling.matcher.Matcher.BELOW_LOW_THRESHOLD属性的典型用法代码示例。如果您正苦于以下问题:Python Matcher.BELOW_LOW_THRESHOLD属性的具体用法?Python Matcher.BELOW_LOW_THRESHOLD怎么用?Python Matcher.BELOW_LOW_THRESHOLD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在maskrcnn_benchmark.modeling.matcher.Matcher的用法示例。


在下文中一共展示了Matcher.BELOW_LOW_THRESHOLD属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: prepare_targets

# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BELOW_LOW_THRESHOLD [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 BELOW_LOW_THRESHOLD [as 别名]
def prepare_targets(self, proposals, targets):
        labels = []
        keypoints = []
        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)

            # this can probably be removed, but is left here for clarity
            # and completeness
            # TODO check if this is the right one, as BELOW_THRESHOLD
            neg_inds = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
            labels_per_image[neg_inds] = 0

            keypoints_per_image = matched_targets.get_field("keypoints")
            within_box = _within_box(
                keypoints_per_image.keypoints, matched_targets.bbox
            )
            vis_kp = keypoints_per_image.keypoints[..., 2] > 0
            is_visible = (within_box & vis_kp).sum(1) > 0

            labels_per_image[~is_visible] = -1

            labels.append(labels_per_image)
            keypoints.append(keypoints_per_image)

        return labels, keypoints 
开发者ID:Res2Net,项目名称:Res2Net-maskrcnn,代码行数:33,代码来源:loss.py

示例3: prepare_targets

# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BELOW_LOW_THRESHOLD [as 别名]
def prepare_targets(self, proposals, targets):
        labels = []
        masks = []
        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)

            # this can probably be removed, but is left here for clarity
            # and completeness
            neg_inds = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
            labels_per_image[neg_inds] = 0

            # mask scores are only computed on positive samples
            positive_inds = torch.nonzero(labels_per_image > 0).squeeze(1)

            segmentation_masks = matched_targets.get_field("masks")
            segmentation_masks = segmentation_masks[positive_inds]

            positive_proposals = proposals_per_image[positive_inds]

            masks_per_image = project_masks_on_boxes(
                segmentation_masks, positive_proposals, self.discretization_size
            )

            labels.append(labels_per_image)
            masks.append(masks_per_image)

        return labels, masks 
开发者ID:Res2Net,项目名称:Res2Net-maskrcnn,代码行数:35,代码来源:loss.py

示例4: prepare_targets

# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BELOW_LOW_THRESHOLD [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

示例5: prepare_targets

# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BELOW_LOW_THRESHOLD [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

示例6: prepare_targets

# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BELOW_LOW_THRESHOLD [as 别名]
def prepare_targets(self, proposals, targets):
        labels = []
        masks = []
        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)

            # this can probably be removed, but is left here for clarity
            # and completeness
            neg_inds = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
            labels_per_image[neg_inds] = 0

            # mask scores are only computed on positive samples
            positive_inds = torch.nonzero(labels_per_image > 0).squeeze(1)

            segmentation_masks = matched_targets.get_field("masks")
            segmentation_masks = segmentation_masks[positive_inds]

            positive_proposals = proposals_per_image[positive_inds]

            masks_per_image = project_masks_on_rotate_boxes(
                segmentation_masks, positive_proposals, self.discretization_size
            )

            labels.append(labels_per_image)
            masks.append(masks_per_image)

        return labels, masks 
开发者ID:clw5180,项目名称:remote_sensing_object_detection_2019,代码行数:35,代码来源:loss.py

示例7: prepare_targets

# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BELOW_LOW_THRESHOLD [as 别名]
def prepare_targets(self, proposals, targets):
        labels = []
        words = []
        word_lens = []
        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)

            # this can probably be removed, but is left here for clarity
            # and completeness
            neg_inds = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
            labels_per_image[neg_inds] = 0

            # mask scores are only computed on positive samples
            positive_inds = torch.nonzero(labels_per_image > 0).squeeze(1)

            words_seq = matched_targets.get_field("words")
            words_seq = words_seq[positive_inds]
            words_len = matched_targets.get_field("word_length")
            words_len = words_len[positive_inds]
            # positive_proposals = proposals_per_image[positive_inds]

            # masks_per_image = project_masks_on_boxes(
            #     segmentation_masks, positive_proposals, self.discretization_size
            # )

            labels.append(labels_per_image)
            words.append(words_seq)
            word_lens.append(words_len)

        return labels, words, word_lens 
开发者ID:clw5180,项目名称:remote_sensing_object_detection_2019,代码行数:38,代码来源:loss.py


注:本文中的maskrcnn_benchmark.modeling.matcher.Matcher.BELOW_LOW_THRESHOLD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。