本文整理汇总了Python中maskrcnn_benchmark.modeling.matcher.Matcher.BETWEEN_THRESHOLDS属性的典型用法代码示例。如果您正苦于以下问题:Python Matcher.BETWEEN_THRESHOLDS属性的具体用法?Python Matcher.BETWEEN_THRESHOLDS怎么用?Python Matcher.BETWEEN_THRESHOLDS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类maskrcnn_benchmark.modeling.matcher.Matcher
的用法示例。
在下文中一共展示了Matcher.BETWEEN_THRESHOLDS属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_targets
# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [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
示例2: prepare_targets
# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [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
示例3: prepare_targets
# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [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
示例4: prepare_targets
# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [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
)
matched_idxs = matched_targets.get_field("matched_idxs")
labels_per_image = matched_idxs >= 0
labels_per_image = labels_per_image.to(dtype=torch.float32)
# discard anchors that go out of the boundaries of the image
labels_per_image[~anchors_per_image.get_field("visibility")] = -1
# discard indices that are between thresholds
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
示例5: prepare_targets
# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [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
)
matched_idxs = matched_targets.get_field("matched_idxs")
labels_per_image = matched_idxs >= 0
labels_per_image = labels_per_image.to(dtype=torch.float32)
# discard anchors that go out of the boundaries of the image
labels_per_image[~anchors_per_image.get_field("visibility")] = -1
# discard indices that are between thresholds
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
)
# print('regression_targets_per_image:', regression_targets_per_image)
# label_np = labels_per_image.data.cpu().numpy()
# print('rpn_labels:', labels_per_image.size(), np.unique(label_np), len(np.where(label_np==1)[0]), len(np.where(label_np==0)[0]))
labels.append(labels_per_image)
regression_targets.append(regression_targets_per_image)
return labels, regression_targets
示例6: prepare_targets
# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [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
)
matched_idxs = matched_targets.get_field("matched_idxs")
labels_per_image = matched_targets.get_field("labels").clone()
# Background (negative examples)
bg_indices = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
labels_per_image[bg_indices] = 0
# discard indices that are between thresholds
# -1 will be ignored in SigmoidFocalLoss
inds_to_discard = matched_idxs == Matcher.BETWEEN_THRESHOLDS
labels_per_image[inds_to_discard] = -1
labels_per_image = labels_per_image.to(dtype=torch.float32)
# 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
示例7: prepare_targets
# 需要导入模块: from maskrcnn_benchmark.modeling.matcher import Matcher [as 别名]
# 或者: from maskrcnn_benchmark.modeling.matcher.Matcher import BETWEEN_THRESHOLDS [as 别名]
def prepare_targets(self, anchors, targets):
labels = []
regression_targets = []
for anchors_per_image, targets_per_image in zip(anchors, targets):
if len(targets_per_image) <= 0:
device = anchors_per_image.bbox.device
dummy_labels = torch.zeros(len(anchors_per_image),
dtype=torch.float32,
device=device)
dummy_regression = torch.zeros((len(anchors_per_image), 4),
dtype=torch.float32,
device=device)
labels.append(dummy_labels)
regression_targets.append(dummy_regression)
continue
matched_targets = self.match_targets_to_anchors(
anchors_per_image, targets_per_image
)
matched_idxs = matched_targets.get_field("matched_idxs")
labels_per_image = matched_targets.get_field("labels").clone()
# Background (negative examples)
bg_indices = matched_idxs == Matcher.BELOW_LOW_THRESHOLD
labels_per_image[bg_indices] = 0
# discard indices that are between thresholds
# -1 will be ignored in SigmoidFocalLoss
inds_to_discard = matched_idxs == Matcher.BETWEEN_THRESHOLDS
labels_per_image[inds_to_discard] = -1
labels_per_image = labels_per_image.to(dtype=torch.float32)
# 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