Main Content

forward

Run forward pass on Mask R-CNN network

Since R2021b

Description

[dlRPNScores,dlRPNReg,dlProposals,dlBoxScores,dlBoxReg,dlMasks] = forward(detector,dlX) calculates features of the image dlX from the output layers of the Mask R-CNN object detector.

example

[dlRPNScores,dlRPNReg,dlProposals,dlBoxScores,dlBoxReg,dlMasks,state] = forward(detector,dlX) also returns the state information of the network. Use the state to update the network parameters.

Note

This function requires the Computer Vision Toolbox™ Model for Mask R-CNN Instance Segmentation. You can install the Computer Vision Toolbox Model for Mask R-CNN Instance Segmentation from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons. To run this function, you will require the Deep Learning Toolbox™.

Examples

collapse all

Load a pretrained Mask R-CNN object detector.

detector = maskrcnn("resnet50-coco");

Read an image to use for training, and convert the image to a formatted dlarray object.

I = imread("visionteam.jpg");
dlX = dlarray(single(I),"SSCB"); 

Calculate features of the training image.

[dlRPNScores,dlRPNReg,dlProposals,dlBoxScores,dlBoxReg,dlMasks] = forward(detector,dlX);

Input Arguments

collapse all

Mask R-CNN object detector, specified as a maskrcnn object.

Training data, specified as a formatted dlarray (Deep Learning Toolbox) object containing real, nonsparse data. The dimension labels of the data must be "SSCB".

Output Arguments

collapse all

RPN classification output after the softmax operation, returned as a dlarray object of size h-by-w-by-numAnchors-by-B. The feature map has spatial size h-by-w. B is the number of images in the batch.

RPN regression output, returned as a dlarray object of size h-by-w-by-(4⁢×numAnchors)-by-B. The feature map has spatial size h-by-w. B is the number of images in the batch.

Region proposals, returned as a dlarray object of size 5-by-numProposals-by-1-by-1. Each column of the proposals contains a box proposal in the format [xStart, yStart, xEnd, yEnd, batchIdx].

Detection network classification output after the softmax operation, returned as a dlarray object of size 1-by-1-by-(numClasses+1)-by-numProposals.

Detection network regression output, returned as a dlarray object of size 1-by-1-by-(4×numClasses)-by-numProposals.

Mask segmentation output, returned as a dlarray object of size hmask-by-wmask-by-numClasses-by-numProposals. The mask segmentation output has spatial size hmask-by-wmask.

Updated network state, returned as a table. The network state is a table with three columns:

  • Layer – Layer name, returned as a string scalar.

  • Parameter – Parameter name, returned as a string scalar.

  • Value – Value of parameter, returned as a numeric array object.

The network state contains information remembered by the network between iterations.

Version History

Introduced in R2021b

expand all