Lightweight truck detection method and system based on improved YOLO model

By improving the YOLO model and employing GhostConv, the Multi-Scale Feature Context Focusing (MCFP) module, and the Adaptive Receptive Field Enhancement (SRFEM) module, the problems of insufficient accuracy and speed in truck detection were solved, achieving efficient multi-scale target recognition and real-time detection.

CN118918545BActive Publication Date: 2025-10-17NANJING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411036278.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2025-10-17
Estimated Expiration
2044-07-31

AI Technical Summary

Technical Problem

Existing YOLO models suffer from low detection accuracy and speed in truck detection, especially under multi-scale and low-resolution targets, and have high computational resource consumption, making it difficult to meet real-time detection requirements.

Method used

GhostConv replaces the Backbone of the YOLOv5s network. The C3Ghost module and the multi-scale feature context focusing module MCFP are designed and combined with the multi-scale adaptive receptive field enhancement module SRFEM to perform truck detection using the improved YOLO model.

Benefits of technology

It improves the accuracy and speed of truck detection, enhances the ability to identify multi-scale targets, reduces computational load, and enables real-time detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118918545B_ABST
    Figure CN118918545B_ABST
Patent Text Reader

Abstract

The application discloses a kind of light truck detection method and system based on improved YOLO model, the method includes collecting the image of different shooting angles of various trucks to construct data set and marking;Ghost convolution is applied to YOLOv5s main network;Construct GhostC3 module for YOLOv5s main feature extraction network;Utilize target scale diversity characteristics to construct multi-scale context feature focusing pyramid module MCFP;Utilize target low-resolution characteristics to construct multi-scale adaptive receptive field enhancement module SRFEM;Finally, the improved network is input to the truck data set built by oneself, and truck detection result is obtained.The application can detect truck target with high precision in real time.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of target detection and recognition of computer vision, and particularly relates to a light truck detection method based on an improved YOLO model. BACKGROUND

[0002] With the accelerated development of urbanization, the demand for urban logistics is increasing, and trucks, as an important part of the logistics system, will exacerbate traffic congestion as heavy vehicles, especially during peak hours, and even cause traffic accidents. In order to reduce the incidence of traffic accidents, it is stipulated that trucks are prohibited from passing at fixed times. However, some truck drivers adjust their routes to avoid being caught on camera by taking advantage of the small size of the truck images recorded by the camera and the inability to identify the license plate. Therefore, large vehicle target detection is a meaningful and challenging technology.

[0003] In recent years, with the improvement of computing power and the optimization of algorithms, deep learning has been increasingly applied in vehicle detection. Deep learning target detectors are mainly divided into two-stage target detectors and single-stage target detectors. Foreign scholars proposed the R-CNN algorithm, which was the first time to apply deep learning to target detection tasks. Subsequently, improved algorithms such as Faster R-CNN and ContextR-CNN were proposed for traffic vehicle detection. Such two-stage methods include two tasks of generating region candidates and positioning targets, so as to obtain high model detection accuracy, but at the expense of inference speed. Single-stage methods only need one step to realize target positioning and classification, so this is the preferred solution for real-time applications in traffic scenarios. For example, the famous YOLO (You Only Look Once) series of algorithms and the SSD (Single Shot Multibox Detector) algorithm. The high accuracy of the YOLO algorithm makes it widely used in vehicle detection tasks.

[0004] Although the yolo series algorithm performs well in efficiency, it still has some limitations or problems, such as accuracy in certain specific scenarios, detection ability for small targets, algorithm complexity, and generalization ability. Due to the influence of various factors such as camera shooting angle and environment in traffic scenarios, the following problems exist:

[0005] (1) Due to the fixed monitoring camera and the continuous movement of the vehicle, the scale of the same vehicle target varies;

[0006] (2) When the vehicle is far from the monitoring camera, the image is small and contains less feature information, and the detection accuracy may be low;

[0007] (3) Different installation positions of the monitoring camera will also cause the shape and features of the same vehicle target to be diverse.

[0008] In summary, a truck detection algorithm that can realize sufficient fusion of multi-scale features and lightweight deployment on a camera is of great significance. SUMMARY

[0009] The technical problems to be solved by the present application: In order to overcome the shortcomings of the prior art, in view of the low precision and speed of truck detection in monitoring images, and the limitation of application to embedded software, the present application proposes a lightweight truck detection method based on an improved YOLO model, which aims to improve the recognition accuracy of multi-scale truck targets and improve the detection speed, and is applied to complex scenes.

[0010] To solve the above technical problems, the technical solutions proposed by the present application are as follows:

