A method, apparatus, storage medium, and equipment for detecting flammable and explosive vehicles in nighttime environments.
By introducing FasterNet and Biformer mechanisms into the YOLOv12n network, the nighttime vehicle detection model was improved, solving the problem of low detection accuracy of flammable and explosive vehicles in nighttime environments, and achieving efficient vehicle identification and monitoring.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUILIN UNIVERSITY OF TECHNOLOGY
- Filing Date
- 2026-03-31
- Publication Date
- 2026-06-30
AI Technical Summary
At night or in low-light conditions, existing target detection algorithms struggle to effectively identify flammable and explosive vehicles, exhibiting low detection accuracy and insufficient feature extraction capabilities.
We introduce FasterNet feature extraction structure and Biformer attention mechanism into the YOLOv12n object detection network to improve the network structure and enhance feature extraction and fusion capabilities. The improved detection model is used to detect vehicle targets in nighttime images.
It improves the detection accuracy and stability of flammable and explosive vehicles in nighttime environments, effectively identifies dangerous transport vehicles such as oil tankers, and enhances road traffic safety monitoring capabilities.
Smart Images

Figure CN122313408A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and intelligent transportation technology, specifically to a method, apparatus, storage medium, and device for detecting flammable and explosive vehicles in nighttime environments based on an improved YOLOv12n target detection algorithm. Background Technology
[0002] With the continuous development of modern logistics and transportation systems, a large number of hazardous chemicals and flammable and explosive materials need to be transported by road, such as tanker trucks, liquefied gas transport trucks, and other hazardous materials transport vehicles. These vehicles may cause fires or explosions in the event of traffic accidents or leaks, posing a serious threat to traffic safety and public safety. Therefore, the effective identification and monitoring of flammable and explosive transport vehicles is of great significance.
[0003] Currently, traffic monitoring systems typically use video surveillance equipment to capture road images and then employ computer vision technology to detect vehicle targets. However, in nighttime or low-light environments, traditional detection methods often struggle to achieve stable detection results due to insufficient illumination, increased image noise, and unclear target features.
[0004] In recent years, deep learning-based object detection algorithms have achieved good results in vehicle detection tasks, but they still suffer from insufficient feature extraction capabilities and poor detection stability in nighttime scenes. Therefore, it is necessary to improve the existing object detection network structure to enhance the detection performance of hazardous transport vehicles in nighttime environments. Summary of the Invention
[0005] Based on this, in order to solve the technical problems of insufficient ability to identify dangerous transport vehicles, low detection accuracy, and limited target feature expression ability of existing technologies in nighttime or low-light environments, the present invention provides a method, device, storage medium, and computer equipment for detecting flammable and explosive vehicles in nighttime environments.
[0006] This invention provides a method for detecting flammable and explosive vehicles in a nighttime environment, comprising: Image data containing vehicle targets in a nighttime road environment are collected to construct a vehicle detection dataset. The vehicle targets in the images are labeled with their location and category to form training samples for model training. Based on the original YOLOv12n object detection network structure, improvements are made by introducing a FasterNet feature extraction structure into the backbone network to replace some convolutional feature extraction modules, thereby improving the network's feature extraction efficiency. At the same time, a Biformer attention mechanism module is introduced between the output of the feature fusion network and the detection head to enhance the fused feature information, thus constructing an improved YOLOv12n object detection network. The improved YOLOv12n target detection network is trained using the vehicle detection dataset to obtain a trained flammable and explosive vehicle detection model. The nighttime road image to be detected is input into the flammable and explosive vehicle detection model. The backbone network is improved to extract features from the input image. The feature fusion network is used to fuse features at different levels. The Biformer attention mechanism is used to enhance the features of key regions. Then, the detection head network is used to detect vehicle targets in the image, thereby outputting the location and category information of flammable and explosive vehicles in the image to be detected.
[0007] Furthermore, the feature extraction of the input image by improving the backbone network specifically includes: Initial feature extraction of the input image is performed using the convolutional modules in the backbone network; The features are further extracted using the FasterNet feature extraction module to obtain a vehicle target feature map; The vehicle target feature map is scaled by a downsampling structure to obtain multi-layer feature maps of different resolutions.
[0008] Furthermore, the FasterNet feature extraction module includes a partially convolutional structure, a feature recombination structure, and a residual connection structure, wherein: The partial convolutional structure is used to perform convolution operations on a portion of the input feature map, thereby reducing the amount of convolutional computation and lowering the model complexity; The feature recombination structure is used to perform channel rearrangement and feature fusion on the convolutional feature map to enhance the network's ability to express vehicle target features. The residual connection structure is used to establish feature transfer paths between different network layers, thereby alleviating the gradient vanishing problem that may occur during deep network training and improving network training stability.
[0009] Furthermore, the multi-scale feature fusion of the vehicle target feature map through the feature fusion network specifically includes: Spatial resolution is restored to deep feature maps through upsampling operations; The upsampled feature map is fused with the shallow feature map by feature concatenation operation to obtain a fused feature map containing multi-scale semantic information. By integrating features at different scales through a multi-layer feature fusion structure, a multi-scale vehicle target feature representation can be obtained.
[0010] Furthermore, the feature enhancement of the fused feature map through the Biformer attention mechanism specifically includes: The fused feature map is divided into multiple local regions; The attention weights between local regions are calculated using a dynamic routing attention mechanism. The key regions in the feature map are weighted according to the attention weights, thereby enhancing the feature representation capability of the vehicle target region.
[0011] Furthermore, the detection head network adopts a multi-scale detection structure, which detects vehicle targets of different scales through multiple detection branches, thereby improving the detection capability for vehicle targets of different sizes.
[0012] The present invention also provides a device for detecting flammable and explosive vehicles in nighttime environments, comprising: The model building module is used to introduce the FasterNet feature extraction structure and the Biformer attention mechanism module on the basis of the original YOLOv12n object detection network structure, thereby building an improved YOLOv12n object detection network. The model training module is used to collect vehicle image data in nighttime road environments to construct a vehicle detection dataset, and to use the dataset to train the improved YOLOv12n target detection network to obtain a flammable and explosive vehicle detection model. The detection module is used to input the nighttime road image to be detected into the detection model, extract features by improving the backbone network, perform multi-scale feature fusion by the feature fusion network, and enhance the features of key areas by combining the Biformer attention mechanism, thereby outputting the location and category information of flammable and explosive vehicles in the image.
[0013] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, is used to implement the above-described method for detecting flammable and explosive vehicles in a nighttime environment.
[0014] The present invention also provides a computer device, including a processor, a memory, and a computer program stored in the memory, wherein when the processor executes the computer program, the above-mentioned method for detecting flammable and explosive vehicles in a nighttime environment is implemented.
[0015] The present invention, by employing the above technical solution, can achieve the following beneficial effects: In the method for detecting flammable and explosive vehicles in nighttime environments provided by this invention, by introducing a FasterNet feature extraction structure into the target detection network, the computational complexity of the model can be reduced while ensuring the network's feature representation capabilities, thereby improving the model's running efficiency. Simultaneously, by introducing a Biformer attention mechanism module between the output of the feature fusion network and the detection head, attention enhancement is applied to the fused features, enabling the network to more accurately focus on the key features of the vehicle, thereby improving the detection accuracy of hazardous transport vehicles. Through these improvements, the detection method can effectively identify flammable and explosive vehicles such as tank trucks and hazardous materials transport vehicles in low-light nighttime environments, thereby enhancing road traffic safety monitoring capabilities. Attached Figure Description
[0016] The accompanying drawings are used to further illustrate the technical solution of the present invention and, in conjunction with the description, to explain the embodiments of the present invention. In the accompanying drawings of the present invention: Figure 1 This is a schematic diagram of the overall process of a method for detecting flammable and explosive vehicles in a nighttime environment provided by the present invention; Figure 2 This is a schematic diagram of the overall structure of the improved target detection network of the present invention; Figure 3 This is a schematic diagram of the FasterNet feature extraction module in this invention; Figure 4 This is a schematic diagram of the Biformer attention mechanism structure in this invention; Figure 5 This is a schematic diagram illustrating the detection results of flammable and explosive vehicles under nighttime conditions according to the present invention.
[0017] It should be noted that the above figures are merely schematic structural diagrams used to assist in illustrating the technical solution of the present invention, and are not intended to limit the scope of protection of the present invention. Detailed Implementation
[0018] To make the technical solution of the present invention clearer and more complete, the present invention will be further described below with reference to the accompanying drawings and specific embodiments. Those skilled in the art should understand that the following embodiments are only for illustrating the present invention and are not intended to limit the scope of protection of the present invention. Without departing from the technical concept of the present invention, those skilled in the art can make various modifications or equivalent substitutions, and all such modifications or substitutions should fall within the scope of protection of the present invention.
[0019] Example 1 like Figure 1As shown, this embodiment provides an intelligent detection method for flammable and explosive vehicles in nighttime environments. This method is based on an improved target detection network model, and through structural optimization of the deep learning detection algorithm, it enables stable identification of hazardous transport vehicles in low-light environments and complex road scenarios.
[0020] The detection method proposed in this embodiment mainly includes four steps: vehicle detection dataset construction, detection model construction, model training, and vehicle detection. S1: Construct a nighttime vehicle target detection dataset.
[0021] In object detection tasks, high-quality datasets have a significant impact on model training performance. Therefore, this embodiment first collects and organizes vehicle image data in nighttime environments to construct a vehicle object detection dataset for training the object detection model.
[0022] Specifically, vehicle image data was first collected through publicly available internet data resources and road surveillance videos. The collection process focused on nighttime road scenes, including flammable and explosive vehicles such as tanker trucks, liquefied gas transport vehicles, and fireworks transport vehicles, as well as ordinary vehicles. To increase the diversity of the dataset, vehicle images under different weather conditions and road environments, such as rain, fog, and different road lighting conditions, were also collected.
[0023] After image acquisition, the raw images need to be filtered. Specifically, image samples with low resolution, severe blurring, or significant occlusion of vehicle targets are removed to ensure high data quality in the dataset. Then, vehicle targets in the images are manually labeled using object detection annotation tools. During annotation, a rectangular bounding box is drawn for each vehicle target, and the corresponding vehicle category label is added, thus generating the annotation information required for the object detection task. After annotation, the corresponding annotation file is generated according to the data format required by the object detection model.
[0024] To further improve the generalization ability of the detection model, data augmentation can be performed on the dataset. For example, operations such as random flipping, brightness changes, noise perturbation, and color adjustment can be applied to the images to expand the number of training samples and enrich the data distribution.
[0025] Finally, the processed dataset is divided into training, validation, and test sets according to a preset ratio. The training set is used for parameter optimization during model training, while the test set is used for performance evaluation of the trained detection model.
[0026] S2: Construct an improved YOLOv12n vehicle detection model.
[0027] After completing the construction of the vehicle target detection dataset, it is necessary to build a target detection model for vehicle detection tasks.
[0028] like Figure 2 As shown, this embodiment improves upon the original YOLOv12n object detection network structure to construct an improved vehicle detection model. This model mainly consists of three parts: a backbone network, a feature fusion network (Neck), and a detection head network (Head).
[0029] S21. The backbone network is mainly used for preliminary feature extraction from the input image. To reduce the computational complexity of the model while ensuring detection accuracy, this embodiment introduces a FasterNet feature extraction module into the backbone network. For example... Figure 3 As shown, the FasterNet module uses a partial convolution structure, performing convolution operations only on some feature channels, thereby reducing computation and improving network efficiency. Let the input feature map be X. The partial convolution calculation process can be represented as follows: ; in: Indicates the feature channels involved in the convolution calculation; This represents the remaining channels that did not participate in the convolution calculation; Indicates the convolution weight parameters; This indicates the output feature map. This indicates a feature splicing operation.
[0030] By using the aforementioned partial convolutional structure, the computational complexity of the network can be reduced while ensuring feature representation capabilities, thereby improving the model's running efficiency.
[0031] S22. The feature fusion network is mainly used to fuse feature maps of different scales, thereby improving the model's ability to detect targets of different sizes. Let the feature map of the l-th layer be... The feature map above it is The multi-scale feature fusion process can then be represented as: ;
[0032] in, Indicates an upsampling operation. This indicates a feature concatenation operation. This represents the fused feature map; By using a multi-scale feature fusion structure, the detection model can simultaneously utilize the detailed information in shallow features and the semantic information in deep features, thereby improving the vehicle target detection performance. S23. The detection head network is used to output vehicle detection results, including the location and category information of the vehicle target.
[0033] To further enhance the model's ability to represent key region features, this embodiment introduces a Biformer attention mechanism between the feature fusion network output and the detection head. For example... Figure 4 As shown, Biformer selectively focuses on input features through a dynamic routing mechanism, thereby improving the model's ability to extract features from key target regions. Let the input feature map be... The attention calculation process is as follows: ;
[0034] The features are then weighted using attention weights: ;
[0035] in: , , Let A represent the query matrix, key matrix, and value matrix, respectively; let A represent the attention weight matrix; and let d represent the feature dimension. This represents the feature representation after attention enhancement.
[0036] By introducing this attention mechanism, the model's ability to represent features of the vehicle target region can be enhanced, thereby improving the target detection performance in complex environments. S3: After constructing the improved YOLOv12n vehicle detection model, the model needs to be trained using the vehicle target detection dataset constructed in step S1, so as to obtain a target detection model that can be used for vehicle detection tasks in nighttime environments.
[0037] The specific training process includes the following steps: S31. First, preprocess the vehicle images collected in the dataset. Specifically, the input images are scaled according to their original aspect ratio and uniformly adjusted to the input size required by the object detection network. During image scaling, the aspect ratio remains unchanged, and blank areas are padded to avoid image distortion. Furthermore, during training, data augmentation operations such as random brightness changes, contrast adjustments, and noise perturbations can be performed on the input images to improve the model's adaptability to different nighttime environmental conditions. S32. The preprocessed training images are input into the backbone network of the improved YOLOv12n model for feature extraction. The backbone network progressively encodes the image features through a multi-layer convolutional structure and extracts semantic feature information at different levels. This embodiment introduces the FasterNet structure to perform convolution operations on some feature channels, thereby reducing the computational complexity of the network while ensuring feature representation capabilities.
[0038] Through the above feature extraction process, feature maps at multiple scales can be obtained for subsequent feature fusion processing; S33. The multi-scale feature maps output by the backbone network are input into the feature fusion network (Neck) for further processing. The feature fusion network fuses feature information from different levels through upsampling, feature concatenation, and convolution operations to construct multi-scale feature representations.
[0039] Specifically, the deeper, high-semantic feature maps are first upsampled to increase their resolution, and then concatenated with the shallower feature maps, thus preserving both semantic and spatial details. This multi-layer feature fusion structure effectively enhances the model's ability to detect vehicle targets at different scales. S34. After completing multi-scale feature fusion, the fused feature map is input into the Biformer attention mechanism module for feature enhancement. The attention weights between different regions are calculated through a dynamic routing attention mechanism, thereby enhancing important feature information of the vehicle target region and suppressing background interference.
[0040] The attention-enhanced feature map is then fed into the detection head network for target prediction. S35. During model training, the error between the predicted result and the true labeled result is calculated by defining a loss function, and the network parameters are updated according to the error.
[0041] This embodiment uses a comprehensive loss function consisting of bounding box regression loss, category prediction loss, and target confidence loss, the expression of which is as follows: ; in: This represents the bounding box regression loss, used to measure the positional error between the predicted and the true bounding boxes. This represents the category prediction loss, used to measure the difference between the predicted category and the true category. This represents the target confidence loss, which measures the accuracy of the model's prediction of the probability of the target's existence.
[0042] During training, the network parameters are iteratively updated using the backpropagation algorithm, causing the loss function to gradually decrease and eventually converge, thus obtaining the trained vehicle detection model.
[0043] To evaluate the model's performance in vehicle detection tasks, metrics such as precision, recall, and mean average precision (mAP) can be used. Experimental results show that the improved model proposed in this embodiment has better detection performance in vehicle detection tasks compared to the original YOLOv12n model.
[0044] S4. After the model training is completed, the trained detection model can be used to identify vehicle targets in nighttime road images.
[0045] Specifically, the road image to be detected is input into the target detection model, and the predicted bounding boxes, category information, and corresponding confidence values of vehicle targets are obtained through network inference. The predicted results output by the model are then filtered. First, detection boxes with confidence scores below a preset threshold are removed. Then, the Non-Maximum Suppression (NMS) algorithm is used to suppress overlapping prediction boxes, retaining only the detection results with higher confidence scores, thus obtaining the final vehicle detection results.
[0046] The detection results can be visually annotated in the original image, using rectangular bounding boxes to identify the location of vehicle targets and displaying the corresponding vehicle category and confidence level information. For example... Figure 5 As shown, the detection method proposed in this embodiment can effectively identify targets such as tanker trucks and other flammable and explosive transport vehicles in nighttime road environments, and annotate the corresponding detection results in the image. The detection results mainly include two aspects of information: first, target category information, that is, whether the identified vehicle belongs to a tanker truck or a dangerous goods transport vehicle or other flammable and explosive goods transport vehicle; second, a confidence value, which is used to represent the probability that the model judges the target to belong to the corresponding category. The confidence value ranges from 0 to 1, and the larger the value, the higher the reliability of the identification result.
[0047] Experimental results show that the improved detection model can accurately identify dangerous transport vehicle targets in low-light conditions at night and provide detection results with high confidence, indicating that the method of the present invention still has good detection performance and stability in complex road scenarios.
[0048] In some implementations, the method of the present invention can also be applied to vehicle detection tasks in different nighttime traffic environments, such as urban roads, highways, and tunnels. By collecting nighttime road images in different traffic environments and constructing a dataset containing multiple vehicle types, the improved YOLOv12n detection model is trained. Introducing richer scene data can further improve the robustness of the detection model in complex environments. Experimental results show that the method of the present invention can still maintain good detection performance and stability in different nighttime traffic scenarios.
[0049] Based on the above-mentioned method for detecting flammable and explosive vehicles in nighttime environments, the present invention also provides a device for detecting flammable and explosive vehicles in nighttime environments, comprising: The model building module constructs an improved YOLOv12n vehicle detection network, introducing a FasterNet feature extraction structure into the backbone network and a Biformer attention mechanism between the feature fusion network and the detection head to enhance the representation of vehicle target features. The model training module collects nighttime vehicle image data and constructs a training dataset, which is then used to train the improved YOLOv12n network to obtain the vehicle detection model. The detection module inputs the nighttime road image to be detected into the vehicle detection model, outputting the vehicle target category information and corresponding target location through the target detection network, thereby achieving the identification of hazardous transport vehicles. For the specific structure and implementation of the above device, please refer to the relevant description of the aforementioned detection method; it will not be repeated here.
[0050] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, is used to implement the various steps of the above-described method for detecting flammable and explosive vehicles in a nighttime environment.
[0051] The present invention also provides a computer device, which includes a processor, a memory, and a computer program stored in the memory. When the computer program is run on the processor, it causes the processor to execute the above-described method for detecting flammable and explosive vehicles in a nighttime environment.
[0052] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by computer program instructions, which can be stored in a non-volatile computer-readable storage medium and implement the above method steps when executed.
Claims
1. An intelligent detection method for flammable and explosive vehicles in nighttime environments, characterized in that, Includes the following steps: An improved YOLOv12n object detection network is constructed by introducing a FasterNet feature extraction structure into the backbone of the original YOLOv12n object detection network to replace some convolutional feature extraction modules. A Biformer attention mechanism is introduced between the output of the feature fusion network and the detection head. Road monitoring images under nighttime conditions are collected and a vehicle detection dataset is constructed. The improved YOLOv12n target detection network is then trained using the vehicle detection dataset to obtain a flammable and explosive vehicle detection model. The nighttime road image to be detected is input into the flammable and explosive vehicle detection model, and the improved backbone network is used to extract features from the input image to obtain the vehicle target feature map. The vehicle target feature map is fused using a feature fusion network at multiple scales to obtain a fused feature map. The vehicle target region in the fused feature map is enhanced by a Biformer attention mechanism set between the output of the feature fusion network and the detection head. The enhanced feature map is processed by a detection head network to detect vehicle targets, thereby outputting the target location and category information of flammable and explosive vehicles in the image to be detected.
2. The method for detecting flammable and explosive vehicles in a nighttime environment as described in claim 1, characterized in that: The process of collecting road surveillance images under nighttime conditions to construct a vehicle detection dataset specifically includes: Raw image data containing vehicle targets were obtained by using publicly available data sources on the Internet and road surveillance videos. The original image data is filtered to select image samples that include flammable and explosive transport vehicles such as oil tankers, as well as other ordinary vehicles. The vehicle targets in the image samples are labeled with their locations and categories to generate a vehicle detection dataset for training the target detection model.
3. The method for detecting flammable and explosive vehicles in a nighttime environment as described in claim 2, characterized in that: After constructing the vehicle detection dataset, the method also includes preprocessing the image samples, the preprocessing operations including: Perform size normalization on the image; Perform brightness enhancement and contrast enhancement processing on low-light nighttime images; Noise suppression processing is applied to the images to improve image quality and enhance the discernibility of vehicle targets.
4. The method for detecting flammable and explosive vehicles in a nighttime environment as described in claim 1, characterized in that: The process of extracting features from the input image by improving the backbone network includes: Initial feature extraction of the input image is performed using the convolutional modules in the backbone network; The initial features are further extracted using the FasterNet feature extraction module to obtain a vehicle target feature map.
5. The method for detecting flammable and explosive vehicles in a nighttime environment as described in claim 4, characterized in that: The FasterNet feature extraction module includes: Partial convolutional units, feature recombination units, and residual connection structures, wherein: Some convolutional units are used to perform convolution operations on a portion of the input feature map to reduce the computational cost of the network. Feature recombination units are used to combine feature information from different levels to improve feature representation capabilities; Residual connection structures are used to maintain the stable transmission of feature information in the network.
6. The method for detecting flammable and explosive vehicles in a nighttime environment as described in claim 1, characterized in that: The feature enhancement of the vehicle target region in the fused feature map using the Biformer attention mechanism specifically includes: The fused feature map is divided into regions through feature block segmentation. The attention weights between regions are calculated using a dynamic routing attention mechanism. The vehicle target region features are weighted according to the attention weights to obtain an enhanced feature map.
7. The method for detecting flammable and explosive vehicles in a nighttime environment as described in claim 6, characterized in that: The multi-scale features output by the feature fusion network are sequentially processed through the Concat operation, the A2C2f feature processing module, and the Biformer attention mechanism module before being input into the detection head network.
8. A device for detecting flammable and explosive vehicles in a nighttime environment, characterized in that, include: The model building module is used to introduce the FasterNet feature extraction structure into the backbone of the original YOLOv12n object detection network and introduce the Biformer attention mechanism between the output of the feature fusion network and the detection head, thereby building an improved YOLOv12n object detection network. The model training module is used to collect road monitoring images under nighttime conditions to construct a vehicle detection dataset, and to train the improved YOLOv12n target detection network using the vehicle detection dataset to obtain a flammable and explosive vehicle detection model. The detection module is used to input the nighttime road image to be detected into the detection model, extract image features by improving the backbone network, perform multi-scale feature fusion by the feature fusion network, enhance the fused features by the Biformer attention mechanism, and detect vehicle targets by the detection head network, thereby outputting the target location and category information of flammable and explosive vehicles.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1 to 7.
10. A computer device, characterized in that, include: Processor, memory, and computer program stored in said memory, When the computer program is executed by the processor, it implements the method according to any one of claims 1 to 7.