An improved yolov5-based high-precision target detection method and system

By improving the YOLOv5 network and introducing multi-scale feature fusion and self-attention modules, the problems of inaccurate small target detection and inaccurate large target localization in YOLOv5 are solved, and high-precision target detection is achieved.

CN116452948BActive Publication Date: 2026-02-17ISA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310389885.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-12
Publication Date
2026-02-17
Estimated Expiration
2043-04-12

AI Technical Summary

Technical Problem

YOLOv5 suffers from low accuracy in detecting small targets and poor accuracy in locating large targets due to the small receptive field of the convolutional neural network.

Method used

By improving the YOLOv5 network, a multi-scale feature fusion module and a prediction module are introduced. Deformable convolutional layers are used to improve the detection accuracy of small targets, and a self-attention module is added to increase the receptive field of large targets to improve localization accuracy.

Benefits of technology

It achieves accurate detection of small targets and high-precision positioning of large targets, thus improving the overall detection effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116452948B_ABST
    Figure CN116452948B_ABST
Patent Text Reader

Abstract

The application discloses a high-precision target detection method and system based on an improved yolov5, and comprises the following steps: obtaining a target image to be detected; obtaining a target detection result according to the target image to be detected and a trained target detection model, wherein the target detection model comprises a backbone network module, a multi-scale feature fusion module and a prediction module, the backbone network module takes the target image as input and outputs feature maps of different levels; the multi-scale feature fusion module performs feature fusion on the feature maps of different levels to obtain multi-scale feature maps; and the prediction module performs small target detection on large-scale feature maps in the multi-scale feature maps to obtain a small target detection result, and performs large target detection on small-scale feature maps in the multi-scale feature maps to obtain a large target detection result. The detection accuracy of small target objects and the positioning accuracy of large target objects are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of target detection technology, and in particular to a high-precision target detection method and system based on an improved YOLOv5. Background Technology

[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.

[0003] High-precision object detection algorithms have significant applications across various fields. In intelligent vision systems, these algorithms enable accurate and rapid detection and localization of objects in images or videos, thereby improving the performance of the vision system and making it more reliable and practical in areas such as autonomous driving, video surveillance, intelligent security, and robotics. In autonomous driving, high-precision object detection algorithms can accurately detect and locate obstacles such as pedestrians and vehicles, thus improving driving safety. In video surveillance and intelligent security, these algorithms can help monitoring systems promptly detect and alert on abnormal events. The development of high-precision object detection algorithms has significant practical implications and far-reaching prospects, and will be widely applied in multiple fields.

[0004] Object detection technology, as one of the research tasks in the field of computer vision, has achieved a series of excellent research results after years of development and has been widely applied in fields such as video surveillance, safety production, and intelligent manufacturing. The task of object detection in video images is to locate the target objects to be detected in the image and identify the category of the target objects. YOLOv5 is one of the most popular and widely used object detection algorithms, with a significant advantage in detection speed; its inference speed can reach real-time levels, making it suitable for some real-time application scenarios requiring efficient processing. This algorithm further improves detection accuracy by introducing some new technologies, enabling it to detect more targets and achieve more accurate localization and classification results. It has been verified and applied in many practical applications, becoming an important algorithm in the field of object detection.

[0005] The inventors believe that although YOLOv5 employs techniques such as multi-scale detection and multi-label prediction to improve its ability to detect small targets, its accuracy in detecting small targets remains low. Furthermore, the algorithm is based on convolutional neural networks, which suffer from a small receptive field, leading to poor localization accuracy for larger targets in the scene. Summary of the Invention

[0006] To address the aforementioned problems, this invention proposes a high-precision target detection method and system based on an improved YOLOv5, which enhances the accuracy of identifying small targets and the positioning accuracy of large targets.

[0007] To achieve the above objectives, the present invention adopts the following technical solution:

[0008] Firstly, a high-precision target detection method based on an improved YOLOv5 is proposed, including:

[0009] Acquire the target image to be detected;

[0010] Based on the target image to be detected and the trained target detection model, the target detection result is obtained. The target detection model is constructed using an improved YOLOv5 network, which includes a backbone network module, a multi-scale feature fusion module, and a prediction module. The backbone network module takes the target image as input and outputs feature maps at different levels. The multi-scale feature fusion module fuses features from different levels to obtain multi-scale feature maps. The prediction module performs small target detection on the large-scale feature maps in the multi-scale feature maps to obtain small target detection results, and performs large target detection on the small-scale feature maps in the multi-scale feature maps to obtain large target detection results.

[0011] Secondly, a high-precision target detection system based on an improved YOLOv5 is proposed, including:

[0012] The image acquisition module is used to acquire the target image to be detected;

[0013] The object detection module is used to obtain object detection results based on the target image to be detected and the trained object detection model. The object detection model is constructed using an improved YOLOv5 network, which includes a backbone network module, a multi-scale feature fusion module, and a prediction module. The backbone network module takes the target image as input and outputs feature maps at different levels. The multi-scale feature fusion module fuses features from different levels to obtain multi-scale feature maps. The prediction module performs small object detection on the large-scale feature maps in the multi-scale feature maps to obtain small object detection results, and performs large object detection on the small-scale feature maps in the multi-scale feature maps to obtain large object detection results.

[0014] Thirdly, an electronic device is proposed, including a memory and a processor, as well as computer instructions stored in the memory and running on the processor, which, when executed by the processor, complete the steps described in a high-precision target detection method based on an improved YOLOv5.

[0015] Fourthly, a computer-readable storage medium is proposed for storing computer instructions, which, when executed by a processor, complete the steps described in a high-precision target detection method based on an improved YOLOv5.

[0016] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0017] 1. This invention achieves accurate detection of small targets by performing small target detection on large-scale feature maps and large target detection on small-scale feature maps.