[0011] A lightweight truck detection method based on an improved YOLO model, comprising the following steps:

[0012] S1, constructing a multi-class truck special data set with labels;

[0013] S2, replacing all convolution operations in the BackBone of YOLOv5s network with GhostConv;

[0014] S3, designing a C3Ghost module applied to the backbone feature extraction network of YOLOv5s; Specifically: designing a GhostBottleNeck module, which contains three layers: first, a Ghost module is used as an expansion layer to increase the number of input feature map channels through linear transformation; second, a depth separable convolution with a stride of 2 is used for down-sampling; finally, a GhostModule is used to reduce the number of output channels to match the number of original input graph channels, and the two are added element by element; replace the BottleNeck module of the C3 module in the YOLOv5s network with the designed GhostBottleNeck module to generate a C3Ghost module;

[0015] S4, constructing a multi-scale feature context focusing module MCFP for target scale diversity, inputting the improved backbone feature extraction network of YOLOv5s in step S3 into the MCFP module, and constructing MCFP is: using CA attention mechanism to fuse the current feature layer and its adjacent feature layer, and weighting on the original feature map through multiplication to obtain the output feature map with attention weight in the width and height direction, then the output feature map is up-sampled through the path from top to bottom and fused with the low-level features, and then from bottom to top, help the model capture the transition from low-level to high-level detailed information to abstract semantics, and for the same size feature map in the feature fusion process, use the jump connection to directly establish the connection;

[0016] S5, construct a multi-scale adaptive receptive field enhancement module SRFEM for the target low resolution, input the SRFEM module into the model detection head, and form an improved truck detection model; the SRFEM is constructed as follows: different sampling rate hole convolution is used to extract feature information in parallel, then softmax is used to calculate the weight, each group of features is given different weights, so that the module can adaptively select different receptive fields according to the size of the target, the output feature maps of different receptive fields are added layer by layer, finally the output features in the channel dimension are spliced, and then the original feature map is added pixel by pixel, to obtain the final output feature map;

[0017] S6, input the data set into the improved truck detection model to detect the truck in the monitoring image.

[0018] The specific steps of the step S1 are as follows:

[0019] Step S11, collect images of large trucks and tank trucks based on different shooting angles;

[0020] Step S12, label the images to obtain labels using Labelme;

[0021] Step S13, randomly divide the images into a truck special data set according to the training set, test set and validation set ratio of 7:2:1.

[0022] The specific steps of the step S2 are as follows: replace the convolution of the backbone network of YOLOv5s with Ghost convolution, reduce the network parameters and calculation amount while ensuring the network accuracy, so as to improve the calculation speed and reduce the delay.

[0023] The specific steps of the step S3 are as follows:

[0024] Step S31, first generate some inherent feature maps through a normal convolution operation, assuming that the input feature map is n-dimensional, the number of mappings is s, the output feature map is m-dimensional, and the convolution kernel size is k, the feature map Y' can be obtained h'×w'×m .

[0025] Step S32, apply a simple linear operation to Y' to obtain more feature maps, as shown in the formula:

[0026]

[0027] Where, y' i represents the i-th channel feature map of Y'; Phi ij represents the j-th linear operation used to generate the i-th Ghost feature map.

[0028] Step S33, the output Ghost module is the splicing result of the ordinary feature map obtained in step 1 and the Ghost feature map obtained in step S32.

[0029] Step S34, the dimension of the channel is increased and decreased respectively for two Ghost modules existing in front and back, so that the output channel number is consistent with the output channel number, and the output feature map GhostBottleNeck is obtained, which is applied to the original network C3 module to reduce the model parameter quantity and the calculation amount.

[0030] The step S4 is specifically:

[0031] Step S41, {P1, P2, P3, P4} is the output of the backbone network, and P5 is the up-sampling result of P4. {P1, P2, P3}, {P2, P3, P4} and {P3, P4, P5} are respectively input into the CA attention mechanism as input feature groups, and the multi-scale features of adjacent layers are fused, and the long-range dependency is captured, and the recognition ability of the model to objects with different scales is improved.

[0032] Step S42, the CA attention mechanism is used for input feature map F C×H×W Global average pooling is respectively performed in the horizontal direction and the vertical direction, and feature maps in the width direction and the height direction are respectively obtained, and the long-range dependency of the features is established.

[0033] Step S43, the pooled feature maps are spliced in the channel dimension, and the features are fused and reduced in dimension by using convolution, and the feature map F1 processed by batch normalization is input into the Sigmoid activation function to obtain the feature map f.

