vis4d.op.detect.faster_rcnn

Faster RCNN detector.

Classes

FRCNNOut(rpn, roi, proposals, ...)

Faster RCNN function call outputs.

FasterRCNNHead(num_classes[, ...])

This class composes RPN and RCNN head components.

class FRCNNOut(rpn: RPNOut, roi: RCNNOut, proposals: Proposals, sampled_proposals: Proposals | None, sampled_targets: Targets | None, sampled_target_indices: list[torch.Tensor] | None)[source]

Faster RCNN function call outputs.

Create new instance of FRCNNOut(rpn, roi, proposals, sampled_proposals, sampled_targets, sampled_target_indices)

proposals: Proposals

Alias for field number 2

roi: RCNNOut

Alias for field number 1

rpn: RPNOut

Alias for field number 0

sampled_proposals: Proposals | None

Alias for field number 3

sampled_target_indices: list[Tensor] | None

Alias for field number 5

sampled_targets: Targets | None

Alias for field number 4

class FasterRCNNHead(num_classes, anchor_generator=None, rpn_box_decoder=None, box_matcher=None, box_sampler=None, roi_head=None, proposal_append_gt=True)[source]

This class composes RPN and RCNN head components.

It generates proposals via RPN and samples those, and runs the RCNN head on the sampled proposals. During training, the sampling process is based on the GT bounding boxes, during inference it is based on objectness score of the proposals.

Creates an instance of the class.

Parameters:
  • num_classes (int) – Number of object categories.

  • anchor_generator (AnchorGenerator, optional) – Custom generator for RPN. Defaults to None.

  • rpn_box_decoder (DeltaXYWHBBoxDecoder, optional) – Custom rpn box decoder. Defaults to None.

  • box_matcher (Matcher, optional) – Custom box matcher for RCNN stage. Defaults to None.

  • box_sampler (Sampler, optional) – Custom box sampler for RCNN stage. Defaults to None.

  • roi_head (RCNNHead, optional) – Custom ROI head. Defaults to None.

  • proposal_append_gt (bool) – If to append the ground truth boxes for proposal sampling during training. Defaults to True.

__call__(features, images_hw, target_boxes=None, target_classes=None)[source]

Type definition for call implementation.

Return type:

FRCNNOut

forward(features, images_hw, target_boxes=None, target_classes=None)[source]

Faster RCNN forward.

Parameters:
  • features (list[torch.Tensor]) – Feature pyramid.

  • images_hw (list[tuple[int, int]]) – Image sizes without padding. This is necessary for removing the erroneous boxes on the padded regions.

  • target_boxes (None | list[torch.Tensor], optional) – Ground truth bounding box locations. Defaults to None.

  • target_classes (None | list[torch.Tensor], optional) – Ground truth bounding box classes. Defaults to None.

Returns:

Proposal and RoI outputs.

Return type:

FRCNNReturn