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


Python boxlist_ops.cat_boxlist方法代碼示例

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


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

示例1: add_gt_proposals

# 需要導入模塊: from maskrcnn_benchmark.structures import boxlist_ops [as 別名]
# 或者: from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist [as 別名]
def add_gt_proposals(self, proposals, targets):
        """
        Arguments:
            proposals: list[BoxList]
            targets: list[BoxList]
        """
        # Get the device we're operating on
        device = proposals[0].bbox.device

        gt_boxes = [target.copy_with_fields([]) for target in targets]

        # later cat of bbox requires all fields to be present for all bbox
        # so we need to add a dummy for objectness that's missing
        for gt_box in gt_boxes:
            gt_box.add_field("objectness", torch.ones(len(gt_box), device=device))

        proposals = [
            cat_boxlist((proposal, gt_box))
            for proposal, gt_box in zip(proposals, gt_boxes)
        ]

        return proposals 
開發者ID:clw5180,項目名稱:remote_sensing_object_detection_2019,代碼行數:24,代碼來源:inference.py

示例2: add_gt_proposals

# 需要導入模塊: from maskrcnn_benchmark.structures import boxlist_ops [as 別名]
# 或者: from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist [as 別名]
def add_gt_proposals(self, proposals, targets):
        """
        Arguments:
            proposals: list[BoxList]
            targets: list[BoxList]
        """
        # Get the device we're operating on
        device = proposals[0].bbox.device
        dtype = proposals[0].get_field("objectness").dtype

        gt_boxes = [target.copy_with_fields([]) for target in targets]

        # later cat of bbox requires all fields to be present for all bbox
        # so we need to add a dummy for objectness that's missing
        for gt_box in gt_boxes:
            gt_box.add_field("objectness", torch.ones(len(gt_box), device=device, dtype=dtype))

        proposals = [
            cat_boxlist((proposal, gt_box))
            for proposal, gt_box in zip(proposals, gt_boxes)
        ]

        return proposals 
開發者ID:HRNet,項目名稱:HRNet-MaskRCNN-Benchmark,代碼行數:25,代碼來源:inference.py

示例3: forward_without

# 需要導入模塊: from maskrcnn_benchmark.structures import boxlist_ops [as 別名]
# 或者: from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist [as 別名]
def forward_without(self, anchors, box_cls, box_regression):
        """
        Arguments:
            anchors: list[list[BoxList]]
            box_cls: list[tensor]
            box_regression: list[tensor]

        Returns:
            boxlists (list[BoxList]): the post-processed anchors, after
                applying box decoding and NMS
        """
        sampled_boxes = []
        anchors = list(zip(*anchors))
        for layer, (a, o, b) in enumerate(
            zip(anchors, box_cls, box_regression)):
            sampled_boxes.append(
                self.forward_for_single_feature_map_without(
                    a, o, b, self.pre_nms_thresh
                )
            )

        boxlists = list(zip(*sampled_boxes))
        boxlists = [cat_boxlist(boxlist) for boxlist in boxlists]
        return boxlists 
開發者ID:zhangxiaosong18,項目名稱:FreeAnchor,代碼行數:26,代碼來源:without_nms_postprocessor.py

示例4: cat_boxlist_with_keypoints

# 需要導入模塊: from maskrcnn_benchmark.structures import boxlist_ops [as 別名]
# 或者: from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist [as 別名]
def cat_boxlist_with_keypoints(boxlists):
    assert all(boxlist.has_field("keypoints") for boxlist in boxlists)

    kp = [boxlist.get_field("keypoints").keypoints for boxlist in boxlists]
    kp = cat(kp, 0)

    fields = boxlists[0].get_fields()
    fields = [field for field in fields if field != "keypoints"]

    boxlists = [boxlist.copy_with_fields(fields) for boxlist in boxlists]
    boxlists = cat_boxlist(boxlists)
    boxlists.add_field("keypoints", kp)
    return boxlists 
開發者ID:Res2Net,項目名稱:Res2Net-maskrcnn,代碼行數:15,代碼來源:loss.py

示例5: __call__