[0034] Step S44, the feature map f is cut according to the height and the width and is subjected to 1x1 convolution to increase the dimension to obtain the feature maps f h and f w respectively. After the Sigmoid activation function, the height attention weight g h and the width attention weight g w of the feature map are respectively obtained.

[0035] Step S45, finally, the output feature map with attention weight in the width and height directions is obtained by multiplying the original feature map, and the formula is as follows:

[0036]

[0037] Wherein, F' c (i,j) represents the feature response of the pixel point (i,j) at the c channel of the feature map F; represents the value of the horizontal direction i pixel at the c channel of the feature; represents the value of the i-th pixel in the vertical direction at the c-th channel.

[0038] Step S46, the three groups of feature maps output by the attention mechanism are up-sampled by a top-down path to obtain high-level semantic features, and are fused with low-level features to improve the position accuracy of the low-resolution feature maps, and help the model capture the transition from low-level to high-level detailed information to abstract semantics. For feature fusion, the same size feature maps are directly connected using a skip connection.

[0039] The step S5 is specifically:

[0040] Step S51, for the three groups of feature maps output by the step S4, a corresponding dilated convolution combination is set, i.e. R1=(1,2), R2=(1,2,5), R3=(1,2,5,8), and feature information is extracted in parallel using dilated convolutions with different sampling rates;

[0041] Step S52, the channel weights of the feature branches are re-allocated by a softmax function, so that the network dynamically selects a receptive field according to a target size, and realizes that for a target with a larger size, a larger weight is allocated to a branch with a larger dilated rate, and for a target with a smaller size, a larger weight is allocated to a branch with a smaller dilated rate. For example, R1=(1,2), the specific formula is as follows:

[0042]

[0043]

[0044] wherein, a c represents the weight of the c-th element in the vector a; b c represents the weight of the c-th element in the vector b.

[0045]

[0046]

[0047] a′+b′=1

[0048] Step S53, the feature branches with the re-calibrated channel weights are added pixel by pixel to compensate for the grid effect caused by the dilated convolution, and then the added feature maps are spliced with the original feature maps, and the formula is as follows:

[0049] F3=Cat(F,aF1+bF1)

[0050] Step S54, the number of output feature channels is adjusted by a 1x1 convolution.

[0051] The above is a processing step of a feature map group, and weights of corresponding channels are set for the other two groups of feature output maps, and the processing steps are the same as described above.

[0052] The step S6 includes the following specific steps:

[0053] The experimental environment hardware of the application is an Nvidia GeForce RTX 3050 graphics card, the software system is Windows 10 and the PyTorch 1.2 deep learning framework, the IOU threshold is set to 0.5, the input image is 640*640, the initial learning rate is 0.01, the batch sample size is 16, and the training round number is 300 rounds. The evaluation indexes of the detection algorithm include the average precision AP (Average Precision) of all categories and the video frame processing rate FPS (Frames Per Second).

[0054] The application further provides a lightweight truck detection system based on an improved YOLO model, which comprises:

[0055] A data set construction unit is configured to construct a multi-class truck special data set with labels.

[0056] A truck detection model construction unit is configured to perform the following actions:

[0057] (1) replacing all convolution operations in the BackBone of the YOLOv5s network with GhostConv;

[0058] (2) designing a C3Ghost module applied to the backbone feature extraction network of the YOLOv5s; specifically, a GhostBottleNeck module is designed, which includes three layers: first, a Ghost module is used as an expansion layer to increase the number of input feature map channels through linear transformation; second, a deep separable convolution with a stride of 2 is used for down-sampling; and finally, a GhostModule is used to reduce the number of output channels to match the number of original input channels, and the two are added element by element; the designed GhostBottleNeck module replaces the BottleNeck module of the C3 module in the YOLOv5s network to generate a C3Ghost module.

[0059] (3) For the target scale, a multi-scale feature context focusing module MCFP is constructed, and the improved YOLOv5s backbone feature extraction network is input into the MCFP module, and the MCFP is constructed as follows: the CA attention mechanism is used to fuse the current feature layer and its adjacent feature layer, and the output feature map with attention weight in the width and height directions is obtained by multiplication weighting on the original feature map, then the output feature map is upsampled through the top-down path to help the model capture the transition from low-level to high-level detailed information to abstract semantics, and for the feature fusion process, the same size feature map is directly connected by using the skip connection;

[0060] (4) For the target low resolution, a multi-scale self-adaptive receptive field enhancement module SRFEM is constructed, and the SRFEM module is input into the model detection head to form an improved truck detection model; the SRFEM is constructed as follows: different sampling rate of the cavity convolution is used to extract feature information in parallel, then the softmax is used to calculate the weight to give different weights to each group of features, so that the module can adaptively select different receptive fields according to the size of the target, the output feature maps with different receptive fields are added layer by layer, and finally the output features in the channel dimension are spliced, and then added with the original feature map pixel by pixel to obtain the final output feature map;