[0018] 2. The convolutional layer in the high-resolution prediction branch of this invention is a deformable convolutional layer, which improves its feature extraction capability for small targets and thus improves its accuracy in detecting small targets; a visual self-attention module is added to the low-resolution prediction branch to increase the visual receptive field of the branch and thus improve its localization accuracy for large targets.

[0019] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0020] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.

[0021] Figure 1 This is a flowchart of the method disclosed in Example 1. Detailed Implementation

[0022] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0023] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.

[0024] Example 1

[0025] In this embodiment, a high-precision target detection method based on an improved YOLOv5 is disclosed, such as... Figure 1 As shown, it includes:

[0026] S1: Obtain the target image to be detected.

[0027] When it is necessary to perform object detection on a video, the video to be identified is acquired, and keyframes are extracted from the video to be identified. Each keyframe image is a target image to be detected.

[0028] S2: Based on the target image to be detected and the trained target detection model, the target detection result is obtained. The target detection model is constructed using an improved YOLOv5 network, which includes a backbone network module, a multi-scale feature fusion module, and a prediction module. The backbone network module takes the target image as input and outputs feature maps at different levels. The multi-scale feature fusion module fuses features from different levels to obtain multi-scale feature maps. The prediction module performs small target detection on the large-scale feature maps in the multi-scale feature maps to obtain small target detection results, and performs large target detection on the small-scale feature maps in the multi-scale feature maps to obtain large target detection results.

[0029] The target detection model in this embodiment takes the target image as input and the target detection result as output, and is constructed using an improved YOLOv5 network.

[0030] The improved YOLOv5 network is obtained by modifying the existing YOLOv5 network structure. The YOLOv5 network includes a backbone network module, a multi-scale feature fusion module, and a prediction module. The backbone network module adopts the CSPNet (CrossStage Partial Network), a highly efficient network structure that effectively reduces the number of parameters and computational cost while maintaining network accuracy. The backbone network module takes the target image as input and extracts features from the input target image to obtain feature maps at different levels.