# 需要導入模塊: from maskrcnn_benchmark.structures import boxlist_ops [as 別名]
# 或者: from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist [as 別名]
def __call__(self, anchors, box_cls, box_regression, targets):
        """
        Arguments:
            anchors (list[BoxList])
            box_cls (list[Tensor])
            box_regression (list[Tensor])
            targets (list[BoxList])

        Returns:
            retinanet_cls_loss (Tensor)
            retinanet_regression_loss (Tensor
        """
        anchors = [cat_boxlist(anchors_per_image) for anchors_per_image in anchors]
        labels, regression_targets = self.prepare_targets(anchors, targets)

        N = len(labels)
        box_cls, box_regression = \
                concat_box_prediction_layers(box_cls, box_regression)

        labels = torch.cat(labels, dim=0)
        regression_targets = torch.cat(regression_targets, dim=0)
        pos_inds = torch.nonzero(labels > 0).squeeze(1)

        retinanet_regression_loss = smooth_l1_loss(
            box_regression[pos_inds],
            regression_targets[pos_inds],
            beta=self.bbox_reg_beta,
            size_average=False,
        ) / (max(1, pos_inds.numel() * self.regress_norm))

        labels = labels.int()

        retinanet_cls_loss = self.box_cls_loss_func(
            box_cls,
            labels
        ) / (pos_inds.numel() + N)

        return retinanet_cls_loss, retinanet_regression_loss 
開發者ID:Res2Net,項目名稱:Res2Net-maskrcnn,代碼行數:40,代碼來源:loss.py

示例6: forward

# 需要導入模塊: from maskrcnn_benchmark.structures import boxlist_ops [as 別名]
# 或者: from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist [as 別名]
def forward(self, anchors, objectness, box_regression, targets=None):
        """
        Arguments:
            anchors: list[list[BoxList]]
            objectness: list[tensor]
            box_regression: list[tensor]

        Returns:
            boxlists (list[BoxList]): the post-processed anchors, after
                applying box decoding and NMS
        """
        sampled_boxes = []
        num_levels = len(objectness)
        anchors = list(zip(*anchors))
        for a, o, b in zip(anchors, objectness, box_regression):
            sampled_boxes.append(self.forward_for_single_feature_map(a, o, b))

        boxlists = list(zip(*sampled_boxes))
        boxlists = [cat_boxlist(boxlist) for boxlist in boxlists]

        if num_levels > 1:
            boxlists = self.select_over_all_levels(boxlists)

        # append ground-truth bboxes to proposals
        if self.training and targets is not None:
            boxlists = self.add_gt_proposals(boxlists, targets)

        return boxlists 
開發者ID:Res2Net,項目名稱:Res2Net-maskrcnn,代碼行數:30,代碼來源:inference.py

示例7: __call__

# 需要導入模塊: from maskrcnn_benchmark.structures import boxlist_ops [as 別名]
# 或者: from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist [as 別名]
def __call__(self, anchors, box_cls, box_regression, targets):
        """
        Arguments:
            anchors (list[BoxList])
            box_cls (list[Tensor])
            box_regression (list[Tensor])
            targets (list[BoxList])

        Returns:
            retinanet_cls_loss (Tensor)
            retinanet_regression_loss (Tensor
        """
        anchors = [cat_boxlist(anchors_per_image) for anchors_per_image in anchors]
        labels, regression_targets = self.prepare_targets(anchors, targets)

        N = len(labels)
        box_cls, box_regression = \
                concat_box_prediction_layers(box_cls, box_regression)

        labels = torch.cat(labels, dim=0)
        regression_targets = torch.cat(regression_targets, dim=0)
        pos_inds = torch.nonzero(labels > 0).squeeze(1)

        retinanet_regression_loss = smooth_l1_loss(
            box_regression[pos_inds],
            regression_targets[pos_inds],
            beta=self.bbox_reg_beta,
            size_average=False,
        ) / (max(1, pos_inds.numel() * self.regress_norm))

        labels = labels.int()

        retinanet_cls_loss = self.box_cls_loss_func(
            box_cls,
            labels
        ) / (pos_inds.numel() + N)
        
        return retinanet_cls_loss, retinanet_regression_loss 
開發者ID:ChenJoya,項目名稱:sampling-free,代碼行數:40,代碼來源:loss.py


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