Home

Awesome

Pretrained YOLO v4 Network For Object Detection

This repository provides a pretrained YOLO v4[1] object detection network for MATLAB®. Open in MATLAB Online

Creator: MathWorks Development

Requirements

Note: Previous MATLAB® release users can use this branch to download the pretrained models.

Getting Started

Getting Started with YOLO v4

Detect Objects Using Pretrained YOLO v4

Use to code below to perform detection on an example image using the pretrained model.

Note: This functionality requires Deep Learning Toolbox™ and the Computer Vision Toolbox™ for YOLO v4 Object Detection. You can install the Computer Vision Toolbox for YOLO v4 Object Detection from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

% Load pretrained detector
modelName = 'csp-darknet53-coco';
detector = yolov4ObjectDetector(name);

% Read test image.
image = imread('visionteam.jpg');

% Detect objects in the test image.
[boxes, scores, labels] = detect(detector, img);

% Visualize detection results.
img = insertObjectAnnotation(img, 'rectangle', bboxes, scores);
figure, imshow(img)

alt text

Choosing a Pretrained YOLO v4 Object Detector

You can choose the ideal YOLO v4 object detector for your application based on the below table:

ModelInput image resolutionmAPSize (MB)Classes
YOLOv4-coco608 x 60844.2229coco class names
YOLOv4-tiny-coco416 x 41619.721.5coco class names

Train Custom YOLO v4 Detector Using Transfer Learning

To train a YOLO v4 object detection network on a labeled data set, use the trainYOLOv4ObjectDetector function. You must specify the class names for the data set you use to train the network. Then, train an untrained or pretrained network by using the trainYOLOv4ObjectDetector function. The training function returns the trained network as a yolov4ObjectDetector object.

For more information about training a YOLO v4 object detector, see Object Detection using YOLO v4 Deep Learning Example.

Code Generation for YOLO v4

Code generation enables you to generate code and deploy YOLO v4 on multiple embedded platforms. For more information about generating CUDA® code using the YOLO v4 object detector see Code Generation for Object Detection by Using YOLO v4

YOLO v4 Network Details

YOLO v4 network architecture is comprised of three sections i.e. Backbone, Neck and Detection Head.

alt text

References

[1] Bochkovskiy, Alexey, Chien-Yao Wang, and Hong-Yuan Mark Liao. "YOLOv4: Optimal Speed and Accuracy of Object Detection." arXiv preprint arXiv:2004.10934 (2020).

[2] Lin, T., et al. "Microsoft COCO: Common objects in context. arXiv 2014." arXiv preprint arXiv:1405.0312 (2014).

Copyright 2021 - 2024 The MathWorks, Inc.