Dangerous chemical vehicle detection method based on improved YOLOv5 algorithm

By introducing the RFEB structure and separable attention mechanism into the YOLOv5 algorithm, the problems of low detection accuracy and high computational cost in the detection of hazardous chemical vehicles are solved, achieving higher detection accuracy and efficiency, and adapting to the detection needs of targets of different sizes.

CN117292335BActive Publication Date: 2025-11-28ZHIXING TECHNOLOGY (CHANGSHA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311280782.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-28
Publication Date
2025-11-28
Estimated Expiration
2043-09-28

AI Technical Summary

Technical Problem

Existing vehicle detection algorithms suffer from low detection accuracy, low efficiency, and high computational overhead in the detection of hazardous chemical vehicles, especially when dealing with overlapping vehicles and small targets.

Method used

An improved YOLOv5 algorithm is adopted, which expands the receptive field by introducing an RFEB structure in the back bone and introduces a separable attention mechanism in the model head. This combines scale-aware, spatial-aware, and task-aware attention mechanisms to improve detection accuracy and efficiency.

Benefits of technology

It effectively solves the problem of mismatch between the receptive field and the target object, improves the model's ability to express the features of hazardous chemical vehicles and the detection accuracy, and enhances the accuracy and stability of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117292335B_ABST
    Figure CN117292335B_ABST
Patent Text Reader

Abstract

The application discloses a hazardous chemical vehicle detection method based on an improved YOLOv5 algorithm, which comprises the following steps: S1, naming the obtained data as Hazardous Vehicles, and performing pretreatment to obtain a processed data set divided into four categories; S2, a traditional YOLOv5 model architecture is built, and an RFEB module is introduced in the backbone network part; S3, a separable attention mechanism is introduced, and the attention mechanisms of scale perception, spatial perception and task perception are unified into the head; S4, the built model is trained on the training set and verified on the test set, and the prediction of the hazardous chemical vehicle is realized. Compared with the prior art, in the backbone network, the RFEB structure solves the mismatching problem of small objects and receptive fields on low-resolution feature maps by designing different dilated convolution structures; in the model head, the separable attention mechanism is introduced, the attention mechanisms of scale perception, spatial perception and task perception are unified into the head, so that the perception ability and detection precision of the head are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of target detection, and particularly relates to a dangerous chemical vehicle detection method based on an improved YOLOv5 algorithm. BACKGROUND

[0002] With the increasing standardization of production, transportation and use of dangerous chemicals, the demand for dangerous chemicals in various industries is increasing day by day. However, accidents of dangerous chemical transportation vehicles occur frequently, causing serious personnel casualties and property losses, posing a great threat to environmental safety and human health, and attracting high attention from the society. Due to the increasing number of dangerous chemical transportation vehicles and the complexity of transportation routes, their safety is difficult to guarantee, so real-time monitoring of dangerous chemical transportation vehicles during driving has become an important research direction.

[0003] Target detection, as one of the core tasks in the field of computer vision, aims to automatically identify specified target objects from images or videos and perform positioning and classification. The emergence of this technology brings significant benefits in dangerous chemical vehicle detection. First, it can quickly and accurately identify dangerous chemical vehicles, saving a lot of human resources and time cost, and improving detection efficiency. Secondly, through the automated process, the need for human intervention is reduced, the risk of misjudgment is reduced, and the reliability and accuracy of detection are improved. In addition, dangerous chemical vehicle detection technology has a wide application prospect in practical applications, especially in the fields of traffic management and public safety. For example, in traffic management, this technology can be used to detect dangerous chemical vehicles in real time to avoid their entry into urban areas or other restricted areas, thereby protecting the life safety and property safety of urban residents; in the field of public safety, this technology can be used to monitor and detect the driving track and transportation route of dangerous chemical vehicles to prevent them from being used by terrorists or other personnel for destruction and attack.

[0004] Currently, vehicle target detection methods can be roughly divided into two categories, namely two-stage target detection algorithm and single-stage target detection algorithm. Among them, Choudhury et al. proposed a cascade algorithm based on Haar features for vehicle detection, which combines the Haar features of multiple regions of interest in the video frame into a cascade, and uses a classifier to determine whether the corresponding candidate region contains a target vehicle. Zhang Fukai et al. proposed a single-stage deep neural network DF-YOLOv3 model to realize real-time detection of vehicles. This algorithm fuses six convolution feature maps of different scales and the corresponding feature maps in the residual network as a feature pyramid to complete the vehicle detection task. Wang et al. proposed a vehicle detection algorithm based on deep belief network, which designed and used a 2D-DBN architecture with a second-order plane as input, and used a bilinear projection method to determine the size of the deep architecture to improve the success rate of vehicle detection. Fei et al. aimed at the problem that the network has poor recognition for untrained data, and used a bilinear module to replace the AlexNet part in the original network to improve the fine-grained feature extraction ability of the model, and then generated hash codes by matching the features to realize fine-grained feature extraction of the vehicle. Yin et al. proposed a single-stage multi-frame detector FD-SSD algorithm based on feature fusion and dilated convolution, which uses VGG-16 as the backbone network to extract features, and uses a deformable convolution network to better adapt to small object shapes. Yawen et al. proposed a method of extracting the features of the target vehicle by using the Scale-Invariant Feature Transform (SIFT) algorithm, combining the Gaussian pyramid with the sliding window mechanism, using support vector machines to classify feature vectors, and finally using a non-maximum suppression algorithm to detect the target vehicle. Liu et al. proposed an SSD (Single Shot MultiBox Detector, SSD) target detection algorithm, which classifies and regresses the bounding boxes of the features output by each layer of the feature extraction network, and fuses features of different scales to obtain accurate target positions. Dong et al. proposed an improved lightweight YOLOv5 vehicle detection algorithm, which introduces C3Ghost and Ghost modules in its neck to reduce floating point operations (FLOP) in the feature channel fusion process and enhance feature expression ability.

[0005] Although the target detection algorithm based on deep learning has made significant breakthroughs in the field of vehicle detection, in practical applications, the high accuracy and real-time performance of vehicle recognition are still affected by vehicle overlap and small targets. Therefore, it is imperative to design a dangerous chemical vehicle detection algorithm with high detection accuracy and low computational overhead. SUMMARY

[0006] The application aims to provide an improved dangerous chemical vehicle detection method to solve the problems of low detection accuracy, low efficiency and high maintenance cost of traditional vehicle detection technology, and the execution result is more accurate. In order to achieve the above-mentioned purpose, the application provides the following technical scheme:

[0007] A dangerous chemical vehicle detection method based on an improved YOLOv5 algorithm, comprising the following steps:

[0008] S1, the data obtained are named Hazardous Vehicles, and are preprocessed to obtain a processed data set containing four categories of Oil truck, Big truck, Tiny truck and Car. The image is labeled by using a labeling tool Lableme, and the labeling result is converted into a text format, including target id, position coordinates and height information. Finally, the data set is divided according to the ratio of 6:2:2, and is used for training, verifying and testing the model respectively;

[0009] S2, a traditional YOLOv5 model architecture is built, and an RFEB (Residual Feature Enhancement Block) structure receptive field expansion module is introduced in the Back Bone part. It adopts an expanded residual structure as a base block, and constructs local and global residual structures. By combining multiple RFEB structures, the receptive field is effectively expanded. Different expansion rates are used for expansion convolution at different levels to match the detection requirements of targets of different sizes;

[0010] S2.1, the RFEB structure of the application solves the problem of small object disappearance in deep feature maps by using different expansion rates. Specifically, we use base blocks with expansion rates of 1, 2 and 3 as components of the RFEB structure, and use them to receive the outputs of the effective feature layers p3, p4 and p5 in the backbone network. This reorganized structure can effectively process the feature information of small objects.

[0011] S3, after the YOLOv5 model architecture and the RFEB structure, a separable attention mechanism is introduced, which unifies the scale perception, spatial perception and task perception attention mechanisms into the head to improve the perception ability and detection accuracy of the head;

[0012] S3.1, in the one-stage detector, the sequence superposition of the separable attention mechanism is adopted twice. Each attention mechanism sequence contains a scale perception attention module, a spatial perception attention module and a task perception attention module. Through this reorganized way, we can better utilize the attention mechanism to extract features and achieve better results in the detection task;

[0013] S4, utilize the built model to train on the training set and verify on the test set, realize the prediction of the dangerous chemical vehicle.

[0014] The beneficial effects of the present application are:

[0015] The advantages and effects of the present application are that the dangerous chemical vehicle detection algorithm faces the problem of mismatch between the detector receptive field and the target object, and improves the expression ability of the model to the dangerous chemical vehicle features, which specifically shows that:

[0016] (1) In the main network, the RFEB structure solves the mismatch problem of small objects and receptive fields on low-resolution feature maps by designing different dilated convolution structures.

[0017] (2) In the model head, the present application introduces a separable attention mechanism, which unifies the attention mechanisms of scale perception, spatial perception and task perception into the head to improve the perception ability and detection accuracy of the head. BRIEF DESCRIPTION OF DRAWINGS

[0018] Figure 1 It is a dangerous chemical vehicle detection flow chart;

[0019] Figure 2 It is a structure diagram of the improved YOLOv5 model;

[0020] Figure 3 It is a RFEB structure diagram;

[0021] Figure 4 It is a structure diagram of the separable attention mechanism; DETAILED DESCRIPTION

[0022] The present application will be further illustrated below in combination with the drawings and specific embodiments.

[0023] As shown in the specific steps of the present application are as follows: Figure 1

[0024] S1, the data obtained is named Hazardous Vehicles, and is preprocessed to obtain a processed data set containing Oiltruck, Bigtruck, Tinytruck and Car four categories. The image is labeled using the labeling tool Lableme, and the labeling result is converted into text format, including target id, position coordinates and height information. Finally, the data set is divided according to the ratio of 6:2:2, which is used to train, verify and test the model, and the specific steps are as follows:

[0025] ​S1.1, draw the bounding box or key points of the target using the rectangle tool, polygon tool, point tool, etc. in the labeling tool. According to the data type, label the target or attribute of different vehicle types;

[0026] S1.2, add label information: after creating the label, add the category of the vehicle and the label, annotation, attribute, etc. information, and specify a unique id for each target;

[0027] S1.3, save the labeling result: when the labeling is completed, save the labeling result as a JSON file;

[0028] S2, build a traditional YOLOv5 model architecture, and introduce a receptive field expansion module in the BackBone part. It uses an expanded residual structure as a basic block, and constructs a local and global residual structure. By combining multiple RFEB structures, the receptive field is effectively expanded. On different levels, different expansion rates are used for expansion convolution to match the detection needs of targets of different sizes. The specific steps are as follows:

[0029] S2.1, YOLOv5 uses CSPDarkNet53 as the main network, and uses C3 module for feature extraction. The role of C3 module is to increase the depth and receptive field of the network to improve the feature extraction ability. However, the down-sampling process will cause the spatial resolution of the feature map to decrease and the target and background information to be fused. In order to solve this problem, the present application proposes to expand the receptive field using RFEB structure to obtain more rich semantic information while maintaining the resolution of the feature map. It uses an expanded residual structure as a basic block, and constructs a local and global residual structure. On different levels, different expansion rates are used for expansion convolution to meet the detection needs of targets of different sizes. In order to balance the computational complexity and detection accuracy, the present application designs the same expansion rate to adjust the receptive field of the detector. This means that the same expansion rate is used on different levels to control the computational complexity and make the detector adapt to the detection needs of targets of different sizes. The RFEB structure formula with three basic blocks is described as:

[0030]

[0031] DB2=DB1+DB'2

[0032]

[0033] where, DB i is a basic block, and i is the serial number of the basic network in RFEM. represents the input of the jth RFEM on the ith layer.

[0034] S2.1.1, the basic composition of RFEB structure is composed of 1*1 convolution, BN, ReLu, dilated convolution and residual structure;

[0035] S3, after the YOLOv5 model architecture and RFEB structure, a separable attention mechanism is introduced, which unifies the scale perception, spatial perception and task perception attention mechanism into the head to improve the perception ability and detection accuracy of the head.

[0036] S3.1, design scale perception attention, dynamically fuse features of different scales according to the importance of semantics:

[0037]

[0038] Where f(·) is a linear function approximated by a 1*1 convolution layer, is a hard-sigmoid function.

[0039] S3.2, on the basis of fused features, we apply another spatial perception attention module to focus on the discriminative regions that consistently coexist between spatial locations and feature layers. Since the spatial perception attention module needs to process high-dimensional features, the present application decomposes the module into two steps. First, use deformable convolution to make attention learning sparse to reduce computational complexity and memory consumption. Then cross-level feature aggregation is performed at the same spatial location:

[0040]

[0041] Where k is the number of sparse sampling positions, p k +Δp k is the position moved by self-learning space, Δp is learned by deformable convolution, focusing on the discriminative region, and Δm k represents the importance of the position p k self-learning;

[0042] S3.3, in order to realize joint learning and summarize different representations of objects, the present application deploys a task perception attention at the end. It dynamically opens or closes feature channels to support different tasks:

[0043] pi C (F)·F=max(α 1 (F)·F C +β 1 (F), alpha 2 (F)·F C +β 2 (F))

[0044] Where F CFor the features split on the C-th channel, [alpha 1 , alpha 2 , beta 1 , beta 2 ] T = theta (cdot) is a super function that learns the control activation threshold. The implementation of theta (cdot) is referenced in the literature

[34] , first global average pooling is performed on LxS dimensions to reduce the dimension, then two fully connected layers and a normalization layer are used, and finally a shifted sigmoid function is applied to normalize the output to [-1, 1];

[0045] S3.4, the application converts the attention function into three sequential attentions, each of which only focuses on one perspective:

[0046] W(F) = pi C (pi S (pi L (F) cdot F) cdot F) cdot F

[0047] Where pi C , pi S , pi L are the attention functions applied to the horizontal, spatial and channel respectively.

[0048] The three attention mechanisms pi L , pi S and pi C are stacked twice in sequence and multiplied by and summed with the original feature vector F to obtain the weighted feature vector W(F), in which the features at each position are weighted and fused to better represent the important features of the dangerous chemical vehicle.

[0049] S3.5, the application proposes a separable attention mechanism, which processes the feature map through scale perception, spatial perception and task perception attention modules. The scale perception attention module enhances the sensitivity to the scale difference of the foreground object, the spatial perception attention module focuses on the features of the foreground object at different spatial positions, and the task perception attention module forms different activations according to the requirements of the downstream task. The three attention mechanisms are applied sequentially and weightedly fused with the original feature vector F, so that the features at each position are weighted and fused to better represent the important features of the dangerous chemical vehicle. This attention mechanism improves the detection accuracy of the dangerous chemical vehicle and improves the detection precision and stability.

[0050] S3.7, the scale perception attention module is composed of a hard sigmoid function and a 1*1 convolution. These components are used to realize the perception and adjustment of scale information;

[0051] S3.8, the spatial perception attention module is composed of the following components: offset, sigmoid function, index module and 3*3 convolution. These components work together to realize the perception and adjustment of spatial information.

[0052] S3.9, the task perception attention mechanism is composed of the following components: average pooling, full connection, ReLU activation function and Normalize normalization. These components work together to realize the perception and processing of task-related information;

[0053] S4, use the model built to train on the training set and verify on the test set, realize the prediction of dangerous chemical vehicle. The specific steps are as follows:

[0054] S4.1, prepare the data set: convert the labeled data set into.txt format according to the model;

[0055] S4.2, configure the data set: first create a new data set configuration file in the data file, and name it Car.yaml. Modify the configuration file and define the vehicle category as 4, and the category name as Car, Oiltruck, Bigtruck, Tinytruck;

[0056] S4.3, define the RFEB structure and the separable attention mechanism and call in the main function;

[0057] S4.4, configure the network: create a new network configuration file in the models file, and change the RFEB structure and the separable attention mechanism network structure in the configuration file;

[0058] S4.4, modify the training parameters: set the data set path and the network configuration file path, and set the epochs to 150 rounds and the Batch_size to 32;

[0059] S4.5, in order to ensure the consistency of the experimental environment, the experimental platform of the application is based on the environment of Windows 11 operating system. In the training process, the SGD optimizer is used to train the model. The size of the input image is 640x640x3, the training is carried out for 150 rounds, and the batch size is 32. The learning rate is set to 0.01, the momentum parameter is 0.937, and the weight decay coefficient is 0.0005. The experiment uses Tesla V100-SXM2 GPU, which has a memory size of 16G;

[0060] S4.6, in order to evaluate the detection performance of dangerous chemical vehicles, the experiment adopts multiple indexes. Among them, the precision (Precision), recall (Recall) and mAP@0.5;

[0061] S4.7、In order to more comprehensively study the contribution of the improved module to the overall performance, the present application design carried out a series of ablation experiments, the training environment, training hyperparameters and the number of iterations were kept consistent during the experiment, through such setting, the effect of each component can be accurately evaluated, and the beneficial guidance about algorithm improvement can be obtained. The experimental results are shown in Table 1:

[0062] Table 1 Comparison results of improved model and original model

[0063]

[0064] The experimental results show that the improved method adopted in the present application has achieved effective results in the dangerous chemical vehicle detection task. At the same time, the improvement of single component to the model performance is also satisfactory. These results provide strong support for further improving the model performance, and prove the effectiveness of the improvement method for improving the model performance.

[0065] The above embodiments are only for illustrating the technical concept and characteristics of the present application, and the purpose is to enable those skilled in the art to understand the content of the present application and implement it, and cannot limit the protection scope of the present application. Any equivalent transformation or modification made according to the spirit and essence of the present application shall be covered within the protection scope of the present application.

Claims

1. A dangerous chemical vehicle detection method based on an improved YOLOv5 algorithm, characterized in that, It comprises the following steps: S1, the data obtained is named Hazardous Vehicles, and is preprocessed to obtain a processed data set divided into four categories; S2, a traditional YOLOv5 model architecture is built, and an RFEB structure is introduced in the backbone network part; S2.1, YOLOv5 uses CSPDarkNet53 as the backbone network, and adopts C3 modules for feature extraction; a three-basic-block RFEB structure is used to expand the receptive field to obtain more rich semantic information while maintaining the resolution of the feature map; In the step S2.1, the three-basic-block RFEB structure formula is described as: ; wherein, DB i ’ is a basic block, i is the sequence number of the basic network in the RFEB, R j l denotes the input of the l layer on the j RFEB; the basic composition of the RFEB structure is composed of 1*1 convolution, BN, ReLu, dilated convolution, residual structure; S3, a separable attention mechanism is introduced, which unifies the attention mechanisms of scale perception, spatial perception and task perception into the head; S4, the model is trained on the training set and verified on the test set to realize the prediction of hazardous chemical vehicle.

2. The dangerous chemical vehicle detection method based on the improved YOLOv5 algorithm according to claim 1, wherein, The step S1 is specifically: S1.1, a labeling tool is used to draw the bounding box or key points of the target; different vehicle types or attributes are labeled according to the data categories; S1.2, the processed data set contains four categories of Oil truck, Big truck, Tiny truck and Car.

3. The dangerous chemical vehicle detection method based on the improved YOLOv5 algorithm according to claim 1, wherein, The step S3 is specifically: S3.1, a scale perception attention is designed to dynamically fuse features of different scales according to the importance of semantics; S3.2, on the basis of fused features, another spatial perception attention module is applied to focus on the discriminative regions that consistently coexist between spatial positions and feature layers; since the spatial perception attention module needs to process high-dimensional features, the module is decomposed into two steps; first, deformable convolution is used to make attention learning sparse to reduce computational complexity and memory consumption; then cross-level feature aggregation is performed at the same spatial position; S3.3, in order to realize joint learning and summarize different representations of objects, a task perception attention is deployed, which dynamically opens or closes feature channels to support different tasks; S3.4, the attention function is converted into three sequential attentions, each of which only focuses on one perspective.

4. The dangerous chemical vehicle detection method based on the improved YOLOv5 algorithm according to claim 1, wherein, In the step S3, the separable attention mechanism processes the feature map through the scale perception, spatial perception and task perception attention modules; The scale perception attention module enhances the sensitivity to the scale difference of the foreground object, the spatial perception attention module focuses on the features of the foreground object at different spatial positions, and the task perception attention module forms different activations according to the requirements of the downstream task; the three attention mechanisms are applied sequentially and weightedly fused with the original feature vector F.

5. The improved YOLOv5 algorithm-based dangerous chemical vehicle detection method according to claim 1, wherein, The step S4 is specifically: S4.1, prepare the data set: convert the labeled data set into.txt format according to the model; S4.2, build the model and introduce the RFEB structure and the separable attention mechanism; S4.3, prepare training.

Citation Information

Patent Citations

  • Text detection method based on attention feature fusion and hole residual feature enhancement

    CN113486890A

  • Improved infrared thermal imaging cervical vertebra part extraction method based on Yolo v3

    CN114708207A