[0031] The multi-scale feature fusion module fuses feature maps at different levels output by the backbone network module, improving the model's feature representation ability and the accuracy of target detection, and obtaining multi-scale feature maps.

[0032] In practice, the multi-scale feature fusion module outputs feature maps at three different scales.

[0033] In multi-scale feature maps, feature maps with a scale greater than a set scale threshold are called large-scale feature maps, and feature maps with a scale less than or equal to the set scale threshold are called small-scale feature maps.

[0034] The multi-scale feature map is input into the prediction module, where the prediction module detects the target in the multi-scale feature map to predict the target's location and category, thus obtaining the target detection result.

[0035] This embodiment uses the backbone network module and multi-scale feature fusion module in the YOLOv5 network to improve the prediction module in the YOLOv5 network, thus obtaining an improved YOLOv5 network.

[0036] The improved YOLOv5 network's prediction module includes a high-resolution prediction branch and a low-resolution prediction branch. The high-resolution prediction branch takes a large-scale feature map as input and outputs a small target detection result; the low-resolution prediction branch takes a small-scale feature map as input and outputs a large target detection result; both the high-resolution prediction branch and the low-resolution prediction branch use convolutional neural networks.

[0037] Specifically, the high-resolution prediction branch and the low-resolution prediction branch are composed of multiple convolutional layers connected in sequence. The feature map of each prediction branch is input to multiple convolutional layers for multi-layer convolution operations to extract features from the input feature map. The features extracted by the convolutional layers are then convolved by multiple 1×1 convolutional kernels in the last convolutional layer to obtain the target detection result.

[0038] In this embodiment, a small target refers to a target with a size less than or equal to a set size, and a large target refers to a target with a size greater than a set size.

[0039] Since small targets in images have less semantic feature information, to improve the model's feature extraction capability for small targets, this embodiment uses deformable convolutional layers in the high-resolution prediction branch. Deformable convolution adds an offset variable to the position of each sampling point in the convolution kernel, allowing for arbitrary sampling near the current position without being limited to the previous N×N square shape. When the target is small, this dynamic convolution calculation method can better extract information about small targets. The calculation method of deformable convolution is expressed as follows:

[0040]

[0041] In the formula, p0 represents the center point of the convolution kernel, p n It is each offset of p0 within the convolution kernel range, Δp n Let y(p0) be the offset of each point in the feature map, generated by another convolution operation in the deformable convolutional layer with the input features, and w(p0) be the output feature value of the convolution kernel. n ) represents p in the convolution kernel n Position parameters.

[0042] Large targets in images often occupy a large area, while convolutional neural networks suffer from a small receptive field. Therefore, for the low-resolution prediction branch in the prediction module that detects large targets, this embodiment adds two serial self-attention modules at its input to increase the receptive field of feature calculation and result prediction for this branch.

[0043] Specifically, the small-resolution prediction branch includes two sequential self-attention modules and a convolutional neural network. The small-scale feature map is input into the first self-attention module, the output of the first self-attention module is input into the second self-attention module, and the output of the second self-attention module is input into the convolutional neural network.

[0044] Each self-attention module divides the input feature map into feature blocks, obtaining multiple one-dimensional feature blocks of the same size. Self-attention and fully connected computations are performed on all one-dimensional feature blocks to output a feature map with a global receptive field.

[0045] A detailed explanation of the small-resolution prediction branch is provided.

[0046] Because the input feature scale of the small-resolution prediction branch is small, a patch operation is performed on the input feature map through a self-attention module. This patch operation flattens the feature blocks spatially, reconstructing a feature block with height H, width W, and number of channels C into H×W one-dimensional feature blocks of dimension C. The reconstructed one-dimensional feature blocks are then weighted with their positional encoding information and subjected to self-attention and fully connected layer calculations in the self-attention module. Finally, the output of the second self-attention module serves as the input to the convolutional network in the small-resolution prediction branch for predicting subsequent object detection results. The prediction branch convolutional network consists of multiple convolutional layers connected sequentially, with the last 1×1 convolutional layer predicting the object detection result. The self-attention calculation formula for this process is expressed as:

