vis4d.op.detect.mask_rcnn¶
Mask RCNN detector.
Functions
|
Sample only positive masks from target masks. |
Classes
|
Post processing of mask predictions. |
|
Output of the final detections from Mask RCNN. |
|
Mask R-CNN RoI head. |
|
Mask RoI head loss function. |
|
Mask RoI head loss container. |
|
Mask R-CNN RoI head outputs. |
|
Type definition for mask sampler. |
|
Sampled Mask RCNN head loss function. |
- class Det2Mask(mask_threshold=0.5, no_overlap=False)[source]¶
Post processing of mask predictions.
- Parameters:
mask_threshold (float, optional) – Positive threshold. Defaults to 0.5.
no_overlap (bool, optional) – Whether to remove overlapping pixels between masks. Defaults to False.
Creates an instance of the class.
- __call__(mask_outs, det_boxes, det_scores, det_class_ids, original_hw)[source]¶
Type definition for function call.
- Return type:
- forward(mask_outs, det_boxes, det_scores, det_class_ids, original_hw)[source]¶
Paste mask predictions back into original image resolution.
- Parameters:
mask_outs (list[torch.Tensor]) – List of mask outputs for each batch element.
det_boxes (list[torch.Tensor]) – List of detection boxes for each batch element.
det_scores (list[torch.Tensor]) – List of detection scores for each batch element.
det_class_ids (list[torch.Tensor]) – List of detection classeds for each batch element.
original_hw (list[tuple[int, int]]) – Original image resolution.
- Returns:
Post-processed mask predictions.
- Return type:
- class MaskOut(masks: list[torch.Tensor], scores: list[torch.Tensor], class_ids: list[torch.Tensor])[source]¶
Output of the final detections from Mask RCNN.
Create new instance of MaskOut(masks, scores, class_ids)
-
class_ids:
list
[Tensor
]¶ Alias for field number 2
-
masks:
list
[Tensor
]¶ Alias for field number 0
-
scores:
list
[Tensor
]¶ Alias for field number 1
-
class_ids:
- class MaskRCNNHead(num_classes=80, num_convs=4, roi_size=(14, 14), in_channels=256, conv_kernel_size=3, conv_out_channels=256, scale_factor=2, class_agnostic=False)[source]¶
Mask R-CNN RoI head.
- Parameters:
num_classes (int, optional) – Number of classes. Defaults to 80.
num_convs (int, optional) – Number of convolution layers. Defaults to 4.
roi_size (tuple[int, int], optional) – Size of RoI after pooling. Defaults to (14, 14).
in_channels (int, optional) – Input feature channels. Defaults to 256.
conv_kernel_size (int, optional) – Kernel size of convolution. Defaults to 3.
conv_out_channels (int, optional) – Output channels of convolution. Defaults to 256.
scale_factor (int, optional) – Scaling factor of upsampling. Defaults to 2.
class_agnostic (bool, optional) – Whether to do class agnostic mask prediction. Defaults to False.
Creates an instance of the class.
- class MaskRCNNHeadLoss(num_classes)[source]¶
Mask RoI head loss function.
- Parameters:
num_classes (int) – number of object categories.
Creates an instance of the class.
- forward(mask_preds, proposal_boxes, target_classes, target_masks)[source]¶
Calculate losses of Mask RCNN head.
- Parameters:
mask_preds (list[torch.Tensor]) – [M, C, H’, W’] mask outputs per batch element.
proposal_boxes (list[torch.Tensor]) – [M, 4] proposal boxes per batch element.
target_classes (list[torch.Tensor]) – list of [M, 4] assigned target boxes for each proposal.
target_masks (list[torch.Tensor]) – list of [M, H, W] assigned target masks for each proposal.
- Returns:
mask loss.
- Return type:
- class MaskRCNNHeadLosses(rcnn_loss_mask: torch.Tensor)[source]¶
Mask RoI head loss container.
Create new instance of MaskRCNNHeadLosses(rcnn_loss_mask,)
-
rcnn_loss_mask:
Tensor
¶ Alias for field number 0
-
rcnn_loss_mask:
- class MaskRCNNHeadOut(mask_pred: list[torch.Tensor])[source]¶
Mask R-CNN RoI head outputs.
Create new instance of MaskRCNNHeadOut(mask_pred,)
-
mask_pred:
list
[Tensor
]¶ Alias for field number 0
-
mask_pred:
- class MaskSampler(*args, **kwargs)[source]¶
Type definition for mask sampler.
- class SampledMaskLoss(mask_sampler, loss)[source]¶
Sampled Mask RCNN head loss function.
Initialize sampled mask loss.
- Parameters:
mask_sampler (MaskSampler) – mask sampler.
loss (MaskRCNNHeadLoss) – mask loss.
- forward(mask_preds, target_masks, sampled_target_indices, sampled_targets, sampled_proposals)[source]¶
Calculate losses of Mask RCNN head.
- Parameters:
mask_preds (list[torch.Tensor]) – [M, C, H’, W’] mask outputs per batch element.
target_masks (list[torch.Tensor]) – list of [M, H, W] assigned target masks for each proposal.
sampled_target_indices (list[Tensor]) – list of [M, 4] assigned target boxes for each proposal.
sampled_targets (Targets) – list of [M, 4] assigned target boxes for each proposal.
sampled_proposals (Proposals) – list of [M, 4] assigned target boxes for each proposal.
- Returns:
mask loss.
- Return type: