pretrained-yolo-v4

所属分类:模式识别(视觉/语音等)
开发工具:matlab
文件大小:3954KB
下载次数:3
上传日期:2023-05-23 09:27:06
上 传 者sh-1993
说明:  在MATLAB中使用预处理的YOLOv4模型进行目标检测和转移学习。
(Object detection and transfer learning using pretrained YOLO v4 models in MATLAB.)

文件列表:
.circleci (0, 2023-05-23)
.circleci\config.yml (519, 2023-05-23)
LICENSE (1486, 2023-05-23)
SECURITY.md (388, 2023-05-23)
codegenYOLOv4.m (2351, 2023-05-23)
detectYOLOv4.m (1525, 2023-05-23)
images (0, 2023-05-23)
images\network.png (20214, 2023-05-23)
images\result.png (355238, 2023-05-23)
models (0, 2023-05-23)
src (0, 2023-05-23)
src\+helper (0, 2023-05-23)
src\+helper\applyActivations.m (378, 2023-05-23)
src\+helper\applyAnchorBoxOffsets.m (536, 2023-05-23)
src\+helper\augmentData.m (1116, 2023-05-23)
src\+helper\coco-classes.txt (624, 2023-05-23)
src\+helper\configureTrainingProgressPlotter.m (385, 2023-05-23)
src\+helper\createBatchData.m (1017, 2023-05-23)
src\+helper\displayLossInfo.m (552, 2023-05-23)
src\+helper\downloadPretrainedYOLOv4.m (1148, 2023-05-23)
src\+helper\extractPredictions.m (1626, 2023-05-23)
src\+helper\generateTargets.m (7095, 2023-05-23)
src\+helper\generateTiledAnchors.m (534, 2023-05-23)
src\+helper\getAnchors.m (720, 2023-05-23)
src\+helper\getCOCOClassNames.m (955, 2023-05-23)
src\+helper\piecewiseLearningRateWithWarmup.m (1158, 2023-05-23)
src\+helper\postprocess.m (3352, 2023-05-23)
src\+helper\preprocess.m (306, 2023-05-23)
src\+helper\preprocessData.m (597, 2023-05-23)
src\+helper\updatePlots.m (306, 2023-05-23)
src\+helper\validateInputData.m (2969, 2023-05-23)
src\+helper\yolov4Forward.m (656, 2023-05-23)
src\+layer (0, 2023-05-23)
src\+layer\mishLayer.m (595, 2023-05-23)
src\+layer\sliceLayer.m (1197, 2023-05-23)
src\+loss (0, 2023-05-23)
... ...

