本文整理匯總了Python中modeling.fast_rcnn_heads.fast_rcnn_losses方法的典型用法代碼示例。如果您正苦於以下問題:Python fast_rcnn_heads.fast_rcnn_losses方法的具體用法?Python fast_rcnn_heads.fast_rcnn_losses怎麽用?Python fast_rcnn_heads.fast_rcnn_losses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類modeling.fast_rcnn_heads
的用法示例。
在下文中一共展示了fast_rcnn_heads.fast_rcnn_losses方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from modeling import fast_rcnn_heads [as 別名]
# 或者: from modeling.fast_rcnn_heads import fast_rcnn_losses [as 別名]
def __init__(self, args):
super(FRCNNCriterion3, self).__init__(args)
# initialize Detectron
this_dir = os.path.dirname(__file__)
lib_path = os.path.join(this_dir, '../../external/Detectron.pytorch/')
sys.path.insert(0, lib_path)
from roi_data.rpn import add_rpn_blobs
from modeling import rpn_heads, fast_rcnn_heads
from core.config import cfg
self.cfg = cfg
self.add_rpn_blobs = add_rpn_blobs
self.generic_rpn_losses = rpn_heads.generic_rpn_losses
self.fast_rcnn_losses = fast_rcnn_heads.fast_rcnn_losses
self.img_size = args.input_size
self.nclass = args.nclass
self.sigmoid = True
示例2: forward
# 需要導入模塊: from modeling import fast_rcnn_heads [as 別名]
# 或者: from modeling.fast_rcnn_heads import fast_rcnn_losses [as 別名]
def forward(self, score_predictions, roi_score, bbox_pred, rpn_ret, rpn_kwargs,
target, meta, synchronous=False):
# rpn loss
loss_rpn_cls, loss_rpn_bbox = self.generic_rpn_losses(**rpn_kwargs)
# bbox loss
print('roi_score norm {} \t mean {}'.format(roi_score.norm(), roi_score.mean()))
if self.training:
if self.cfg.MODEL.CLS_AGNOSTIC_BBOX_REG:
labels = rpn_ret['fix_labels_int32'].cpu().numpy() * rpn_ret['labels_int32'].cpu().numpy()
else:
labels = rpn_ret['labels_int32'].cpu().numpy()
loss_cls, loss_bbox, accuracy_cls = self.fast_rcnn_losses(
roi_score, bbox_pred, labels, rpn_ret['bbox_targets'].cpu().numpy(),
rpn_ret['bbox_inside_weights'].cpu().numpy(), rpn_ret['bbox_outside_weights'].cpu().numpy())
else:
loss_cls = loss_bbox = accuracy_cls = 0
if self.sigmoid:
sigmoid_loss = torch.nn.MultiLabelSoftMarginLoss()
loss_cls = sigmoid_loss(roi_score, rpn_ret['multilabels_int32'])
print('sigmoid frcnn loss')
losses = [loss_rpn_cls, loss_rpn_bbox*2, loss_cls*0, loss_bbox*0]
print('losses {} {} {} {}'.format(*losses))
print('accuracy {}'.format(accuracy_cls))
score_targets = []
for m in meta:
score_targets.append({'boxes': m['boxes'],
'labels': m['labels'],
'start': m['start'],
'vid': m['id']})
return score_predictions, sum(losses), score_targets