本文整理匯總了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
示例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
示例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
示例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
示例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