[0047]

[0048] In the formula, Attention represents the result of self-attention calculation, which is a feature map with a global receptive field; Q, K, V are three one-dimensional vectors of the same size obtained by fully connecting each one-dimensional feature block of the input; and d k Let K be the length of the one-dimensional vector K, and T denote the transpose of the one-dimensional vector matrix K. The calculation process of the Softmax operation is as follows: Map multiple input nodes to real numbers between 0 and 1, and sum all outputs to 1, where Z i Let represent the value of the i-th input node, and C represent the total number of input nodes.

[0049] This embodiment constructs an object detection model using an improved YOLOv5 network and obtains a large number of training object images. The target locations and IDs of the training object images are labeled, and a training dataset is constructed using the labeled training object images.

[0050] The constructed object detection model is trained using the training dataset, and the trained object detection model is obtained after training.

[0051] The target detection model constructed in this embodiment uses loss functions including target detection loss, category loss, and bounding box loss.

[0052] Among them, the Object Detection Loss is a loss function used to calculate the difference between the predicted bounding box and the ground truth bounding box, as well as the difference between the confidence scores of the predicted bounding box and the ground truth bounding box.

[0053] Classification Loss is a loss function used to calculate the difference between the predicted class of an object in the prediction box and the true class.

[0054] Boundary Box Regression Loss is a loss function used to calculate the positional differences between the predicted bounding box and the ground truth bounding box, that is, the differences between the center point coordinates, width, and height of the predicted bounding box and the center point coordinates, width, and height of the ground truth bounding box.

[0055] This embodiment discloses a method that performs small target detection on a large-scale feature map to obtain small target detection results, and performs large target detection on a small-scale feature map to obtain large target detection results. This achieves accurate detection of both large and small targets. Furthermore, the convolutional layer in the large-resolution prediction branch disclosed in this embodiment is a deformable convolutional layer, which improves its feature extraction capability for small targets, thereby improving the accuracy of small target detection. A visual self-attention module is added to the small-resolution prediction branch to increase the visual receptive field of this branch, thereby improving its localization accuracy for large targets.

[0056] This embodiment improves the prediction module of YOLOv5, thereby increasing the model's detection accuracy for small objects and the localization accuracy for large objects.

[0057] Example 2

[0058] In this embodiment, a high-precision target detection system based on an improved YOLOv5 is disclosed, comprising:

[0059] The image acquisition module is used to acquire the target image to be detected;

[0060] The object detection module is used to obtain object detection results based on the target image to be detected and the trained object detection model. The object detection model is constructed using an improved YOLOv5 network, which includes a backbone network module, a multi-scale feature fusion module, and a prediction module. The backbone network module takes the target image as input and outputs feature maps at different levels. The multi-scale feature fusion module fuses features from different levels to obtain multi-scale feature maps. The prediction module performs small object detection on the large-scale feature maps in the multi-scale feature maps to obtain small object detection results, and performs large object detection on the small-scale feature maps in the multi-scale feature maps to obtain large object detection results.

[0061] Example 3

[0062] In this embodiment, an electronic device is disclosed, including a memory and a processor, as well as computer instructions stored in the memory and running on the processor. When the processor executes the computer instructions, it performs the steps described in the high-precision target detection method based on an improved YOLOv5 disclosed in Embodiment 1.

[0063] Example 4

[0064] In this embodiment, a computer-readable storage medium is disclosed for storing computer instructions, which, when executed by a processor, complete the steps described in the high-precision target detection method based on an improved YOLOv5 disclosed in Embodiment 1.

