Main Content

yoloxObjectDetector

Detect objects using YOLOX object detector

Since R2023b

Description

The yoloxObjectDetector object creates a You Only Look Once X (YOLOX) one-stage, real-time, anchor-free object detector for detecting objects in an image of arbitrary size. Using this object, you can:

  • Create a pretrained YOLOX object detector by using YOLOX deep learning networks trained on the COCO data set.

  • Create a custom YOLOX object detector by using a pretrained or untrained YOLOX deep learning network.

Note

This functionality requires Deep Learning Toolbox™ and the Automated Visual Inspection Library for Computer Vision Toolbox™. You can install the Automated Visual Inspection Library for Computer Vision Toolbox from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

Creation

Description

detector = yoloxObjectDetector creates a YOLOX object detector trained to detect 80 object classes from the COCO data set using a CSP-Darknet-53 network.

detector = yoloxObjectDetector(name) creates a pretrained YOLOX object detector by using YOLOX deep learning networks trained on the COCO data set.

example

detector = yoloxObjectDetector(name,classes) creates a pretrained YOLOX object detector and configures it to perform transfer learning using a specified set of object classes. For optimal results, you must train the detector on new training images before performing detection.

Use the trainYOLOXObjectDetector function to train the detector before performing object detection.

detector = yoloxObjectDetector(___,Name=Value) sets the ModelName and InputSize properties of the object, and specifies the NormalizationStatistics of the detector, using name-value arguments in addition to any combination of input arguments from previous syntaxes. For example, ModelName="customDetector" sets the name of the object detector to "customDetector".

Input Arguments

expand all

Name of the pretrained YOLOX deep learning network, created using a CSP-DarkNet-53 as the base network and trained on the COCO data set [1], specified as one of these values.

  • "nano-coco" — Pretrained YOLOX-nano deep learning network with fewest filters and fewest convolutional layers. Use YOLOX-nano when you have few available computational resources and require the fastest performance speed and real-time inference.

  • "tiny-coco" — Pretrained YOLOX-tiny deep learning network. Use YOLOX-tiny for slightly less constrained real-time applications with an improvement in accuracy from YOLOX-nano.

  • "small-coco" — Pretrained YOLOX-small deep learning network. Use YOLOX-small for a higher level of accuracy than YOLOX-tiny when moderate computational resources are available.

  • "medium-coco" — Pretrained YOLOX-medium deep learning. Use YOLOX-medium for a higher level of accuracy than YOLOX-small when some computational resources (e.g. GPU hardware) are available.

  • "large-coco" — Pretrained YOLOX-large deep learning network with the largest number of filters and convolutional layers. Use the YOLOX-large network for the highest level accuracy of object detection at the expense of computational cost and speed.

Tip

To improve accuracy and performance of complex detection tasks, increase the pretrained model size at the expense of decreased inference speed, larger computation time, and greater memory requirements. Use YOLOX-nano for real-time inference at the expense of detection accuracy. Use YOLOX-tiny and YOLOX-small for near-real time applications due to fast inference. Use YOLOX-medium and YOLOX-large when sufficient computational resources are available for the largest accuracy, at the expense of lower computation speeds.

Data Types: char | string

Names of object classes for training the detector, specified as a vector of strings, cell array of character vectors, or categorical vector. This argument sets the ClassNames property of the yoloxObjectDetector object.

Data Types: char | string | categorical

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: yoloxObjectDetector(detector,classes,ModelName="customDetector") sets the name for the object detector to "customDetector".

Name for the object detector, specified as a character vector or string scalar.

Image size used for training the object detector, specified as a row vector [H W C], where H, W, and C correspond to the height, width, and number of channels, respectively. The default is the network input size.

Z-score normalization statistics, specified as a structure with these fields, which contain the values from the COCO data set:

FieldDescriptionDefault Value
Mean1-by-C vector of means per channel.[123.6750 116.2800 103.5300]
StandardDeviation1-by-C vector of standard deviations per channel.[58.3950 57.1200 57.3750]

The number of channels C must match the number of channels in the image specified by InputSize.

Properties

expand all

This property is read-only.

Name for the object detector, stored as a character vector or string scalar. To set this property, specify it at object creation.

This property is read-only.

Names of object classes to detect, stored as a categorical vector. To set this property, use the classes argument at object creation.

This property is read-only.

Image size used for training and inference, stored as a row vector of integers, of the form [height width channels]. To set this property, specify it at object creation.

Object Functions

detectDetect objects using YOLOX object detector

Examples

collapse all

Specify the name of a pretrained YOLOX deep learning network.

networkName = "small-coco"
networkName = 
"small-coco"

Create a YOLOX object detector by using the pretrained YOLOX network.

detector = yoloxObjectDetector(networkName);

Display and inspect the properties of the YOLOX object detector.

disp(detector)
  yoloxObjectDetector with properties:

                 ClassNames: {80x1 cell}
                  InputSize: [640 640 3]
    NormalizationStatistics: [1x1 struct]
                  ModelName: 'small-coco'

Detect objects in a chosen image.

I = imread("carsonroad.png");
[bboxes,scores,labels] = detect(detector,I);

Display the detection results.

detectedImg = insertObjectAnnotation(I,"Rectangle",bboxes,labels);
figure
imshow(detectedImg)

Figure contains an axes object. The hidden axes object contains an object of type image.

References

[1] Ge, Zheng, Songtao Liu, Feng Wang, Zeming Li, and Jian Sun. “YOLOX: Exceeding YOLO Series in 2021.” arXiv, August 5, 2021. http://arxiv.org/abs/2107.08430.

Extended Capabilities

Version History

Introduced in R2023b

expand all