[0061] The detection unit is configured to input a data set into the improved truck detection model to detect trucks in the monitoring image.

[0062] Further, the present application also provides an electronic device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the improved YOLO model-based lightweight truck detection method when executing the computer program.

[0063] Further, the present application also provides a computer-readable storage medium, which stores a computer program, wherein the computer program is executable on a processor to execute the steps of the improved YOLO model-based lightweight truck detection method.

[0064] Finally, the present application also provides a computer program product, which comprises a computer program / instruction, wherein the computer program / instruction is executable on a processor to implement the steps of the improved YOLO model-based lightweight truck detection method.

[0065] Compared with the prior art, the present application has the beneficial effects that:

[0066] (1) In view of the problem that the scale of the same vehicle target is variable due to the fixed monitoring camera and the continuous movement of the vehicle, the application introduces a multi-scale context feature focusing pyramid module, establishes the context interaction of multi-scale features of adjacent levels, makes the network more effectively transmit semantic information, and then samples the relevance of features between different levels, thereby improving the generalization and accuracy of the network.

[0067] (2) In view of the problem that the detection accuracy may be low when the vehicle is far away from the monitoring camera, the image is small, and less feature information is contained, the application introduces a multi-scale adaptive receptive field enhancement module, enhances the receptive field extraction features through the combination of different expansion rates of the hollow convolution, and gives different weight values to each group of features, so that the network dynamically selects different receptive fields according to the different target scales, and improves the recognition accuracy of different scale targets.

[0068] (3) In view of the problem that most target detection models occupy high computing resources, have low detection real-time frame rate, have poor real-time performance, and cannot meet the actual scene requirements, the application introduces a Ghost module, reduces the computational amount of the network under the condition of maintaining the detection accuracy of the network, improves the detection speed, and realizes real-time detection. BRIEF DESCRIPTION OF DRAWINGS

[0069] Figure 1 It is an improved YOLO model-based lightweight truck detection method flow diagram.

[0070] Figure 2 It is an improved network structure diagram.

[0071] Figure 3 It is a C3Ghost module structure diagram.

[0072] Figure 4 It is a MCFP multi-scale context feature focusing pyramid module structure diagram.

[0073] Figure 5 It is a SRFEM multi-scale context feature focusing pyramid module structure diagram.

[0074] Figure 6 It is a detection performance comparison diagram of the application and other methods under the same environment. DETAILED DESCRIPTION

[0075] The application will be further described in detail below with reference to the accompanying drawings.

[0076] Example 1: The improved YOLO model-based lightweight truck detection method of the present application is as shown in the figure, which comprises the following steps: Figure 1

[0077] ​S1, a multi-class truck special data set with labels is constructed; the specific steps are as follows:

[0078] Step S11, collect images of large trucks and tank trucks based on different shooting angles;

[0079] Step S12, label the images to obtain labels using Labelme;

[0080] Step S13, randomly divide the images into a truck special data set according to the training set, test set and validation set ratio of 7:2:1.

[0081] S2, apply Ghost convolution to the backbone network of YOLOv5s; the specific steps are as follows:

[0082] Replace all ordinary convolution operations in BackBone in the original network of YOLOv5s with GhostConv, which reduces network parameters and computational complexity while ensuring network accuracy, thereby improving calculation speed and reducing latency, and the overall network structure diagram is as shown in Figure 2 .

[0083] S3, design a C3Ghost module for the backbone network of YOLOv5s; specifically:

[0084] Step S31, first generate some inherent feature maps through a normal convolution operation, assuming that the input feature map is n-dimensional, the height is h, the number of mappings is s, the output feature map is m-dimensional, and the convolution kernel size is k. The feature map Y' can be obtained h'×w'×m .

[0085] Step S32, apply a simple linear operation to Y' to obtain more feature maps, as shown in equation (1):

[0086]

[0087] where y' i represents the i-th channel feature map of Y'; Φ ij represents the j-th linear operation used to generate the i-th Ghost feature map.

[0088] Step S33, the output of the Ghost module is the splicing result of the normal feature map obtained in step S31 and the Ghost feature map obtained in step S32.

[0089] Step S34, the output feature map is GhostBottleNeck, whose structure is as shown in Figure 3 , two Ghost modules exist before and after to perform channel dimension increasing and dimension decreasing operations, so that the output channel number is consistent with the output channel number.