# Pretrained YOLO v4 Network For Object Detection This repository provides a pretrained YOLO v4[1] object detection network for MATLAB®. Requirements ------------ - MATLAB® R2021a or later - Deep Learning Toolbox™ - Computer Vision Toolbox™ Overview -------- Object detection is a computer vision technique used for locating instances of objects in images or videos. YOLO v4 is a popular single stage object detector that performs detection and classification using CNNs. The YOLO v4 network is composed of a backbone feature extraction network and detection heads for the localization of objects in an image. This repository implements two variants of the YOLO v4 object detectors: - YOLOv4-coco: Standard YOLOv4 network trained on COCO dataset. - YOLOv4-tiny-coco: Lightweight YOLOv4 network trained on COCO dataset. The pretrained networks are trained to detect different object categories including person, car, traffic light, etc. These networks are trained using COCO 2017[2] which have 80 different object categories. For more information about object detection, see [Getting Started with Object Detection Using Deep Learning](https://www.mathworks.com/help/vision/ug/getting-started-with-object-detection-using-deep-learning.html). Getting Started --------------- Download or clone this repository to your machine and open it in MATLAB®. ### Setup Add path to the source directory. ``` addpath('src'); ``` ### Download the pretrained network Use the below helper to download the YOLO v4 pretrained models. Use "YOLOv4-coco" model name for selecting standard YOLO v4 pretrained network and "YOLOv4-tiny-coco" model name for tiny YOLO v4 network. ``` modelName = 'YOLOv4-coco'; model = helper.downloadPretrainedYOLOv4(modelName); net = model.net; ``` Detect Objects Using Pretrained YOLO v4 --------------------------------------- ``` % Read test image. image = imread('visionteam.jpg'); % Get classnames of COCO dataset. classNames = helper.getCOCOClassNames; % Get anchors used in training of the pretrained model. anchors = helper.getAnchors(modelName); % Detect objects in test image. executionEnvironment = 'auto'; [bboxes, scores, labels] = detectYOLOv4(net, image, anchors, classNames, executionEnvironment); % Visualize detection results. annotations = string(labels) + ": " + string(scores); image = insertObjectAnnotation(image, 'rectangle', bboxes, annotations); figure, imshow(image) ``` ![alt text](images/result.png?raw=true) Choosing a Pretrained YOLO v4 Object Detector --------------------------------------------- | Model | Input image resolution | mAP | Size (MB) | Classes | | ------ | ------ | ------ | ------ | ------ | | YOLOv4-coco | 608 x 608 | 44.2 | 229 | [coco class names](src/+helper/coco-classes.txt) | | YOLOv4-tiny-coco | 416 x 416 | 19.7 | 21.5 | [coco class names](src/+helper/coco-classes.txt) | - mAP for models trained on the COCO dataset is computed as average over IoU of .5:.95. Train Custom YOLO v4 Using Transfer Learning ---------------------------------------------------- Transfer learning enables you to adapt a pretrained YOLO v4 network to your dataset. Create a custom YOLO v4 network for transfer learning with a new set of classes and train using the `yolov4TransferLearn.m` script. Code Generation for YOLO v4 ----------------------------------- Code generation enables you to generate code and deploy YOLO v4 on multiple embedded platforms. Run `codegenYOLOv4.m`. This script calls the `yolov4Predict.m` entry point function and generate CUDA code for YOLOv4-coco or YOLOv4-tiny-coco models. It will run the generated MEX and give output. | Model | Input image resolution | Speed(FPS) with Codegen| Speed(FPS) w/o Codegen | | ------ | ------ | ------ | ------ | | YOLOv4-coco | 608 x 608 | 14.025 | 1.18 | | YOLOv4-tiny-coco | 416 x 416 | 49.309 | 9.46 | - Performance (in FPS) is measured on a TITAN-RTX GPU. For more information about codegen, see [Deep Learning with GPU Coder](https://www.mathworks.com/help/gpucoder/gpucoder-deep-learning.html) YOLO v4 Network Details ----------------------- YOLO v4 network architecture is comprised of three sections i.e. Backbone, Neck and Detection Head. ![alt text](images/network.png?raw=true) - **Backbone:** CSP-Darknet53(Cross-Stage-Partial Darknet53) is used as the backbone for YOLO v4 networks. This is a model with a higher input resolution (608 x 608), a larger receptive field size (725 x 725), a larger number of 3 x 3 convolutional layers and a larger number of parameters. Larger receptive field helps to view the entire objects in an image and understand the contexts around those. Higher input resolution helps in detection of small sized objects. Hence, CSP-Darknet53 is a suitable backbone for detecting multiple objects of different sizes in a single image. - **Neck:** This section comprised of many bottom-up and top-down aggregation paths. It helps to increase the receptive field further in the network and separates out the most significant context features and causes almost no reduction of the network operation speed. SPP (Spatial Pyramid Pooling) blocks have been added as neck section over the CSP-Darknet53 backbone. PANet (Path Aggregation Network) is used as the method of parameter aggregation from different backbone levels for different detector levels. - **Detection Head**: This section processes the aggregated features from the Neck section and predicts the Bounding boxes, Objectness score and Classification scores. This follows the principle of one-stage anchor based object detector. 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 The MathWorks, Inc.

近期下载者

相关文件


收藏者