主要内容

YOLO Postprocessing

R2026b

Calculates bounding boxes and scores from deep learning network output

Since R2026b

  • YOLO Postprocessing block

Libraries:
Vision HDL Toolbox / DL Postprocessing

Description

The YOLO Postprocessing block accepts reformatted streaming input from a deep learning processor and identifies the best bounding boxes. It returns bounding box coordinates, scores, and class indexes. The block performs non-maximal suppression (NMS) to select the best results. This block supports HDL code generation and allows you to include postprocessing steps on an FPGA.

The diagram shows the postprocessing operation in context of a deep learning (DL) object detection system. First, input images are resized and normalized. Then a deep learning processor detects features. The Reformat DL Processor Output step reads the network results from memory and converts them to a stream of formatted detections. The YOLO postprocessing operation processes the output detections to select the best bounding boxes and the Controller reads the postprocessing results.

The block requires a trained deep learning network to define the protocol and expectations for the input detections. Use the network objects from the Deep Learning Toolbox™ product to provide information about your network to the block.

The input ports of this block are designed to connect to the output ports of the Deep Learning HDL Output Format block, which implements the Reformat DL Processor Output step in the diagram. For more information about this interface, see the Deep Learning HDL Output Format (Deep Learning HDL Toolbox) block reference page.

This waveform shows the output signals and reading the results of the postprocessing. The block sets the rdReady signal to true when postprocessing is complete. The numBboxes output indicates how many bounding boxes met the thresholds. The controller then uses the rdAddr and rdValid signals to read out the bounding box coordinates, and optionally their scores and class indexes. After the results are read, the controller resets the postprocessing block.

Waveform showing the output protocol of the YOLO Postprocessing block

Examples

Ports

Input

expand all

Stream of formatted detection data from the deep learning processor, specified as a single data type scalar. Connect this port to the DataOut port of the Deep Learning HDL Output Format block.

Data Types: single

Indicates that the input detection data is valid, specified as a Boolean scalar. Connect this port to the ValidOut port of the Deep Learning HDL Output Format block.

Data Types: Boolean

Row index of the input detection data, specified as a uint16 data type scalar. Connect this port to the RowIdx port of the Deep Learning HDL Output Format block.

Data Types: uint16

Column index of the input detection data, specified as a uint16 data type scalar. Connect this port to the ColIdx port of the Deep Learning HDL Output Format block.

Data Types: uint16

Depth index of the input detection data, specified as a uint16 data type scalar. Connect this port to the DepthIdx port of the Deep Learning HDL Output Format block.

Data Types: uint16

Output selection index for multiple-output networks, specified as a uint8 data type scalar. Connect this port to the OutputIdx port of the Deep Learning HDL Output Format block.

Data Types: uint8

Control signal that indicates that the read address, rdAddr, for the output bounding boxes, is valid, specified as a Boolean scalar.

Data Types: Boolean

Address of output bounding box, specified as a uint16 scalar. The block returns the count of bounding boxes on the numBboxes port and sets the ready signal to true when postprocessing of the output from the deep learning processor is complete. Read the results by setting rdAddr to values from 1 through the value on numBboxes port.

Data Types: uint16

Reset signal, specified as a Boolean scalar. When this input is true, the block resets internal calculations and starts a new detection.

Data Types: Boolean

Output

expand all

Detected bounding box, returned as a 1-by-4 vector of coordinates, [x,y,h,w]. The block reads this value from the location specified by the rdAddr and rdValid ports. The numBboxes port returns the number of bounding boxes available for read.

Dependencies

This port appears when you select the Bounding boxes checkbox under Output ports.

Data Types: uint16

Bounding box score , returned as a single data type scalar. The block reads this value from the location specified by the rdAddr and rdValid ports.

Dependencies

This port appears when you select the Scores checkbox under Output ports.

Data Types: single

Bounding box class index , returned as a uint16 data type scalar. The block reads this value from the location specified by the rdAddr and rdValid ports.

Dependencies

This port appears when you select the Class indices checkbox under Output ports.

Data Types: uint16

Number of valid detections, returned as a uint8 scalar. The block returns this value and sets the ready signal to true when postprocessing of the output from the deep learning processor is complete. Read the results by setting rdAddr to values from 1 through the value on numBboxes port. The maximum number of detections returned is set by the Maximum number of detections parameter.

Data Types: uint8

Control signal that indicates that the result of the bounding box read specified by rdAddr is available, specified as a Boolean scalar. This valid signal qualifies the bbox, score, and classIndex output ports.

Data Types: Boolean

Control signal that indicates when block calculations are complete. After the block sets this signal to true, you can read the bounding box, score, and class index results from the detection by using the input rdAddr and rdValid ports. The numBboxes port returns the number of bounding boxes available for read.

Data Types: Boolean

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Source of your detector network, specified as one of these options:

  • Detector from MAT-file — When you choose this option, set the File path parameter to the location of a file that contains the definition of a trained YOLO detector network object.

  • Detector from MATLAB function — When you choose this option, set the MATLAB function parameter to the name of a function that is on the path and that returns a trained YOLO detector network object.

The block expects a detector network definition as an object from the Deep Learning Toolbox product, such as the yolov3ObjectDetector or yolov4ObjectDetector objects.

The block supports YOLOv3 or YOLOv4 detectors.

Location of a file that contains the definition of a trained YOLO detector network.

The block supports YOLOv3 or YOLOv4 detectors.

Dependencies

This parameter appears when you set Detector to Detector from MAT-file.

Name of a function that is on the path and that returns a trained YOLO detector network object.

The block supports YOLOv3 or YOLOv4 detectors.

Dependencies

This parameter appears when you set Detector to Detector from MATLAB function.

Outputs

Maximum number of detections selected and returned, specified as an integer value between 4 and 128, inclusive.

When you select this option, the bbox port appears on the block.

When you select this option, the score port appears on the block.

When you select this option, the classIndex port appears on the block.

Advanced

Confidence threshold, specified as a value between 0 and 1, inclusive. The block uses this value to select relevant bounding boxes.

Threshold to detect overlap, specified as a value between 0 and 1, inclusive. The non-maximal suppression (NMS) algorithm finds overlapping boxes, and uses this value to select the box with the highest confidence metric from those with overlap.

Number of strongest regions to pass to the non-maximal suppression (NMS) algorithm, specified as an integer value between 4 and 4096, inclusive. The block implements a FIFO that stores the bounding boxes that pass the confidence threshold. If you specify a higher confidence threshold, you can reduce the size of this FIFO. If you specify a low confidence threshold, you may need to increase the size of this FIFO.

Tips

Algorithms

This diagram shows a high level view of the postprocessing steps.

YOLO Postprocessing algorithm architecture diagram

The YOLO Transform step applies sigmoid and exp activations to convert the processor output into a confidence score, [x, y, width, height] coordinates relative to an anchor box, and a class probability for each detection. The Generate Anchor Boxes step converts the relative coordinates to bounding box coordinates. The Reshape Indices step reshapes the detection metrics so the algorithm can combine and compare detections from different detection heads. The Generate Bounding Boxes step applies the confidence threshold to select the strongest boxes. The Non-Maximal Suppression step calculates the intersection-over-union (IOU) for overlapping boxes. IOU is the areaOfIntersection/areaOfUnion. To select the strongest boxes, NMS compares the IOU against the overlap threshold, similar to the Computer Vision Toolbox™ selectStrongestBbox (Computer Vision Toolbox) function.

Extended Capabilities

expand all

Version History

Introduced in R2026b

See Also

(Deep Learning HDL Toolbox)