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


Python core.bbox_overlaps方法代码示例

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


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

示例1: iou_loss

# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox_overlaps [as 别名]
def iou_loss(pred, target, eps=1e-6):
    """IoU loss.

    Computing the IoU loss between a set of predicted bboxes and target bboxes.
    The loss is calculated as negative log of IoU.

    Args:
        pred (torch.Tensor): Predicted bboxes of format (x1, y1, x2, y2),
            shape (n, 4).
        target (torch.Tensor): Corresponding gt bboxes, shape (n, 4).
        eps (float): Eps to avoid log(0).

    Return:
        torch.Tensor: Loss tensor.
    """
    ious = bbox_overlaps(pred, target, is_aligned=True).clamp(min=eps)
    loss = -ious.log()
    return loss 
开发者ID:open-mmlab,项目名称:mmdetection,代码行数:20,代码来源:iou_loss.py

示例2: iou_loss

# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox_overlaps [as 别名]
def iou_loss(pred, target, eps=1e-6):
    """IoU loss.

    Computing the IoU loss between a set of predicted bboxes and target bboxes.
    The loss is calculated as negative log of IoU.

    Args:
        pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2),
            shape (n, 4).
        target (Tensor): Corresponding gt bboxes, shape (n, 4).
        eps (float): Eps to avoid log(0).

    Return:
        Tensor: Loss tensor.
    """
    ious = bbox_overlaps(pred, target, is_aligned=True).clamp(min=eps)
    loss = -ious.log()
    return loss 
开发者ID:xvjiarui,项目名称:GCNet,代码行数:20,代码来源:iou_loss.py

示例3: iou_loss

# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox_overlaps [as 别名]
def iou_loss(pred, target, linear=False, eps=1e-6):
    """IoU loss.

    Computing the IoU loss between a set of predicted bboxes and target bboxes.
    The loss is calculated as negative log of IoU.

    Args:
        pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2),
            shape (n, 4).
        target (Tensor): Corresponding gt bboxes, shape (n, 4).
        eps (float): Eps to avoid log(0).

    Return:
        Tensor: Loss tensor.
    """
    ious = bbox_overlaps(pred, target, is_aligned=True).clamp(min=eps)
    if linear:
        loss = 1 - ious
    else:
        loss = -ious.log()
    return loss 
开发者ID:thangvubk,项目名称:Cascade-RPN,代码行数:23,代码来源:iou_loss.py

示例4: linear_iou_loss

# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox_overlaps [as 别名]
def linear_iou_loss(pred, target, eps=1e-6):
    """IoU loss.

    Computing the IoU loss between a set of predicted bboxes and target bboxes.
    The loss is calculated as negative log of IoU.

    Args:
        pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2),
            shape (n, 4).
        target (Tensor): Corresponding gt bboxes, shape (n, 4).
        eps (float): Eps to avoid log(0).

    Return:
        Tensor: Loss tensor.
    """
    ious = bbox_overlaps(pred, target, is_aligned=True).clamp(min=eps)
    loss = 1 - ious
    return loss 
开发者ID:lizhe960118,项目名称:CenterNet,代码行数:20,代码来源:linear_iou_loss.py

示例5: loss_single

# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox_overlaps [as 别名]
def loss_single(self, cls_score, bbox_pred, labels, label_weights, level,
                    bbox_targets, bbox_weights, num_total_samples, cfg):

        #generate anchors
        anchors = self.anchor_generators[level].grid_anchors(self.featmap_sizes[level], self.anchor_strides[level])
        anchors = anchors.repeat(2,1)

        # classification loss
        labels = labels.reshape(-1)
        label_weights = label_weights.reshape(-1)
        cls_score = cls_score.permute(0, 2, 3,
                                      1).reshape(-1, self.cls_out_channels)

        # regression loss
        bbox_targets = bbox_targets.reshape(-1, 4)
        bbox_weights = bbox_weights.reshape(-1, 4)
        bbox_pred = bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4)
        if 'is_iou' in cfg.keys() and cfg['is_iou'] == True:
            #get IOU
            bbox = delta2bbox(anchors, bbox_pred, self.target_means, self.target_stds)
            ious = bbox_overlaps(bbox, bbox_targets, is_aligned=True)
            loss_cls = self.loss_cls(
                cls_score, labels, label_weights, avg_factor=num_total_samples,ious=ious)
            loss_bbox = self.loss_bbox(
                bbox_pred,
                bbox_targets,
                bbox_weights,
                avg_factor=num_total_samples)
        else:
            loss_cls = self.loss_cls(
                cls_score, labels, label_weights, avg_factor=num_total_samples)
            loss_bbox = self.loss_bbox(
                bbox_pred,
                bbox_targets,
                bbox_weights,
                avg_factor=num_total_samples)
        return loss_cls, loss_bbox 
开发者ID:xieenze,项目名称:PolarMask,代码行数:39,代码来源:anchor_head.py


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