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 Computer Vision Toolbox™ Automated Visual Inspection Library. You can install the Computer Vision Toolbox Automated Visual Inspection Library 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.

example

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

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, specified as one of these:

  • "small-coco" — A pretrained YOLOX deep learning network created using CSP-DarkNet-53 as the base network and trained on the COCO data set.

  • "tiny-coco" — A pretrained YOLOX deep learning network created using a smaller CSP-DarkNet-53 with fewer filters as the base network and trained on the COCO data set.

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)

Extended Capabilities

Version History

Introduced in R2023b