[0065] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. An improved yolov5-based high-precision target detection method, characterized in that, The method comprises the steps of: obtaining a target image to be detected; obtaining a target detection result according to the target image to be detected and a trained target detection model, wherein the target detection model is obtained by an improved yolov5 network, the improved yolov5 network comprises a backbone network module, a multi-scale feature fusion module and a prediction module, the backbone network module takes the target image as input and outputs feature maps of different levels; the multi-scale feature fusion module performs feature fusion on the feature maps of different levels to obtain multi-scale feature maps; the prediction module performs small target detection on large-scale feature maps in the multi-scale feature maps to obtain a small target detection result, and performs large target detection on small-scale feature maps in the multi-scale feature maps to obtain a large target detection result; the prediction module comprises a large-resolution prediction branch and a small-resolution prediction branch, the large-resolution prediction branch takes the large-scale feature maps as input and outputs the small target detection result; the small-resolution prediction branch takes the small-scale feature maps as input and outputs the large target detection result; the large-resolution prediction branch and the small-resolution prediction branch both adopt a convolutional neural network; the convolutional layer in the large-resolution prediction branch is a deformable convolutional layer; the small-resolution prediction branch comprises two serial self-attention modules and a convolutional neural network, the small-scale feature maps are input into the first self-attention module, the output of the first self-attention module is input into the second self-attention module, and the output of the second self-attention module is input into the convolutional neural network.

2. The high-precision target detection method based on improved yolov5 of claim 1, wherein, The backbone network module adopts a CSPNet network.

3. The high-precision target detection method based on improved yolov5 of claim 1, wherein, Each self-attention module performs feature block division on the input feature maps to obtain a plurality of one-dimensional feature blocks of the same size, performs full connection calculation on all one-dimensional feature blocks to obtain a plurality of one-dimensional vectors of the same number as the one-dimensional feature blocks, and obtains self-attention through one-dimensional vector calculation, the self-attention serving as the output of the self-attention module.

4. The high-precision target detection method based on improved yolov5 of claim 1, wherein, The loss function adopted by the target detection model comprises a target detection loss, a category loss and a bounding box loss.

5. An improved yolov5-based high-precision target detection system, characterized in that, The method comprises the steps of: an image acquisition module is configured to acquire a target image to be detected; a target detection module is configured to obtain a target detection result according to the target image to be detected and a trained target detection model, wherein the target detection model is obtained by an improved yolov5 network, the improved yolov5 network comprises a backbone network module, a multi-scale feature fusion module and a prediction module, the backbone network module takes the target image as input and outputs feature maps of different levels; the multi-scale feature fusion module performs feature fusion on the feature maps of different levels to obtain multi-scale feature maps; the prediction module performs small target detection on large-scale feature maps in the multi-scale feature maps to obtain a small target detection result, and performs large target detection on small-scale feature maps in the multi-scale feature maps to obtain a large target detection result; the prediction module comprises a large-resolution prediction branch and a small-resolution prediction branch, the large-resolution prediction branch takes the large-scale feature maps as input and outputs the small target detection result; the small-resolution prediction branch takes the small-scale feature maps as input and outputs the large target detection result; the large-resolution prediction branch and the small-resolution prediction branch both adopt a convolutional neural network; The convolutional layer in the large-resolution prediction branch is a deformable convolutional layer; the small-resolution prediction branch includes two serial self-attention modules and a convolutional neural network, small-scale feature maps are input into the first self-attention module, the output of the first self-attention module is input into the second self-attention module, and the output of the second self-attention module is input into the convolutional neural network.

6. An electronic device, comprising: The computer instructions are executed by the processor to complete the steps of the high-precision target detection method based on the improved yolov5 according to any one of claims 1-4.

7. A computer readable storage medium characterized in that, A computer program product for storing computer instructions, which are executed by a processor to complete the steps of the high-precision target detection method based on the improved yolov5 according to any one of claims 1-4.

Citation Information

Patent Citations

  • Unmanned engineering machinery decision-making method based on feature fusion and space-time constraint

    CN113848884A

  • Improved target detection method and device based on Yolov5 target detection model, and storage medium

    CN115375914A