Skip to content

matlab-deep-learning/Object-Detection-Using-Pretrained-YOLO-v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pretrained YOLO v2 For Object Detection

This repository implements pretrained YOLO v2 [1] object detectors in MATLAB. Open in MATLAB Online

Creator: MathWorks Development

Requirements

  • MATLAB® R2020a or later
  • Deep Learning Toolbox™
  • Computer Vision Toolbox™
  • Computer Vision Toolbox™ Model for YOLO v2 Object Detection

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

Getting Started

Getting Started with YOLO v2

Detect Objects Using Pretrained YOLO v2

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 v2 Object Detection. You can install the Computer Vision Toolbox for YOLO v2 Object Detection from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

% Load pretrained detector
modelName = 'tiny-yolov2-coco';
detector = yolov2ObjectDetector(name);

% Read test image.
img = imread('sherlock.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 v2 Object Detector

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

Model mAP Size (MB) Classes Speed in Frames Per Second (FPS)
Darknet19-COCO 28.7 181 coco class names 17.8
Tiny-YOLO_v2-COCO 10.5 40 coco class names 32
  • Performance (in FPS) is measured on a TITAN-XP machine using:
    • 608x608 image for Darknet19-COCO.
    • 416x416 image for Tiny-YOLO_v2-COCO.
  • mAP for models trained on the COCO dataset is computed as average over IoU of .5:.95.

Train Custom YOLO v2 Detector Using Transfer Learning

To train a YOLO v2 object detection network on a labeled data set, use the trainYOLOv2ObjectDetector 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 trainYOLOv2ObjectDetector function. The training function returns the trained network as a yolov2ObjectDetector object.

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

Code Generation

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

YOLO v2 Algorithm Details

YOLO v2 is a popular single stage object detectors that performs detection and classification using CNNs. The YOLO v2 network is composed of a backbone feature extraction network and a detection head for the localization of objects in an image. For more information about YOLO v2, see Getting Started with YOLO v2.

alt text

References

[1] Redmon, Joseph, and Ali Farhadi. "YOLO9000: better, faster, stronger." Proceedings of the IEEE conference on computer vision and pattern recognition. 2017.

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

[3] The PASCAL Visual Object Classes Challenge: A Retrospective Everingham, M., Eslami, S. M. A., Van Gool, L., Williams, C. K. I., Winn, J. and Zisserman, A. International Journal of Computer Vision, 111(1), 98-136, 2015.

Copyright 2021 - 2024 The MathWorks, Inc.