[0090] Step S35, finally apply the Ghost BottleNeck to the original network C3 module to reduce the model parameter quantity and calculation amount;

[0091] S4, a multi-scale feature context focusing module MCFP is constructed for target scales;

[0092] Step S41, set {P1, P2, P3, P4} as the output of the backbone network, and P5 is the up-sampling result of P4. {P1, P2, P3}, {P2, P3, P4} and {P3, P4, P5} are respectively input into the CA attention mechanism as input feature groups, and the multi-scale features of adjacent layers are fused, and the long-range dependency relationship is captured, and the recognition ability of the model to the hierarchical semantic information and the objects of different scales is improved.

[0093] Step S42, taking {P2, P3, P4} as an example, the multi-scale context feature interaction pyramid module proposed in the application is as shown in Figure 4 The CA attention mechanism performs global average pooling on the input feature map F∈R C×H×W in the horizontal direction and the vertical direction respectively, respectively obtains the feature maps in the width direction and the height direction, and establishes the long-range dependency of the features. The specific formulas are as follows:

[0094]

[0095]

[0096] wherein, represents the value of the feature z at the horizontal direction h pixel point (c, h), represents the value of the feature w at the vertical direction w pixel point (c, w).

[0097] Step S43, the feature maps after pooling are spliced in the channel dimension, and the features are fused and reduced in dimension by using convolution, and the feature map F1 after batch normalization processing is input into the Sigmoid activation function to obtain the feature map f, and the calculation is as shown in formula (4).

[0098]

[0099] Step S44, the feature map f is cut according to the height and the width and is subjected to 1×1 convolution dimension increasing to obtain the feature maps f h and f w respectively. After the Sigmoid activation function, the height attention weight g h and the width attention weight g w of the feature map are obtained respectively, and the calculation formulas are as shown in formulas (5) and (6).

[0100] g h= σ (F h (f h )) (5)

[0101] g w = σ (F w (f w )) (6)

[0102] Step S45, finally, the output feature map with attention weight in the width and height direction is obtained by multiplying the original feature map, and the calculation is as shown in formula (7):

[0103]

[0104] Wherein, F' c (i,j) represents the feature response of the pixel point (i,j) at the c channel of the feature map F; represents the value of the feature at the i-th pixel in the horizontal direction at the c channel; represents the value of the feature at the j-th pixel in the vertical direction at the c channel.

[0105] Step S46, the feature map output by the attention mechanism is up-sampled by a top-down path to fuse the high-level semantic features with the low-level features, and the position accuracy of the low-resolution feature map is improved. Then help the model capture the transition from detailed information to abstract semantics from low layer to high layer. For the feature maps of the same size in the feature fusion process, the jump connection is used to directly establish the connection, so that the multi-layer features can complement each other and enhance the feature integration ability of the model.

[0106] S5, a multi-scale adaptive receptive field enhancement module SRFEM is proposed for the target low resolution; specifically:

[0107] Step S51, set the corresponding dilated convolution combination of the feature maps output by the three branches in step S4, that is, R1=(1,2), R2=(1,2,5), and R3=(1,2,5,8). Use different sampling rates of dilated convolution to extract feature information in parallel. Take R1=(1,2) as an example, use a kernel of size 3, and dilated convolution with expansion rates of 1 and 2 are used to extract features F∈R C ×H×W , and the number of channels is reduced to 1 / 2 of the original, then the average pooling is used to model the channel information, and the weight vector of is calculated as shown in formula (8) and formula (9):

[0108]

[0109]

[0110] Wherein, a c represents the weight of the c-th element in the vector a; bc represents the weight of the cth element in the vector b.

[0111] Step S52, reassign the channel weight of the feature branch through the softmax function, so that the network dynamically selects the receptive field according to the target size. For a larger target, larger weights are allocated to branches with a large expansion rate. For a smaller target, larger weights are allocated to branches with a small expansion rate. The specific formula is shown in formula (10) and formula (11):

[0112]

[0113]

[0114] a+b=1.

[0115] Step S53, add the feature branches with re-calibrated channel weights pixel by pixel to compensate for the grid effect caused by the empty convolution. Then, the added feature map is spliced with the original feature map, as shown in formula (12):

[0116] F3=Cat(F,a'F1+b'F1) (12)

[0117] Step S54, adjust the output feature channel number through 1x1 convolution. For the multi-branch case, the network structure is as shown in formula (13) by analogy with the above description, and three weights and four weights are taken respectively. Figure 5

[0118] S6, the data set is input into the improved truck detection model to detect the truck in the monitoring image, and the specific steps are as follows:

