Factory vehicle detection method based on improved YOLO v8
By introducing the receptive field collaborative attention convolution operation and the center pixel difference convolution module into the YOLO v8 model, and replacing the head with the RT-DETR head, the problem of low vehicle detection accuracy in the factory environment is solved, and higher accuracy is achieved. detection accuracy and generalization ability.
Patent Information
- Application Number
- CN202411409409.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-01-24
AI Technical Summary
The existing real-time vehicle detection model has problems such as vehicle target loss and low detection accuracy in factory environment, resulting in large vehicle positioning errors.
The factory vehicle detection method based on improved YOLO v8 is adopted. By introducing the improved receptive field collaborative attention convolution operation RFCAConv module in the backbone network, the central pixel differential convolution CPDC module is introduced in the neck, and the head is replaced with real-time The head of the detection algorithm RT-DETR.
It improves the accuracy of vehicle detection in the factory environment, solves the problem of detection failure due to partial occlusion, reduces the impact of complex background interference, and improves the generalization effect of the model.
Smart Images

Figure CN119360301A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a factory vehicle detection method based on improved YOLO v8. Background Art
[0002] The demand for intelligent management of vehicles in factories is constantly increasing. On the one hand, for daily factory production, the efficiency of factory production scheduling can be greatly improved by detecting operating vehicles and obtaining vehicle status information and real-time location; on the other hand, by real-time detection of external vehicles, the tracking and positioning of external vehicles can be further realized, and abnormal conditions of various external vehicles can be discovered at any time, the location of the accident can be located, and safety measures can be taken in time to ensure the safety of factory employees and equipment and improve the safety management level of the factory.
[0003] However, the existing real-time vehicle detection model has various limitations when performing real-time vehicle detection in a factory environment, such as vehicle target loss and low detection accuracy, which leads to large subsequent vehicle positioning errors. Therefore, the research on real-time vehicle detection methods for factories is of great significance. Summary of the invention
[0004] The present invention aims to solve the problems existing in the above-mentioned prior art and provide a factory vehicle detection method based on improved YOLO v8.
[0005] The technical solutions adopted in the present invention are:
[0006] A factory vehicle detection method based on improved YOLO v8, comprising the following steps:
[0007] S1. Collect surveillance pictures of factory vehicles, annotate the selected surveillance pictures, and divide the data set into training set, validation set and test set in a ratio of 8:1:1;
[0008] S2. Based on the network structure of the original YOLO v8 algorithm, improvements are made for the factory vehicle detection target to obtain an improved YOLO v8 detection model. The improvements are:
[0009] 1. In the backbone network of the YOLO v8 algorithm, the improved RFCAConv module is used to replace the original convolution operation, and the C2f module is improved to obtain the new C2f_RFCAConv module;
[0010] 2. The center pixel differential convolution (CPDC) module is introduced into the neck of the YOLO v8 algorithm and applied to high-level semantic feature maps;
[0011] 3. Replace the head of the YOLO v8 algorithm with the head of the real-time detection algorithm RT-DETR;
[0012] S3. Use the data set obtained in step S1 to train and test the improved YOLO v8 detection model.
[0013] Furthermore, the improved RFCAConv module integrates the receptive field collaborative attention mechanism RFCA into the original convolution operation;
[0014] The C2f_RFCAConv module replaces the multiple Bottleneck structure stacks in the original C2f module with multiple Bottleneck_RFCAConv structure stacks, and acts on feature extraction through the stacking of multiple Bottleneck_RFCAConv structures;
[0015] The CPDC module includes a central convolution module, a standard convolution module and a feature fusion module;
[0016] The RT-DETR header includes: uncertainty minimum query, Transformer decoder and prediction header.
[0017] Furthermore, the receptive field collaborative attention mechanism RFCA directs the attention of the collaborative attention mechanism to the receptive field spatial features.
[0018] Furthermore, the Bottleneck_RFCAConv structure is based on the original Bottleneck and incorporates the RFCAConv module.
[0019] Furthermore, the central convolution module is used to calculate the sum of weights of all pixels except the central pixel in the convolution kernel;
[0020] The standard convolution module uses the original standard convolution kernel to perform convolution operations on the input image;
[0021] The feature fusion module subtracts the result of the central convolution from the result of the standard convolution and combines it with the original input image to obtain the final output.
[0022] Furthermore, the uncertainty minimum query is used to filter out the required encoder features, which are then input into the decoder;
[0023] The Transformer decoder includes: a multi-head self-decoding attention layer, an encoding and decoding attention layer, and a feedforward network;
[0024] The prediction head includes a feed-forward prediction network.
[0025] Furthermore, in S3, the training set images are input into the improved YOLO v8 detection model, and the corresponding hyperparameters are set for training to obtain the final model weights; the model weights are loaded, and the test set images are input into the improved YOLO v8 detection model, and the category, confidence, bounding box and coordinate results of the vehicle target are output to realize factory vehicle detection.
[0026] The present invention has the following beneficial effects:
[0027] The present invention adopts an improved receptive field collaborative attention convolution operation RFCAConv module in the backbone network to replace the traditional convolution operation and improves the C2f module to obtain a new C2f_RFCAConv module, so as to solve the problem of failure of detection due to partial occlusion and failure to capture sufficient vehicle feature information during vehicle detection in a factory environment, thereby improving the detection accuracy; the present invention introduces a central pixel differential convolution CPDC module in the neck and applies it to a high-level semantic feature map, thereby reducing the influence of complex background interference during vehicle detection; the present invention uses the head of the real-time detection algorithm RT-DETR in the head, fully considers the contextual information, improves the generalization effect of the model, and avoids the situation of excessive suppression of real targets during post-processing; the present invention makes a series of improvements on the detection of vehicles in factories, and proposes a factory vehicle detection method based on improved YOLO v8, which effectively improves the accuracy of vehicle detection in factories. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a flow chart of the present invention.
[0029] Figure 2 To improve the model structure diagram.
[0030] Figure 3 This is the structural diagram of the RFCAConv module.
[0031] Figure 4 This is the structural diagram of the C2f_RFCAConv module.
[0032] Figure 5 Schematic diagram of Bottleneck_RFCAConv structure.
[0033] Figure 6 This is the structural diagram of the center pixel differential convolution CPDC module.
[0034] Figure 7 This is the detailed structure diagram of the head of the real-time detection algorithm RT-DETR.
[0035] Figure 8 The overall workflow diagram of the improved YOLO v8 factory vehicle detection model. DETAILED DESCRIPTION
[0036] The present invention will be further described below in conjunction with the accompanying drawings.
[0037] The invention discloses a factory vehicle detection method based on improved YOLO v8, which can effectively improve the accuracy of vehicle detection in a factory environment, and solve the problem of missed detection in the actual detection process on the basis of meeting the real-time requirements of factory vehicle detection.
[0038] like Figure 1 As shown, the present invention comprises the following steps:
[0039] S1: Collect surveillance images of factory vehicles, select images for manual annotation, and divide the data set;
[0040] S2: Based on the network structure of the original YOLO v8 algorithm, the improved YOLO v8 factory vehicle detection model is obtained for the factory vehicle detection target;
[0041] S3: Use the dataset obtained in step S1 to train and test the improved YOLO v8 factory vehicle detection model.
[0042] Step S1 is specifically as follows:
[0043] Collect factory surveillance videos and filter out the required vehicle parts; extract surveillance images of factory vehicles by frame and filter out those that meet the requirements. Use LabelImg to manually annotate the images. The annotated label categories mainly include vehicles and workers. The annotated label format is txt format to facilitate training. The annotated data set is divided into training set, validation set and test set in a ratio of 8:1:1.
[0044] like Figure 2 , Figure 2 The following is a diagram of the improved model structure. The improvements of the improved YOLO v8 detection model are:
[0045] (1) The improved receptive field collaborative attention convolution operation RFCAConv module is used to replace the traditional convolution operation in the backbone network of the original YOLO v8 algorithm, and the C2f module is improved to obtain the new C2f_RFCAConv module. This solves the problem of partial occlusion during vehicle detection in the factory environment, which causes insufficient vehicle feature information to be captured and leads to detection failure, and improves the detection accuracy.
[0046] (2) The center pixel differential convolution (CPDC) module is introduced into the neck of the original YOLO v8 algorithm and applied to high-level semantic feature maps, reducing the impact of complex background interference during vehicle detection.
[0047] (3) The head of the original YOLO v8 algorithm is replaced with the head of the real-time detection algorithm RT-DETR, which fully considers the context information, improves the generalization effect of the model, and avoids the situation of excessive suppression of real targets during post-processing.
[0048] like Figure 3 , the processing flow of the RFCAConv module is as follows:
[0049] First, perform group convolution GroupConv on the input to extract the spatial features of the receptive field, map the original features to new features, and then adjust the shape AdjustShape to make the height and width of the features k times the original.
[0050] Then use average pooling AvgPool to aggregate the global information of each receptive field feature from the width and height dimensions, and then combine them together, and use a 1×1 convolution operation to interact with the information and split it into two parts. Then perform Sigmoid activation on these two parts and generate attention weights to emphasize the importance of each feature in the receptive field feature.
[0051] Finally, the output of Sigmoid and the output after reshaping are reweighted to obtain the feature map.
[0052] However, at this time, the height and width of the feature are k times the original, so a convolution operation with a stride of k is used to extract the feature information.
[0053] The formula of RFCAConv is as follows:
[0054] X′=AdjustShape(ReLU(Norm(GroupConv(X)))) (1)
[0055] XX HW ==HWAAvvggPPooooll((XX″)) (2)
[0056] Z=NonLinear(Norm(Conv(Concat(X H ,X W )))) (3)
[0057] Z H ,Z W =Split(Z) (4)
[0058] A H =Sigmoid(Conv(Z H )) (5)
[0059] A W=Sigmoid(Conv(Z W ))
[0060] Y = Conv(X′×A H +X′×A W ) (6)
[0061] Among them, X is the input feature map, X′ is the feature map after group convolution and shape adjustment, and X H and X W They are the feature maps after average pooling in the height direction and width direction, Z is the feature map obtained after splicing and further processing, and Z H and Z W It is the feature map segmented in height and width directions, A H and A W are the attention weights in the height and width directions, and Y is the final output feature map.
[0062] like Figure 4 ,The C2f_RFCAConv module inherits the basic structure of C2f and expands on it to include multiple Bottleneck_RFCAConv structures.
[0063] The feature map is input into a 1×1 convolution block to generate an intermediate feature map, and the channel of the intermediate feature map is split into two parts: the main path part and the residual path part. The main path part is processed by multiple Bottleneck_RFCAConv structures for feature extraction, and the residual path part is directly fused with the result of the main path processing to output the final feature map.
[0064] like Figure 5 The Bottleneck_RFCAConv structure is an enhanced bottleneck structure that integrates the RFCAConv module based on the original Bottleneck and is used to improve the performance of feature extraction and convolution operations.
[0065] The first-layer RFCAConv module directly extracts features on the input feature map, and the second-layer RFCAConv module adjusts the number of channels of the feature map to achieve feature fusion between channels. Finally, the input feature map is fused with the feature map after two convolution operations to output the result.
[0066] like Figure 6 ,The CPDC module includes a central convolution module, a standard convolution module, and a feature fusion module.
[0067] The central convolution module is used to calculate the sum of the weights of all pixels in the convolution kernel except the central pixel, and then perform a convolution operation without padding. It is usually used to calculate local features.
[0068] The standard convolution module uses the original convolution kernel to perform a convolution operation on the input image.
[0069] The feature fusion module subtracts the result of the center convolution from the result of the standard convolution and combines the result with the original input image to obtain the final output.
[0070] The formula of the central convolution module is as follows:
[0071]
[0072] Among them, x i is the original pixel of the input, ω i is the weight in the convolution kernel of size k×k. 1 , x 1 ′),(x 2 , x′ 2 ),...,(x n , x′ n ) is a set of pixel pairs selected from the current local block, and n≤k×k.
[0073] like Figure 7 ,The head of RT-DETR includes: uncertainty minimum query, Transformer decoder and prediction head.
[0074] The uncertainty minimum query is used to filter out the required encoder features, which are then input into the decoder.
[0075] The Transformer decoder consists of a multi-head self-decoding attention layer, an encoder-decoder attention layer, and a feedforward network.
[0076] The prediction head mainly consists of a feed-forward prediction network.
[0077] like Figure 7 ,The multi-head self-decoding attention layer is used to model the relationship between the positions inside the decoder, enabling the decoder to autonomously capture features between different positions.
[0078] The multi-head self-decoding attention layer follows these steps:
[0079] First, the input feature map X is linearly transformed to generate query Q, key K and value V. Then in the multi-head self-attention mechanism, Q, K, V are mapped to the subspace of each head through different weight matrices, and each head calculates attention independently, with the purpose of parallel processing and capturing different attention modes. The formula is as follows:
[0080]
[0081] in, is a scaling factor used to stabilize the calculation. The results of all these heads are concatenated and integrated through a linear layer to get the final self-attention output
[0082] Next, in order to improve computational efficiency, the Q, K, and V of each head are further decomposed into multiple smaller sub-blocks, and attention calculations are performed independently on each sub-block. Finally, the attention results of all sub-blocks are aggregated and then linearly transformed to generate the final output.
[0083] like Figure 7 ,The encoder-decoder attention layer is responsible for aligning the global features output by the encoder with the query of the decoder, extracting relevant information through the attention mechanism, helping the decoder to better understand the input features.
[0084] The encoder-decoder attention layer follows these steps: First, the output of the previous layer is used as the input feature X of the decoder. dec , generate query Q through linear transformation dec , and at the same time, by outputting the feature X to the encoder enc Perform linear transformation to generate key K enc Sum value V enc ;
[0085] Next, similar to self-attention, Q dec , X enc and K enc It is split into multiple heads, each of which independently performs the following computations, including: computing the dot product of the decoder query and the encoder key, softmax normalization, and weighted summing of the encoder values.
[0086]
[0087] The results of these heads are concatenated and integrated through a linear layer to obtain the final cross-modal attention output, which is concatenated and linearly transformed to obtain the encoder information associated with the decoder query.
[0088] like Figure 8 And continue to read Figure 2 ,The overall workflow of the improved YOLO v8 factory vehicle detection model in step S2 is divided into feature extraction using the backbone network, multi-scale feature fusion using the neck and the head for target category prediction, and generating the target’s bounding box and coordinates.
[0089] The process of feature extraction using the backbone network is as follows:
[0090] First, a standard convolutional layer is used to perform preliminary feature extraction on the input image and the number of channels is expanded to 64. Secondly, the number of channels is gradually increased to 1024 through multiple layers of the RFCAConv module to enhance the model's ability to understand large objects and complex backgrounds. At the same time, each layer of the RFCAConv module is followed by a layer of the C2f_RFCAConv module.
[0091] The C2f_RFCAConv module performs multiple nonlinear transformations on the feature map through the multi-layer Bottleneck_RFCAConv structure and retains important short connections to further extract richer deep features; finally, the SPPF module is used to perform multi-scale pooling on the feature map to provide multi-scale global features.
[0092] The process of multi-scale feature fusion using the neck is as follows:
[0093] First, the sum of the weights of all pixels in the convolution kernel except the central pixel is calculated to obtain a central convolution kernel weight, and then a convolution operation is performed to obtain a central convolution result; secondly, the original convolution kernel is used to perform a convolution operation on the input image to obtain a standard convolution result; finally, the standard convolution result is subtracted from the central convolution result and combined with the original input to obtain the final output.
[0094] The process of using the head to predict the target category and generate the bounding box and coordinates of the target is as follows:
[0095] First, after the feature map is processed and fused by the neck, the minimum uncertainty query is used to screen out the required encoder features and then input into the decoder; the decoder is processed by the multi-head self-decoding attention layer and then input into the encoder-decoder attention layer, and the pairwise relationship between the input embeddings is used to perform global reasoning on all objects to obtain the output embedding; finally, the output embedding is used as the input of the prediction feedforward network and they are independently converted into the coordinates and category labels of the detection box through the feedforward network, so as to obtain the final prediction result.
[0096] The operation of step S3 is: setting the data set path, inputting the training set images into the improved YOLO v8 factory vehicle detection model; setting the corresponding hyperparameters for training; observing the training progress of the network through the loss curve until the model converges; retaining the optimal model weight file obtained by the final training; loading the optimal model weight file, and inputting the test set images into the trained network; performing feature extraction through the backbone network; and then performing multi-scale feature fusion through the neck; finally, the category, confidence, bounding box and coordinate results of the vehicle target are output by the head to realize factory vehicle detection; the performance parameters of the improved YOLO v8 factory vehicle detection model are counted, and compared with various existing mainstream target detection methods. The comparison results are shown in Table 1:
[0097] Table 1 Comparison of detection performance of different detection methods
[0098]
[0099] It can be seen from the test results that the present invention further improves the detection accuracy of factory vehicles on the basis of meeting the real-time requirements of factory vehicle detection.
[0100] The method of the present invention solves the problems existing in the existing detection methods in the vehicle detection task of smart factories. The algorithm first improves the original YOLOv8 backbone network by combining the receptive field collaborative attention convolution operation RFCAConv, which solves the problem that the vehicles in smart factories are partially occluded, resulting in insufficient effective features captured and finally detection failure; then a central pixel differential convolution CPDC module is added to the neck to highlight the inspected vehicle target by capturing texture details and semantic information, reducing the impact of background interference on factory vehicle detection. Finally, the head of the original YOLOv8 is replaced with the head of the real-time detection algorithm RT-DETR, which realizes the combination of contextual information and improves the accuracy of factory vehicle detection. At the same time, it also solves the problem of excessive suppression of real targets when there are many vehicle targets in the factory and the overlapping detection frames need to be processed, laying the foundation for the subsequent vehicle positioning in the factory.
[0101] The above description is only a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements without departing from the principle of the present invention, and these improvements should also be regarded as within the protection scope of the present invention.
Claims
1. A factory vehicle detection method based on improved YOLO v8, characterized by: The following steps are involved: S1. Collect monitoring pictures of factory vehicles, annotate the selected monitoring pictures, and divide the data set into training set and test set; S2. Based on the network structure of the YOLO v8 algorithm, an improvement is made for the factory vehicle detection target to obtain an improved YOLO v8 detection model. The improvements are: 1) In the backbone network of the YOLO v8 algorithm, the improved RFCAConv module is used to replace the original convolution operation, and the C2f module is improved to obtain the new C2f_RFCAConv module; 2) The center pixel differential convolution (CPDC) module is introduced into the neck of the YOLO v8 algorithm and applied to high-level semantic feature maps; 3) Replace the header of the YOLO v8 algorithm with the header of the real-time detection algorithm RT-DETR; S3. Use the data set obtained in step S1 to train and test the improved YOLO v8 detection model.
2. The factory vehicle detection method based on improved YOLO v8 as claimed in claim 1, characterized in that: The improved RFCAConv module integrates the receptive field collaborative attention mechanism RFCA into the original convolution operation; The C2f_RFCAConv module replaces the multiple Bottleneck structure stacks in the original C2f module with multiple Bottleneck_RFCAConv structure stacks, and acts on feature extraction through the stacking of multiple Bottleneck_RFCAConv structures; The CPDC module includes a central convolution module, a standard convolution module and a feature fusion module; The RT-DETR header includes: uncertainty minimum query, Transformer decoder and prediction header.
3. The factory vehicle detection method based on improved YOLO v8 as claimed in claim 2, characterized in that: The receptive field collaborative attention mechanism RFCA directs the attention of the collaborative attention mechanism to the receptive field space features.
4. The factory vehicle detection method based on improved YOLO v8 as claimed in claim 2, characterized in that: The Bottleneck_RFCAConv structure is based on the original Bottleneck and integrates the RFCAConv module.
5. The factory vehicle detection method based on improved YOLO v8 as claimed in claim 2, characterized in that: The central convolution module is used to calculate the sum of weights of all pixels in the convolution kernel except the central pixel; The standard convolution module uses the original standard convolution kernel to perform convolution operations on the input image; The feature fusion module subtracts the result of the central convolution from the result of the standard convolution and combines it with the original input image to obtain the final output.
6. The factory vehicle detection method based on improved YOLO v8 as claimed in claim 2, characterized in that: The uncertainty minimum query is used to filter out the required encoder features, which are then input into the decoder; The Transformer decoder includes: a multi-head self-decoding attention layer, an encoding and decoding attention layer, and a feedforward network; The prediction head includes a feed-forward prediction network.
7. The factory vehicle detection method based on improved YOLO v8 as claimed in claim 2, characterized in that: In S3, the training set images are input into the improved YOLO v8 detection model, and the corresponding hyperparameters are set for training to obtain the final model weights; The model weights are loaded, and the test set images are input into the improved YOLO v8 detection model. The category, confidence, bounding box and coordinate results of the vehicle target are output to realize factory vehicle detection.
Citation Information
Cited By
Driver distraction behavior detection method and system based on improved YOLOv8 model
CN120107937A
A driver distraction behavior detection method and system based on improved YOLOv8 model
CN120107937B