Target detection method and device and readable storage medium
The enhanced YOLOv5 network with P2 layer, PANET, and CBAM modules addresses the limitations of Yolo in small target detection, improving detection accuracy and real-time performance by capturing detailed features and enhancing attention on small targets.
Patent Information
- Application Number
- CN202411129849.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-13
AI Technical Summary
Existing Yolo algorithms face challenges in accurately detecting small targets due to loss of small target information during feature extraction and limitations of fixed anchor points in complex backgrounds, especially in high-density target scenes.
The improved YOLOv5 network incorporates a new detection layer P2, multi-scale feature fusion through PANET, dense connections, and CBAM modules to enhance feature extraction and attention on small targets, increasing network layers and data resolution.
Significantly improves target detection performance, particularly for small targets, by capturing detailed features and enhancing detection accuracy and real-time performance.
Smart Images

Figure CN119131344A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a target detection method, device and readable storage medium. Background Art
[0002] Object detection algorithm is an important branch in the field of computer vision, which aims to identify and locate the target object of interest from the image. Object detection algorithm largely determines many fields such as autonomous driving, security monitoring, drone navigation, etc. In addition, small target detection is also widely used in social services.
[0003] At present, Yolo has received widespread attention as a single-stage target detection; however, Yolo has relatively large defects and challenges in handling small target detection, so further improvement and optimization are needed in small target detection.
[0004] Therefore, how to improve the accuracy of the target detection results of the Yolo algorithm becomes a problem that needs to be solved. Summary of the invention
[0005] The technical problem to be solved by the present application is to provide a target detection method, device and readable storage medium to solve the problems existing in the prior art in view of the above-mentioned deficiencies in the prior art.
[0006] In a first aspect, the present application provides a target detection method, the method comprising:
[0007] S1, obtaining an image to be detected, and inputting the image to be detected into a pre-trained improved yolov5 network;
[0008] S2, in the P2 stage of the improved yolov5 network, feature extraction is performed on the image to be detected through a convolutional attention module CBAM and a dense connection layer Denseblock to obtain a first feature and a second feature, wherein the dimension of the first feature is higher than the dimension of the second feature;
[0009] S3. Based on the second feature, feature extraction is performed through a path aggregation network PANET to obtain a third feature and a fourth feature, wherein the dimension of the third feature is lower than the dimension of the fourth feature;
[0010] S4. Perform target detection based on the third feature and the fourth feature to obtain a target detection result.
[0011] In some embodiments, after S1 and before S2, the process further includes:
[0012] S11, reshape the image to be detected to obtain an image of preset dimensions;
[0013] S12. Perform feature extraction on the image of the preset dimension through a convolutional layer to obtain initial features.
[0014] In some embodiments, S2 includes:
[0015] S21, in the P2 stage of the improved yolov5 network, the initial features are processed by a convolutional attention module CBAM and a dense connection layer Denseblock to obtain processed initial features;
[0016] S22, processing the processed initial features through a convolutional layer, a dense connection layer Denseblock and a convolutional attention module CBAM to obtain a first feature;
[0017] S23. Process the first feature through a convolutional layer, a convolutional attention module CBAM and a dense connection layer Denseblock to obtain a second feature.
[0018] In some embodiments, S3 includes:
[0019] S31, processing the second feature through a convolutional layer, a convolutional attention module CBAM and a path aggregation network PANET to obtain a third feature;
[0020] S32, processing the third feature via a CSP module and a path aggregation network PANET to obtain a fourth feature;
[0021] Among them, the path aggregation network PANET includes a convolutional layer, an upsampling module and a Concat module.
[0022] In some embodiments, S31 includes:
[0023] S31a, processing the second feature via a convolutional layer, a convolutional attention module CBAM and an SPPF module;
[0024] S31b, processing the output of the SPPF module through a convolutional layer and an upsampling module;
[0025] S31c, input the output of the upsampling module and the second feature into a Concat module to obtain a third feature.
[0026] In some embodiments, S32 includes:
[0027] S32a, processing the third feature via a CSP module, a convolutional layer, and an upsampling module;
[0028] S32b, input the output of the upsampling module and the first feature into a Concat module to obtain a fourth feature.
[0029] In some embodiments, S4 includes:
[0030] S41, processing the fourth feature through a CSP module and a convolutional layer to obtain a small target detection result;
[0031] S42, processing the third feature and the fourth feature via a Concat module, a CSP module and a convolutional layer to obtain a target detection result;
[0032] S43. Process the third feature and the fourth feature via a Concat module, a CSP module and a convolutional layer to obtain a large target detection result.
[0033] In a second aspect, the present application provides a target detection device, the device comprising:
[0034] An image acquisition module is configured to acquire an image to be detected and input the image to be detected into a pre-trained improved yolov5 network;
[0035] A first processing module is configured to extract features of the image to be detected through a convolutional attention module CBAM and a dense connection layer Denseblock in the P2 stage of the improved yolov5 network to obtain a first feature and a second feature, wherein the dimension of the first feature is higher than the dimension of the second feature;
[0036] A second processing module is configured to extract features through a path aggregation network PANET based on the second feature to obtain a third feature and a fourth feature, wherein a dimension of the third feature is lower than a dimension of the fourth feature;
[0037] The target detection module is configured to perform target detection based on the third feature and the fourth feature to obtain a target detection result.
[0038] In a third aspect, the present application provides a target detection device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement the target detection method described in the first aspect above.
[0039] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the target detection method described in the first aspect above is implemented.
[0040] The target detection method, device and readable storage medium provided by the present application include: obtaining an image to be detected, inputting the image to be detected into a pre-trained improved yolov5 network; in the P2 stage of the improved yolov5 network, extracting features of the image to be detected through a convolutional attention module CBAM and a dense connection layer Denseblock to obtain a first feature and a second feature, wherein the dimension of the first feature is higher than the dimension of the second feature; based on the second feature, extracting features through a path aggregation network PANET to obtain a third feature and a fourth feature, wherein the dimension of the third feature is lower than the dimension of the fourth feature; performing target detection based on the third feature and the fourth feature to obtain a target detection result. The present application provides a target detection method, which improves yolov5, wherein the original network detection layer is added, a p2 layer is added to the yolov5 network, and PANet is introduced to perform multi-scale feature fusion, so that the p2, p3, p4, and p5 networks can better share features; a dense connection layer is added to the backbone network of yolov5 to improve the feature transfer function; a cbam module is added to the convolutional layer in Yolov5 to increase the attention to small targets; the present application can significantly improve the target detection performance, especially the detection performance of small targets, through the above-mentioned improvements to the network structure of yolov5. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0042] Figure 1 A flow chart of a target detection method provided in an embodiment of the present application;
[0043] Figure 2 A schematic diagram of an improved yolov5 network provided in an embodiment of the present application;
[0044] Figure 3 A schematic diagram of the structure of a target detection device provided in an embodiment of the present application;
[0045] Figure 4 A schematic diagram of the structure of another target detection device provided in an embodiment of the present application.
[0046] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0047] In order to enable those skilled in the art to better understand the technical solution of the present application, the implementation mode of the present application will be further described in detail below with reference to the accompanying drawings.
[0048] It should be understood that the specific embodiments and drawings described herein are only used to explain the present application, rather than to limit the present application.
[0049] It can be understood that, in the absence of conflict, the various embodiments in the present application and the various features in the embodiments can be combined with each other.
[0050] It can be understood that, for the convenience of description, the drawings of the present application only show the parts related to the present application, while the parts unrelated to the present application are not shown in the drawings.
[0051] It can be understood that each unit and module involved in the embodiments of the present application may correspond to only one physical structure, or may be composed of multiple physical structures, or multiple units and modules may be integrated into one physical structure.
[0052] It can be understood that the terms "first", "second", etc. in the embodiments of the present application are used to distinguish different objects, or to distinguish different processing of the same object, rather than to describe a specific order of objects.
[0053] It is understandable that, in the absence of conflict, the functions and steps marked in the flowcharts and block diagrams of the present application may occur in an order different from that marked in the drawings.
[0054] It is understood that the flowcharts and block diagrams of the present application illustrate the possible architectures, functions, and operations of the systems, devices, equipment, and methods according to the various embodiments of the present application. Among them, each box in the flowchart or block diagram may represent a unit, module, program segment, code, which contains executable instructions for implementing the specified functions. Moreover, each box or combination of boxes in the block diagram and flowchart may be implemented by a hardware-based system that implements the specified functions, or by a combination of hardware and computer instructions.
[0055] It can be understood that the units and modules involved in the embodiments of the present application can be implemented by software or hardware, for example, the units and modules can be located in a processor.
[0056] The Yolo algorithm divides the input image into fixed grids, each of which can only detect the position of one target. This design works better when processing large target features, but it makes detection difficult for densely packed small targets.
[0057] In addition, the design mode of Yolo uses relatively large downsampling and convolution kernels. When extracting features, small target information is easily lost, so the corresponding small targets cannot be detected.
[0058] In addition, the predefined anchor points used by Yolo to predict the boundaries of targets will be subject to greater limitations for small targets with large variations in shape and size, especially in complex backgrounds and high-density target scenes; fixed anchor points are not sufficient to detect small targets.
[0059] Based on the above problems, this application provides a target detection method based on the improved YOLOv5 network, aiming to improve detection accuracy and real-time performance.
[0060] The main ideas of this application are:
[0061] (1) This application uses a new detection layer P2 to better capture the details of small targets, and the number of network layers is increased from 53 to 56;
[0062] (2) The path aggregation network PANET is introduced to enhance the expression ability of features at different scales through multi-scale feature fusion;
[0063] (3) Dense connections (denseNET) were added to the backbone network, adding 8 dense connection layers, increasing the number of convolutional layers to 32 layers, improving feature transfer and reuse,
[0064] (4) A CBAM convolutional attention module is added to each DBL (Convolution + Batch Normalization + Leaky Relu) event. Five CBAM attention modules are introduced here to further improve the focus on small targets. In addition, the data resolution can be enhanced to enlarge the data to 1024*1024 to enhance the detection of small targets.
[0065] The following is a comparison between the improved yolov5 network provided in this application and the traditional network:
[0066]
[0067] Through the above-mentioned improvement of the network structure of yolov5, this application can significantly improve the detection performance of the target, especially the detection performance of small targets.
[0068] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0069] The present application provides a target detection method, the working process of which can be implemented by electronic devices, such as computers, handheld smart terminals, etc. For the convenience of explanation, the embodiments of the present application are described with the method execution subject being a computer.
[0070] Figure 1 A schematic diagram of a target detection method provided in an embodiment of the present application, such as Figure 1 As shown, the present application provides a target detection method, the method includes S1-S4, which are as follows:
[0071] S1, obtaining an image to be detected, and inputting the image to be detected into a pre-trained improved yolov5 network;
[0072] Specifically, Figure 2 A schematic diagram of the improved yolov5 network provided in the embodiment of the present application, such as Figure 2 As shown in the figure, the image to be detected is first taken as input (Nx3) and input into the pre-trained improved yolov5 network.
[0073] It should be noted that, for ease of understanding, the subsequent embodiments of this application involve size dimension data of feature images, such as 1024ⅹ1024ⅹ3, etc., but this application does not specifically limit the size dimensions of each feature image. The specific numerical values involved in this application are only for illustrative purposes and can be adjusted in actual applications.
[0074] In some embodiments, after S1 and before S2, the process further includes:
[0075] S11, reshape the image to be detected to obtain an image of preset dimensions;
[0076] Specifically, refer to Figure 2 , the image to be detected is reshaped through the reshape module to obtain an image of preset dimensions (1024ⅹ1024ⅹ3).
[0077] This step enhances the acquired image data and can increase the resolution of the original photo to 1024*1024. The enhancement effect can help improve the accuracy of small target detection results.
[0078] S12. Perform feature extraction on the image of the preset dimension through a convolutional layer to obtain initial features.
[0079] Specifically, two convolution modules conv are used to extract features of the preset dimension image (1024ⅹ1024ⅹ3), and the initial features of size 512ⅹ512ⅹ128 and 256ⅹ256ⅹ256 are obtained respectively. Among them, the initial features of 256ⅹ256ⅹ256 subsequently enter the P2 stage of the improved yolov5 network.
[0080] S2, in the P2 stage of the improved yolov5 network, feature extraction is performed on the image to be detected through a convolutional attention module CBAM and a dense connection layer Denseblock to obtain a first feature and a second feature, wherein the dimension of the first feature is higher than the dimension of the second feature;
[0081] In this step, compared with the traditional network, this application adds a new detection layer P2, which enables the network to better capture the details of small targets. Among them, the dense connection layer Denseblock can increase feature transmission and reuse.
[0082] In the convolutional attention module CBAM, the channel attention is:
[0083] M c (F) = σ(W1(W0(F avg ))+W1(W0(F max )))
[0084] Among them, F avg and F max Respectively represent the global average pooling and global maximum pooling of the feature map, W0 and W = represents the fully connected layer, and σ represents the sigmoid activation function.
[0085] The spatial attention is:
[0086] M s (F) = σ(f 7×7 ([F avg ,F max ]))
[0087] Among them, f (7×7) represents a 7x7 convolution operation, [F avg ,F max ] represents the concatenation of feature maps in the channel dimension.
[0088] The output characteristics of the CBAM module are: F'=M c (F)·F·M s (F)
[0089] where · represents multiplication.
[0090] In some embodiments, S2 includes:
[0091] S21, in the P2 stage of the improved yolov5 network, the initial features are processed by a convolutional attention module CBAM and a dense connection layer Denseblock to obtain processed initial features;
[0092] Specifically, the initial features of 256ⅹ256ⅹ256 are processed by a convolutional attention module CBAM and three densely connected layers Denseblock to obtain the processed initial features (256ⅹ256ⅹ256).
[0093] S22, processing the processed initial features through a convolutional layer, a dense connection layer Denseblock and a convolutional attention module CBAM to obtain a first feature;
[0094] Specifically, the processed initial features (256ⅹ256ⅹ256) are first input into the convolutional layer conv to obtain an output of 128ⅹ128ⅹ512, and then the output of 128ⅹ128ⅹ512 is processed through three densely connected layers Denseblock and a convolutional attention module CBAM to obtain the first feature of 128ⅹ128ⅹ512.
[0095] S23. Process the first feature through a convolutional layer, a convolutional attention module CBAM and a dense connection layer Denseblock to obtain a second feature.
[0096] Specifically, the first feature of 128ⅹ128ⅹ512 is input into the convolutional layer conv to obtain an output of 64ⅹ64ⅹ1024, and then the output of 64ⅹ64ⅹ1024 is processed by the convolutional attention module CBAM and two densely connected layers Denseblock to obtain the second feature of 64ⅹ64ⅹ1024.
[0097] In the traditional YOLOv5 network, target detection exists in three levels (P3, P4, P5). This application adds a P2 stage, increasing the network from the original 53 layers to 56 layers, so that the network can better capture the details of small targets.
[0098] In addition, this application introduces the Denseblock module into yolov5, which can improve the interconnection efficiency of the internal network and avoid the loss of feature information. At the same time, on this basis, dense connection can reduce the problem of small gradients.
[0099] In addition, this application introduces the cbam module into yolov5, which can weight the channel attention and spatial attention, and enhance the attention to important features by adaptively adjusting the weights of the feature network; on this basis, a cbam module is added to each dbl module of the original network.
[0100] S3. Based on the second feature, feature extraction is performed through a path aggregation network PANET to obtain a third feature and a fourth feature, wherein the dimension of the third feature is lower than the dimension of the fourth feature;
[0101] In this application, the PANET method is used to enhance the path aggregation operation for p3, p4, p5 and the newly added p2, and better scale feature extraction is performed through multi-layer fusion in the feature hierarchy. This step introduces the path aggregation network (PANet) for multi-scale feature fusion. PANet enhances the feature expression capability by fusing features of different scales.
[0102] In some embodiments, S3 includes:
[0103] S31, processing the second feature through a convolutional layer, a convolutional attention module CBAM and a path aggregation network PANET to obtain a third feature;
[0104] S32, processing the third feature via a CSP module and a path aggregation network PANET to obtain a fourth feature;
[0105] Among them, the path aggregation network PANET includes a convolutional layer, an upsampling module and a Concat module.
[0106] In some embodiments, S31 includes:
[0107] S31a, processing the second feature via a convolutional layer, a convolutional attention module CBAM and an SPPF module;
[0108] Specifically, for the second feature of 64ⅹ64ⅹ1024, the output of 32ⅹ32ⅹ2048 is first obtained through the convolutional layer, and then the output of 32ⅹ32ⅹ2048 is processed through the convolutional attention module CBAM and the SPPF module to obtain the output of the SPPF module (32ⅹ32ⅹ2048).
[0109] Among them, the SPPF module is an improved version of SPP (Spatial Pyramid Pooling). The function of SPP is to extract and encode images at different scales. It can rescale input images of any size to a fixed size and generate a feature vector of fixed length. However, SPPf changes the original parallel structure of SPP into a serial structure, which reduces the amount of calculation. Its main function is to fuse features at different scales and enhance the semantics of feature maps. In Yolov5, SPPF keeps the dimensions of input and output feature maps unchanged, and is used for feature fusion rather than fixed feature vector generation.
[0110] S31b, processing the output of the SPPF module through a convolutional layer and an upsampling module;
[0111] Specifically, the output of the SPPF module (32×32×2048) is input into the convolutional layer to obtain an output of 32×32×1024, and then the output of 32×32×1024 is input into the upsampling module upsample to obtain an output of 64×64×1024.
[0112] S31c, input the output of the upsampling module and the second feature into a Concat module to obtain a third feature.
[0113] Specifically, the output of the upsampling module (64ⅹ64ⅹ1024) and the second feature (64ⅹ64ⅹ1024) are input into the Concat module to obtain the third feature (128ⅹ128ⅹ2048).
[0114] In some embodiments, S32 includes:
[0115] S32a, processing the third feature via a CSP module, a convolutional layer, and an upsampling module;
[0116] Specifically, the third feature (128ⅹ128ⅹ2048) is passed through the CSP module to obtain an output of 128ⅹ128ⅹ1024.
[0117] Among them, CSP (Cross Stage Partial Network) is a special module in YOLOv5. The CSP module can divide the feature map into two parts, one part is convolution operation, and the other part is directly processed in the next step, and then the two parts of the feature map are spliced. This design can improve the expressiveness of features and information flow, thereby improving the accuracy and speed of target detection.
[0118] Then, the output of the CSP module (128ⅹ128ⅹ1024) is input into the convolutional layer to obtain an output of 128ⅹ128ⅹ512, and then the output of the convolutional layer (128ⅹ128ⅹ512) is input into the upsampling module to obtain an output of 128ⅹ128ⅹ256.
[0119] S32b, input the output of the upsampling module and the first feature into a Concat module to obtain a fourth feature.
[0120] Specifically, the output of the upsampling module (128ⅹ128ⅹ256) and the first feature (128ⅹ128ⅹ512) are input into the Concat module to obtain the fourth feature (256ⅹ256ⅹ256).
[0121] S4. Perform target detection based on the third feature and the fourth feature to obtain a target detection result.
[0122] In some embodiments, S4 includes:
[0123] S41, processing the fourth feature through a CSP module and a convolutional layer to obtain a small target detection result;
[0124] Specifically, the fourth feature (256×256×256) is input into the CSP module, and then the output of the CSP module is processed by a convolutional layer to obtain a 256×256 small target detection result.
[0125] S42, processing the third feature and the fourth feature via a Concat module, a CSP module and a convolutional layer to obtain a target detection result;
[0126] Specifically, the fourth feature is input into the convolution layer via the output of the CSP module (256ⅹ256ⅹ128) to obtain the output of the convolution layer (128ⅹ128ⅹ128), and then the output of the convolution layer (128ⅹ128ⅹ128) and the output of the convolution layer in step S32a (128ⅹ128ⅹ512) are input into the Concat module together to obtain an output of 128ⅹ128ⅹ512.
[0127] Then, the 128×128×512 output obtained by the Concat module is passed through the CSP module and the convolution layer to obtain the 128×128 target detection result.
[0128] S43. Process the third feature and the fourth feature via a Concat module, a CSP module and a convolutional layer to obtain a large target detection result.
[0129] Specifically, the 128ⅹ128ⅹ512 output obtained by the Concat module in step S42 is passed through the CSP module to obtain a 128ⅹ128ⅹ512 output, and then the 128ⅹ128ⅹ512 output obtained by the CSP module is processed through a convolutional layer to obtain a 32ⅹ32ⅹ512 output.
[0130] Then, the 32×32×512 output obtained by the convolution layer and the 32×32×1024 output obtained by the convolution layer in step S31b are input into the Concat module together to obtain a 32×32×1024 output.
[0131] Finally, the 32×32×1024 output obtained by the Concat module is passed through the CSP module and the convolution layer to obtain the 32×32 large object detection result.
[0132] The present application provides a target detection method, which improves yolov5, wherein the original network detection layer is added, a p2 layer is added to the yolov5 network, and PANet is introduced to perform multi-scale feature fusion, so that the p2, p3, p4, and p5 networks can better share features; a dense connection layer is added to the backbone network of yolov5 to improve the feature transfer function; a cbam module is added to the convolutional layer in Yolov5 to increase the attention to small targets; the present application can significantly improve the target detection performance, especially the detection performance of small targets, through the above-mentioned improvements to the network structure of yolov5.
[0133] It should be understood that, although the various steps in the flowcharts in the above-described embodiments are sequentially displayed according to the indications of the arrows, these steps are not necessarily executed sequentially in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and they can be executed in other orders. Moreover, at least a portion of the steps in the figure may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily to be carried out sequentially, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0134] Figure 3 A schematic diagram of a target detection device provided in an embodiment of the present application, such as Figure 3 As shown, the present application provides a target detection device, the device comprising:
[0135] An image acquisition module 11 is configured to acquire an image to be detected and input the image to be detected into a pre-trained improved yolov5 network;
[0136] A first processing module 12 is configured to extract features of the image to be detected through a convolutional attention module CBAM and a dense connection layer Denseblock in the P2 stage of the improved yolov5 network to obtain a first feature and a second feature, wherein the dimension of the first feature is higher than the dimension of the second feature;
[0137] A second processing module 13 is configured to extract features through a path aggregation network PANET based on the second feature to obtain a third feature and a fourth feature, wherein a dimension of the third feature is lower than a dimension of the fourth feature;
[0138] The target detection module 14 is configured to perform target detection based on the third feature and the fourth feature to obtain a target detection result.
[0139] Regarding the limitation on the target detection device, reference may be made to the limitation on the target detection method in the above embodiments of the present application, which will not be elaborated in this embodiment.
[0140] Figure 4 Another schematic diagram of the target detection device provided in the embodiment of the present application is as follows Figure 4 As shown, in some embodiments, the present application provides a target detection device, including a memory 22 and a processor 21, the memory stores a computer program, and the processor is configured to run the computer program to execute the target detection method in the above embodiments of the present application.
[0141] The memory is connected to the processor, the memory may be a flash memory or a read-only memory or other memory, and the processor may be a central processing unit or a single-chip microcomputer.
[0142] In some embodiments, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the target detection method in the above-mentioned embodiments of the present application is implemented.
[0143] The computer-readable storage medium includes volatile or non-volatile, removable or non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, computer program modules or other data). Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable read only memory), flash memory or other memory technology, CD-ROM (Compact Disc Read-Only Memory), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer.
[0144] It is to be understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of the present application, but the present application is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and substance of the present application, and these modifications and improvements are also considered to be within the scope of protection of the present application.
Claims
1. A target detection method, characterized in that: The method comprises: S1, obtaining an image to be detected, and inputting the image to be detected into a pre-trained improved yolov5 network; S2, in the P2 stage of the improved yolov5 network, feature extraction is performed on the image to be detected through a convolutional attention module CBAM and a dense connection layer Denseblock to obtain a first feature and a second feature, wherein the dimension of the first feature is higher than the dimension of the second feature; S3. Based on the second feature, feature extraction is performed through a path aggregation network PANET to obtain a third feature and a fourth feature, wherein the dimension of the third feature is lower than the dimension of the fourth feature; S4. Perform target detection based on the third feature and the fourth feature to obtain a target detection result.
2. The target detection method according to claim 1, characterized in that: After S1 and before S2, it also includes: S11, reshape the image to be detected to obtain an image of preset dimensions; S12. Perform feature extraction on the image of the preset dimension through a convolutional layer to obtain initial features.
3. The target detection method according to claim 2, characterized in that: S2, including: S21, in the P2 stage of the improved yolov5 network, the initial features are processed by a convolutional attention module CBAM and a dense connection layer Denseblock to obtain processed initial features; S22, processing the processed initial features through a convolutional layer, a dense connection layer Denseblock and a convolutional attention module CBAM to obtain a first feature; S23. Process the first feature through a convolutional layer, a convolutional attention module CBAM and a dense connection layer Denseblock to obtain a second feature.
4. The target detection method according to claim 1, characterized in that: S3, including: S31, processing the second feature through a convolutional layer, a convolutional attention module CBAM and a path aggregation network PANET to obtain a third feature; S32, processing the third feature via a CSP module and a path aggregation network PANET to obtain a fourth feature; Among them, the path aggregation network PANET includes a convolutional layer, an upsampling module and a Concat module.
5. The target detection method according to claim 4, characterized in that: S31, including: S31a, processing the second feature via a convolutional layer, a convolutional attention module CBAM and an SPPF module; S31b, processing the output of the SPPF module through a convolutional layer and an upsampling module; S31c, input the output of the upsampling module and the second feature into a Concat module to obtain a third feature.
6. The target detection method according to claim 4, characterized in that: S32, including: S32a, processing the third feature via a CSP module, a convolutional layer, and an upsampling module; S32b, input the output of the upsampling module and the first feature into a Concat module to obtain a fourth feature.
7. The target detection method according to claim 1, characterized in that: S4, including: S41, processing the fourth feature through a CSP module and a convolutional layer to obtain a small target detection result; S42, processing the third feature and the fourth feature via a Concat module, a CSP module and a convolutional layer to obtain a target detection result; S43. Process the third feature and the fourth feature via a Concat module, a CSP module and a convolutional layer to obtain a large target detection result.
8. A target detection device, characterized in that: The device comprises: An image acquisition module is configured to acquire an image to be detected and input the image to be detected into a pre-trained improved yolov5 network; A first processing module is configured to extract features of the image to be detected through a convolutional attention module CBAM and a dense connection layer Denseblock in the P2 stage of the improved yolov5 network to obtain a first feature and a second feature, wherein the dimension of the first feature is higher than the dimension of the second feature; A second processing module is configured to extract features through a path aggregation network PANET based on the second feature to obtain a third feature and a fourth feature, wherein a dimension of the third feature is lower than a dimension of the fourth feature; The target detection module is configured to perform target detection based on the third feature and the fourth feature to obtain a target detection result.
9. A target detection device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement the target detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the target detection method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method for detecting target object grabbed by mechanical arm based on improved YOLOv5 algorithm
CN116630602A
Small sample SAR target recognition method based on mixed attention mechanism
CN116824374A
Improved PCB defect detection method based on YOLO v5 algorithm
CN117274197A
Remote beach obstacle target identification method and system based on YOLOv5 improvement
CN118072196A