[0119] The image data set obtained in S1 is input into the network of the present application, and the learned features are used for prediction, and the position and category of the low resolution small target in the image are output. The evaluation index of the detection algorithm includes the average precision AP (Average Precision) of all categories and the video frame processing rate FPS (Frames Per Second). The specific content is:

[0120] In this example, in order to verify the effectiveness of each module of the present application, YOLOv5s is taken as the baseline network, and ablation experiments are performed on each key improvement module.

[0121] The experimental results are shown in the following table:

[0122] SRFEM MCFP GhostModule FPS AP 26 76.73 √ 24 77.81 √ 22 79.37 √ √ 21 80.15 √ √ √ 28 80.06

[0123] ​To verify the effectiveness of the algorithm proposed in the present application in the traffic scene, the present application selects a real traffic monitoring video, and compares the detection performance of the baseline network YOLOv5s and the improved algorithm in the present application at the same time of the video frame, and the detection results are as shown in Figure 6 As can be seen from (b) t = 6 in Figure 6 , due to the occlusion of the passing vehicles, the detection is missed, while Figure 6 (c) shows that the algorithm of the present application realizes accurate detection. Figure 6 (b) t = 24, due to the small size of the vehicle target in the distance, the detection is missed, while Figure 6 (c) correctly identifies the target. In summary, the network proposed in the present application effectively improves the missed detection and false detection of the target detector, and improves the accuracy and stability of the detection.

[0124] As a second embodiment of the present application, the present embodiment proposes a lightweight truck detection system based on an improved YOLO model, comprising:

[0125] a data set construction unit for constructing a multi-class truck special data set with labels;

[0126] a truck detection model construction unit configured to perform the following actions:

[0127] (1) replacing all convolution operations in the BackBone of the YOLOv5s network with GhostConv;

[0128] (2) designing a C3Ghost module applied to the main feature extraction network of YOLOv5s; Specifically, a GhostBottleNeck module is designed, which includes three layers: first, a Ghost module is used as an expansion layer to increase the number of input feature map channels through linear transformation; second, a depth separable convolution with a stride of 2 is used for down-sampling; finally, a GhostModule is used to reduce the number of output channels to match the number of original input map channels, and the two are added element by element; the designed GhostBottleNeck module replaces the BottleNeck module of the C3 module in the YOLOv5s network to generate a C3Ghost module;

[0129] (3) For the target scale, a multi-scale feature context focusing module MCFP is constructed, and the improved YOLOv5s backbone feature extraction network is input into the MCFP module, and the MCFP is constructed as follows: the CA attention mechanism is used to fuse the current feature layer and its adjacent feature layer, and the output feature map with attention weight in the width and height direction is obtained by multiplication weighting on the original feature map, then the output feature map is upsampled through the top-down path to help the model capture the transition from low-level to high-level detailed information to abstract semantics, and for the feature fusion process, the same size feature map is directly connected by using the skip connection;

[0130] (4) For the target low resolution, a multi-scale self-adaptive receptive field enhancement module SRFEM is constructed, the SRFEM module is input into the model detection head, and an improved truck detection model is formed; the SRFEM is constructed as follows: different sampling rate of the cavity convolution is used to extract feature information in parallel, then the softmax is used to calculate the weight to give different weights to each group of features, so that the module can adaptively select different receptive fields according to the size of the target, the output feature maps of different receptive fields are added layer by layer, and finally the output features in the channel dimension are spliced, and then added with the original feature map pixel by pixel to obtain the final output feature map;

[0131] The detection unit is configured to input a data set into the improved truck detection model to detect trucks in the monitoring image.

[0132] Technical details not described in detail in the embodiment can be referred to the method provided in the embodiment of the application.

[0133] Embodiment 3: The embodiment of the application also provides an electronic device, including a memory, a processor and a computer program stored in the memory and executable on the processor. It should be noted that when the processor executes the computer program, it corresponds to the specific steps of the method provided in the embodiment of the application, has the corresponding function modules and beneficial effects of the execution method. Technical details not described in detail in the embodiment can be referred to the method provided in the embodiment of the application.

[0134] Embodiment 4: The embodiment of the application also provides a computer readable storage medium, which stores a computer program. It should be noted that when the computer program is executed by the processor, it corresponds to the specific steps of the method provided in the embodiment of the application, has the corresponding function modules and beneficial effects of the execution method. Technical details not described in detail in the embodiment can be referred to the method provided in the embodiment of the application.

[0135] Embodiment 5: Finally, the application also proposes a computer program product comprising computer programs / instructions which, when executed by a processor, implement the steps of the low-resolution small target detection method based on the improved YOLO model.

[0136] The above description is only preferred embodiments of the present application, and it should be pointed out that, for those skilled in the art, without departing from the technical principles of the present application, a number of improvements and modifications can be made, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims

1. A lightweight truck detection method based on an improved YOLO model, characterized in that: include: S1. Build a multi-category truck dataset with annotations; S2. Replace all convolution operations in BackBone in the YOLOv5s network with GhostConv; S3. Design the C3Ghost module for use in the backbone feature extraction network of YOLOv5s. Specifically, design the GhostBottleNeck module, which consists of three layers: first, a Ghost module as an extension layer that increases the number of input feature map channels through linear transformation; second, a depthwise separable convolution with a stride of 2 is used for downsampling; and finally, a GhostModule is used to reduce the number of output channels to match the number of original input map channels, and the two are added element-wise. The designed GhostBottleNeck module replaces the BottleNeck module of the C3 module in the YOLOv5s network to generate the C3Ghost module. S4. Construct a multi-scale feature context focusing module MCFP for the diverse target scales. Input the improved YOLOv5s backbone feature extraction network from step S3 into the MCFP module. Constructing MCFP specifically involves: using the CA attention mechanism to fuse the current feature layer with its adjacent feature layer, and performing weighted multiplication on the original feature map to obtain an output feature map with attention weights in the width and height directions. Then, the output feature map is upsampled from the high-level semantic features through a top-down path and fused with the low-level features. Then, from the bottom up, the model is helped to capture the transition from detailed information from low to high layers to abstract semantics. Feature maps of the same size are directly connected using skip connections during the feature fusion process. S5. A multi-scale adaptive receptive field enhancement module (SRFEM) is constructed for low-resolution targets. The SRFEM module is fed into the model detection head to form an improved truck detection model. Specifically, the SRFEM is constructed by extracting feature information in parallel using dilated convolutions at different sampling rates. The softmax weighting is then used to assign different weights to each set of features, enabling the module to adaptively select different receptive fields based on the target scale. The output feature maps with different receptive fields are layered and added together. Finally, the output features are concatenated in the channel dimension and pixel-wise added to the original feature map to obtain the final output feature map. S6. Input the data set into the improved truck detection model to detect trucks in the surveillance image.

2. The lightweight truck detection method based on the improved YOLO model according to claim 1 is characterized in that: The specific steps of step S1 are as follows: Step S11: collecting images of medium and large trucks and tank trucks based on different shooting angles; Step S12: Use Labelme to label the image to obtain a label; Step S13: randomly divide the images into a training set, a test set, and a validation set in a ratio of 7:2:1 to form a truck-specific dataset.

3. The lightweight truck detection method based on the improved YOLO model according to claim 1 is characterized in that: The specific steps of step S3 are as follows: Step S31: First, generate some inherent feature maps through a convolution operation. Assume that the input feature map is n-dimensional, the number of maps is s, the output feature map is m-dimensional, and the convolution kernel size is k, and obtain the feature map Y' h'×w'×m ; Step S32: For the feature map Y' h'×w'×m Apply linear operations to obtain more feature maps, as shown in the formula: Among them, y' i represents the i-th channel feature map of Y'; Φ ij Represents the j-th linear operation used to generate the i-th Ghost feature map; Step S33: Outputting the Ghost module as the splicing result of the feature map obtained in step S31 and the Ghost feature map obtained in step S32; Step S34: For the two Ghost modules before and after, perform channel dimension increase and dimension reduction operations respectively, so that the number of output channels of the previous module is consistent with the number of input channels of the latter module, obtain the output feature map GhostBottleNeck, and apply it to the original network C3 module.

4. The lightweight truck detection method based on the improved YOLO model according to claim 1 is characterized in that: Step S4 is specifically as follows: Step S41: Assume {P1, P2, P3, P4} as the output of the backbone network, P5 is the upsampling result of P4, and feed PP1, P2, P3}, {P2, P3, P4}, and {P3, P4, P5} as input feature groups into the CA attention mechanism to fuse the multi-scale features of adjacent layers and capture long-range dependencies. Step S42: Use CA attention mechanism to input feature map F∈R C×H×W Perform global average pooling in the horizontal and vertical directions respectively to obtain feature maps in the width and height directions, and establish long-range dependencies of features; Step S43: concatenate the pooled feature maps in the channel dimension, use convolution to fuse features and reduce dimensionality, and feed the batch normalized feature map F1 into the Sigmoid activation function to obtain the feature map f; Step S44: Split the feature map f by height and width and perform 1×1 convolution to increase the dimension to obtain feature maps f h and f w , and then after Sigmoid activation function, we get the feature maps f h and f w At the height attention weight g h and the width attention weight g w ; Step S45: Multiply and weight the original feature map to obtain an output feature map with attention weights in the width and height directions. The formula is as follows: Among them, F' c (i, j) represents the feature response of pixel (i, j) in the feature map F at channel c; Represents the value of the i-th pixel in the horizontal direction of the feature at the c channel; Represents the value of the i-th pixel in the vertical direction of the feature at the c channel; Step S46: The three sets of feature maps {P1, P2, P3}, {P2, P3, P4} and {P3, P4, P5} respectively output by the attention mechanism are upsampled by the high-level semantic features through a top-down path and fused with the low-level features to improve the position accuracy of the low-resolution feature maps, and then help the model capture the transition from detailed information from low to high levels to abstract semantics from bottom to top. For feature maps of the same size in the feature fusion process, jump connections are used to directly establish connections.

5. The lightweight truck detection method based on the improved YOLO model according to claim 3 is characterized in that: Step S5 is specifically as follows: Step S51: For the three sets of feature maps output in step S4, dilated convolution combinations with corresponding dilation rates are set, i.e., R1 = (1, 2), R2 = (1, 2, 5), and R3 = (1, 2, 5, 8), and feature information is extracted in parallel using dilated convolutions with different sampling rates. Step S52: The channel weights of the feature branches are redistributed through the softmax function, so that the network dynamically selects the receptive field according to the target size, so that for larger targets, larger weights are allocated to the branches with larger expansion rates, and for smaller targets, larger weights are allocated to the branches with smaller expansion rates. R1=(1,2), the specific formula is as follows: Among them, a c represents the weight of the cth element in vector a; b c represents the weight of the cth element in vector b; a′+b′=1 Step S53: add the feature branches after recalibrating the channel weights pixel by pixel to compensate for the grid effect caused by the dilated convolution. Then, concatenate the added feature map with the original feature map. The formula is as follows: F′3=Cat(F,a′F1+b′F1) Step S54: Adjust the number of output feature channels through 1×1 convolution; The above are the processing steps for the first set of feature maps. For the remaining two sets of feature output maps, the weights of the corresponding channels are set respectively, and the processing steps are the same as described above.

6. A lightweight truck detection system based on an improved YOLO model, characterized in that: include: Dataset construction unit, used to construct a multi-category truck dataset with annotations; The truck detection model building unit is configured to perform the following actions: (1) Replace all convolution operations in BackBone in the YOLOv5s network with GhostConv; (2) Design the C3Ghost module to be applied to the backbone feature extraction network of YOLOv5s; specifically: design the GhostBottleNeck module, which consists of three layers: first, a Ghost module is used as an extension layer to increase the number of input feature map channels through linear transformation; second, a depthwise separable convolution with a stride of 2 is used for downsampling; finally, a GhostModule is used to reduce the number of output channels to match the number of original input map channels, and the two are added element by element; the designed GhostBottleNeck module is used to replace the BottleNeck module of the C3 module in the YOLOv5s network to generate the C3Ghost module; (3) A multi-scale feature context focusing module MCFP is constructed for the diverse target scales. The improved YOLOv5s backbone feature extraction network in step (2) is input into the MCFP module. The specific steps of constructing MCFP are as follows: the CA attention mechanism is used to fuse the current feature layer with its adjacent feature layer, and the original feature map is weighted by multiplication to obtain an output feature map with attention weights in the width and height directions. The output feature map is then upsampled from the high-level semantic features through a top-down path and fused with the low-level features. The model is then helped to capture the transition from detailed information from low to high layers to abstract semantics from the bottom up. For feature maps of the same size in the feature fusion process, jump connections are used to directly establish connections. (4) A multi-scale adaptive receptive field enhancement module SRFEM is constructed for the low-resolution target. The SRFEM module is fed into the model detection head to form an improved truck detection model. The SRFEM is constructed by: extracting feature information in parallel using dilated convolutions with different sampling rates, and then using softmax to calculate weights to assign different weights to each set of features, so that the module can adaptively select different receptive fields according to the scale of the target. The output feature maps with different receptive fields are layered and added together. Finally, the output features are spliced ​​in the channel dimension and then added to the original feature map pixel by pixel to obtain the final output feature map. The detection unit is used to input the data set into the improved truck detection model to detect trucks in the monitoring image.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

9. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Method and system for detecting artificial small target in SAR (Synthetic Aperture Radar) image

    CN113567984A

  • Lightweight traffic sign detection method, storage medium and system

    CN116453091A