Aviation forest fire image recognition method based on self-attention mechanism
By using a self-attention mechanism and a deep convolutional neural network of weakly supervised learning in aerial forest fire image recognition, fine-grained features of aerial forest fire images are extracted, which solves the problem of traditional methods being unable to identify small targets and achieves higher accuracy. The recognition accuracy and robustness improve forest fire monitoring and early warning capabilities.
Patent Information
- Application Number
- CN202410821515.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-10-01
AI Technical Summary
Traditional image recognition methods cannot accurately identify small target areas in aerial forest fire images. Especially in different seasonal environments, the fine-grained feature extraction capabilities of forest fire images are insufficient, resulting in low recognition accuracy and robustness.
A deep convolutional neural network based on the self-attention mechanism is used, combined with ViT and weakly supervised learning methods, to serialize images through overlapping sliding panes, embed position information, and use multi-head self-attention and multi-layer perceptron mechanisms to extract small Target features, construct a comparative feature learning strategy to improve the model's feature learning ability and recognition accuracy.
It has significantly improved the accuracy and robustness of aerial forest fire image recognition, can be better generalized to different seasonal environments, enhanced fire and fire hazard response capabilities, and improved the efficiency of forest fire prevention and monitoring.
Smart Images

Figure CN118736299A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine learning technology, and in particular to an aerial forest fire image recognition method based on a self-attention mechanism. Background Art
[0002] When a forest is hit by a fire, it will damage the ecological environment, cause air pollution, threaten the reserves of understory plants, endanger the survival of wild animals, and in serious cases, destroy the forest structure, causing the forest ecosystem to lose balance, and even threaten human life and property. According to the China Statistical Yearbook, a total of 2,345 forest fires occurred in 2019, affecting an area of 13,500 hm2. 2 In 2020, there were 1,153 forest fires, affecting 8,500 hectares of forest. 2 Understanding the occurrence and burning patterns of forest fires and using scientific methods to improve forest fire early warning capabilities can minimize the ecological, environmental and economic losses caused by forest fires.
[0003] With the development of deep learning in the field of computer vision, a large number of image classification and recognition methods based on convolutional neural networks (CNNs) have been proposed in recent years. According to the different recognition granularity, the classification methods based on CNNs are mainly divided into two types: 1) coarse-grained classification, that is, the recognition of objects of different species levels. This method has the characteristics of large inter-class variance and small intra-class variance. The mainstream models include VGG16, GoogleNet, Resnet50, etc., which are often used in image classification, image segmentation and target recognition. 2) fine-grained classification, that is, accurate recognition of sub-class objects in large categories, such as distinguishing different types of birds based on detailed features, and eliminating background information based on discriminative regions to identify different car models. The classification method based on fine-grained classification has the characteristics of small inter-class differences and large intra-class differences. It is difficult for classical neural networks to recognize fine-grained images. For this reason, Lin et al. proposed the Bilinear-CNN network to achieve fine-grained recognition of birds, airplanes, and cars, but the high-dimensional features of bilinear pooling in this model will cause the model to overfit. Woo proposed the CBAM fine-grained classification network, integrated the attention mechanism into the network model, and achieved good recognition results on the ImageNet-1K dataset.
[0004] The Transformer-based network model framework ViT performs well in fine-grained image recognition. ViT bypasses the pooling layer and integrates the self-attention mechanism to achieve image feature extraction. It captures the internal correlation of data or features by reducing the dependence on external information. Since the self-attention mechanism focuses on global features, simple queries and assignments can obtain feature maps and global spatial information, avoiding the multi-layer stacking of feature maps in CNN convolution kernels. Wang et al. proposed a fine-grained classification method based on self-attention destruction and construction learning (SADCL) and used it for retail product recognition. Zhao Guochuan et al. applied the self-attention mechanism to hydropower hub defect recognition and obtained a defect recognition accuracy of 98.87%. Horváth et al. proposed using ViT to detect spliced areas in satellite images.
[0005] Aerial forest fire images contain rich fine-grained information, with characteristics such as diverse fire targets, complex seasonal and ecological environment backgrounds, etc. Traditional CNN is not suitable for fine-grained feature extraction. In view of this, this application proposes a deep CNN model based on the self-attention mechanism to analyze the fine-grained features of forest fire images in different scenarios, mine local differences between images, and combine the ViT self-attention mechanism and weakly supervised learning methods to improve the accuracy and robustness of aerial forest fire image recognition. Summary of the invention
[0006] Aiming at the characteristics of aerial forest fire images collected by UAVs, such as small fire point targets and complex occurrence scenes, this paper proposes a deep convolutional neural network learning method based on the self-attention mechanism, and uses machine learning technology to improve the accuracy and robustness of aerial forest fire image recognition.
[0007] This application provides an aerial forest fire image recognition method based on a self-attention mechanism, comprising the following steps:
[0008] Step 1: Get forest fire video as data source;
[0009] Step 2: Filter out images through preprocessing methods and build a forest fire image dataset. At the same time, use data enhancement technology to enrich data diversity and improve the generalization ability of the model.
[0010] Step 3: In the feature extraction stage, a 10-layer ViT is selected as the backbone network, and the image is serialized using an overlapping sliding pane method. After embedding the position information, it is used as the input of the first layer of ViT. The region selection modules extracted by the first 9 layers of ViT are batch-embedded into the 10th layer of ViT through a multi-head self-attention mechanism and a multi-layer perceptron mechanism, effectively amplifying the slight differences between sub-images to obtain small target features;
[0011] Step 4: Adopt the contrast feature learning strategy, construct the target loss function for model training, obtain the image category label, and effectively improve the model's feature learning ability and recognition accuracy.
[0012] Preferably, the second step: the preprocessing method is to obtain a forest fire image dataset by extracting frames and cleaning the data source obtained in the first step.
[0013] As a preferred method, the second step: use data enhancement technology as follows: 1) Random cropping, randomly cropping a sub-region with a resolution of 448448 on the original image to highlight the proportion of local features in the sub-region; 2) Random horizontal flipping, flipping the image horizontally with probability P = 0.5, that is, randomly selecting 50% of the images to simulate different shooting angles of the drone; 3) Standardization, standardizing the image with mean (0.485, 0.465, 0.406) and standard deviation (0.229, 0.224, 0.225).
[0014] Preferably, in the third step, the specific steps are: first, the image is divided into multiple sub-images, and the sub-images are serialized and embedded with position information, and the embedded position information is used as the input of the first layer ViT. After superimposing 9 layers of ViT, the region selection module information extracted by the first 9 layers of ViT is combined with the multi-head self-attention mechanism and the multi-layer perceptron mechanism to be batch embedded into the 10th layer ViT, which effectively amplifies the slight differences between the sub-images to obtain the fine-grained feature features of small target images.
[0015] Preferably, in the fourth step, key hyperparameters used in the model training process include batch size, random seed, activation function, optimizer, learning rate and number of iterations.
[0016] As a preferred embodiment, in the third step, the specific steps of image serialization are as follows: image serialization is to divide the image into non-overlapping sub-images to improve the image processing efficiency, but this operation will lose the local adjacent structure information between sub-images. In order to maximize the retention of local adjacent structure information between sub-images, an overlapping sliding window segmentation method is adopted; assuming that the image resolution is H×W, the size of the sub-image after segmentation is P, the sliding window step size is S, and the image is divided into N blocks, then N is:
[0017]
[0018] Where: H represents the image height; W represents the image width; N H and N W Respectively represent the number of times the image is divided in height and width;
[0019] After image segmentation, two adjacent sub-images will share an overlapping area of size (PS)×P, which contains local information of the image. In this segmentation method, the smaller the step size S, the more complete the local adjacent structural feature information is retained, but as S decreases, it will also lead to the problem of high algorithm complexity.
[0020] As a preference, in the third step, the specific steps of batch embedding are: use linear projection to embed each vectorized subgraph X P Mapped into the three-dimensional embedding space, embedding the learnable coordinates to record the position information, the embedded position information Z0 is:
[0021]
[0022] Where: N is the number of image batches; is the projection of batch embedding; E POS ∈R N × D for position embedding;
[0023] The Transformer encoder contains L layers of multi-head self-attention MSA and multi-layer perceptron MLP. The output of the Lth layer with Z0 as input is:
[0024] Z′ L =MSA(LN(Z L-1 ))+Z L-1 L∈1,2,…,N; (3
[0025] Z L =MLP(LN(Z′ L ))+Z L L∈1,2,…,N; (4
[0026]
[0027] Where: represents normalization processing; Z L represents a coded image; Represents a pixel value of a channel in an image; min(Z L ) and max(Z L ) represent the minimum and maximum grayscale values of pixels in this channel of the image respectively;
[0028] ViT incorporates the self-attention mechanism and embeds an E POS The sub-image position information of the upper layer is the calculation result of the lower layer module; the first module in the last encoder When global features are used as classifier input, there is no need to consider the potential position information stored in other modules.
[0029] As a preferred method, in the third step, the self-attention mechanism is used in aerial forest fire image recognition. The key is to accurately locate the subtle difference areas in similar images. ViT's multi-head attention mechanism transmits the input information with differences to the last Transformer layer, which can locate the subtle difference areas of the image.
[0030] Assuming that the model has N attention heads, when it reaches the 10th layer ViT after 9 layers of ViT, the hidden layer feature Z9 input to the 10th layer is:
[0031]
[0032] Attention head weights for:
[0033]
[0034] Then the hidden layer features input to the lth layer ViT are:
[0035]
[0036] The weight of the attention head at layer l is:
[0037]
[0038] Where: a l represents the N self-attention weights of the lth layer, l represents the lth layer ViT;
[0039] Recursively apply matrix multiplication to the original attention weights at each layer:
[0040]
[0041] Where: a final represents the final attention head weight after multiplying the weight matrices of the first l layers of attention heads;
[0042] In a final Among the N different attention heads, select the attention head with the largest weight (A1, A2, ..., A K ) as the index, extract the corresponding module in Z9 as the input selection module and combine it with the classification module as the joint input sequence, then the joint input sequence Z local It can be expressed as:
[0043]
[0044] Where: Represents the joint input sequence of the selection module and the classification module;
[0045] The input selection module represents the segmented sub-image. Replacing the original input sequence with the information region module can obtain the classification module. The joint input sequence is used as the input of the last layer of ViT, which not only retains the global information of the image, but also facilitates the model to accurately extract subtle differences between classes and weaken background areas such as sky, snow, and vegetation.
[0046] As a preferred method, in the fourth step, the cross entropy of feature learning is used as a loss function to measure the predicted value and the actual value in the neural network. The cross entropy loss function L cross It is not very sensitive to small differences and cannot achieve fully supervised learning; the contrast loss function L con It can minimize the similarity between samples with different labels and maximize the similarity between samples with the same label. In order to prevent the contrast loss function from being disturbed by extremely small negative numbers, a reconciliation threshold ɑ is introduced. If and only if the similarity between samples is greater than ɑ, an effective L con ; If there are N samples, the contrast loss function L con for:
[0047]
[0048] Where: z i and z j is the normalized feature; sim(z i ,z j ) is z i and z j The cosine similarity of
[0049] The target loss function L can be constructed and used to train the model;
[0050] L=L cross (y,y′)+L con (z); (13) Where: L cross (y,y') represents the cross entropy loss between the predicted label y' and the true label y; L con (z) represents the contrast loss of module z;
[0051] When L cross When the loss is large, it means that the model effect is poor but the learning speed is fast. When the loss is small, it means that the model effect is good but the learning speed is slow. con The attention head can be made to focus on different areas. At this time, the samples with different labels have the minimum similarity, and the samples with the same label have the maximum similarity. The SGD optimizer and L feedback value are expressed as continuous gradient descent iteration and regression in model training. At this time, L tends to 0, and the model is continuously iterated and optimized.
[0052] As a preference, in the fourth step, accuracy evaluation: the recognition accuracy (ACC) of the model is expressed as the ratio of the number of successful predictions to the total number:
[0053]
[0054] Where: TP represents the number of samples predicted as positive; TN represents the number of samples predicted as negative; FP represents the number of samples predicted as negative; FN represents the number of samples predicted as positive.
[0055]
[0056] In the formula, y i and They represent the measured and predicted vertical projection areas of the crown of the ith tree respectively; represents the mean of the actual crown vertical projection area; n represents the number of samples in the test set.
[0057] Beneficial effects of the present invention:
[0058] At present, traditional image recognition methods cannot accurately identify small target areas in aerial forest fire images. The model in this application adopts a combination of self-attention mechanism and weak supervision learning to explore the local feature differences of aerial forest fire images under different seasonal environments. It has good generalization ability and robustness, which is of great significance to improving the ability and efficiency of responding to fire conditions and fire risks and preventing forest fires. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the embodiments are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0060] Figure 1 Data collection and preprocessing of this embodiment;
[0061] Figure 2 The forest fire sample image of this embodiment;
[0062] Among them: the first row of samples is fire; the second to third row of samples are smoke; the fourth row of samples is background;
[0063] Figure 3 The data enhancement processing of this embodiment;
[0064] Figure 4 The multi-head self-attention mechanism model of this embodiment;
[0065] Figure 5 The forest fire identification result of this embodiment;
[0066] Figure 6 Confusion matrix under different allocation ratios of this embodiment;
[0067] Figure 7 Convergence speed analysis of this embodiment. DETAILED DESCRIPTION
[0068] The following embodiments are described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following embodiments do not represent all implementations consistent with the present application. They are only examples of systems and methods consistent with some aspects of the present application as detailed in the claims.
[0069] This embodiment uses forest fire videos collected by drones in Chongli District, Zhangjiakou City in winter, spring and summer as data sources. First, 19,992 images are screened out through preprocessing methods such as frame extraction and data cleaning to construct a forest fire image dataset. At the same time, data enhancement technology is used to enrich data diversity and improve the generalization ability of the model; then, in the feature extraction stage, a 10-layer Vision Transformer (ViT) is selected as the backbone network, and the image is serialized in an overlapping sliding pane manner. After embedding the position information, it is used as the input of the first layer of ViT, and the region selection modules extracted by the first 9 layers of ViT are batch-embedded into the 10th layer of ViT through multi-head self-attention and multi-layer perceptron mechanisms, which effectively amplifies the micro differences between sub-images to obtain small target features; finally, a contrast feature learning strategy is adopted to construct a target loss function for model prediction, which effectively improves the feature learning ability and recognition accuracy of the model. To verify the effectiveness of this model, the sample ratios of the training set and the test set were set to 8:2, 7:3, 6:4 and 4:6, and the recognition performance was compared with that of the VGG16, GoogleNet, Resnet50, Bilinear-CNN and CBAM models. The specific implementation process is as follows:
[0070] 1.1 Overview of the study area
[0071] The study area is located in Chongli District, Zhangjiakou City, Hebei Province (40°47'-41°17'E, 114°17'-115°34'N), which is the transition zone between the Inner Mongolia Plateau and the North China Plain, and the junction of the eastern section of the Yinshan Mountains to the branches of the Damashan Mountains and the remnants of the Yanshan Mountains, with an altitude of 813-2174m. It belongs to the East Asian continental monsoon climate. 80% of the area is mountainous, with a forest coverage rate of 52.38%. Due to the large forest coverage area, special topography and landforms, and large seasonal differences, especially the dry climate in autumn and winter, forest fires are very likely to occur. In addition, due to the large changes in the outdoor environment, the complex vegetation background, the irregular changes in the fire intensity of forest fires, and the three-dimensional and multi-level characteristics of the fire points in the burning area, it is difficult to detect and intervene in time.
[0072] 1.2 Data acquisition and preprocessing
[0073] 1.2.1 Data acquisition The data comes from forest fire video data collected by drones in Chongli District, Zhangjiakou City from November 2020 to July 2021. The drone model is Jingwei M300RTK, with a flight altitude of 300-500m, equipped with an airborne H20T gimbal camera, and a video resolution of 1920×1080@30fps. The data is transmitted to the background server through CAN / 4G / WIFI and other communication forms. After frame extraction and cleaning, the video data is obtained to obtain an aerial forest fire image dataset. The data collection and preprocessing process is as follows: Figure 1 shown.
[0074] Chongli District has a special topography, with great differences in vegetation status in different seasons and complex backgrounds of aerial images. The data collection work started in the winter of 2020 and ended in the summer of 2021. During this period, smoke, fire and background data of forests, shrubs and urban areas were collected in different time periods. In order to make the sample data set more complete, image data of thin smoke and thick smoke, small fire points and large fire points, as well as various forest vegetation coverage states and urban environment images in different seasonal environments were collected as background data sets. A total of 19,992 valid aerial forest fire images were obtained, of which 14,070, 2,738 and 3,184 were smoke, fire and background images, respectively, with a resolution of 512×512 pixels. The sample data set includes three real forest fire samples that occurred in Shijiazhuang during the period and multiple simulated forest fire point samples implemented under the premise of ensuring fire safety. Some sample data sets are as follows: Figure 2 shown.
[0075] 1.2.2 Data enhancement processing Data enhancement processing can enrich data diversity, improve the robustness of the training model, prevent overfitting, and enable the model to obtain more complete sample feature information. The data enhancement methods used in this application are as follows: 1) Random cropping, randomly cropping a sub-region with a resolution of 448×448 on the original image to highlight the proportion of local features in the sub-region; 2) Random horizontal flipping, flipping the image horizontally with a probability of P=0.5, that is, randomly selecting 50% of the images to simulate different shooting angles of the drone; 3) Standardization, standardizing the image with mean (0.485, 0.465, 0.406) and standard deviation (0.229, 0.224, 0.225). Data enhancement processing such as Figure 3 shown.
[0076] 1.3 Research Methods
[0077] Inspired by the Transformer's self-attention mechanism in NLP to overcome the contextual limitations of LSTM, Dosovitskiy et al. (2020) proposed the ViT mechanism and applied Transformer to computer vision. Horváth et al. (2021) applied the ViT mechanism to fine-grained image classification and achieved a high accuracy in identifying satellite images. In order to more accurately extract subtle feature differences in aerial forest fire images and better mark feature location information, the model of this application first divides the image into multiple sub-images, serializes the sub-images and embeds location information, and after superimposing 9 layers of ViT, the region selection module information is combined with the self-attention mechanism to inject into the 10th layer of ViT to obtain fine-grained features of the image. Finally, the constructed target loss function is used to train the model to obtain the image category label. The model structure of this application is as follows: Figure 4 shown.
[0078] 1.3.1 Parameter settings The key hyperparameters used in the training process of three coarse-grained deep learning networks (VGG16, GoogleNet, Resnet50) and two fine-grained deep learning networks (Bilinear-CNN, CBAM) as well as the models of this application include batch size, random seed, activation function, optimizer, learning rate and number of iterations. Batch size refers to the number of images input into the network each time. This parameter is related to the ability of the hardware device to process data. The environment of this application is 32G single memory Tesla, and the batch size is set to 16. The random seed is set to 42, which is convenient for reproducing results. RELU as an activation function can not only accelerate the nonlinearity of the network, but also effectively prevent the disappearance of gradients. In order to automatically escape the saddle point and stay away from the poor local optimal solution, SGD is selected as the optimizer. The learning rate selects the common value of 0.01. Since all 6 models converged within 48 iterations, the number of iterations is set to 48. All models in this application use the same training parameters, and the parameter settings are shown in Table 1.
[0079] Table 1 Parameter settings
[0080]
[0081] 1.3.2 Image Sequencing Sequencing is to divide an image into non-overlapping sub-images to improve image processing efficiency, but this operation will lose the local adjacent structure information between sub-images. In order to maximize the retention of local adjacent structure information between sub-images, this application adopts an overlapping sliding window segmentation method. Assuming that the image resolution is H×W, the size of the sub-image after segmentation is P, the sliding window step size is S, and the image is divided into N blocks, then N is:
[0082]
[0083] Where: H represents the image height; W represents the image width; N Hand N W Represents the number of times the image is divided in height and width respectively.
[0084] After the image is segmented, two adjacent sub-images will share an overlapping area of size (PS)×P, which contains local information of the image. In this segmentation method, the smaller the step size S, the more complete the local adjacent structural feature information is preserved, but as S decreases, it will also lead to the problem of high algorithm complexity. In this application, the sliding window step size S is set to 0.3P.
[0085] 1.3.3 Batch Embedding Use linear projection to vectorize each subgraph X P Mapped into the three-dimensional embedding space, embedding the learnable coordinates to record the position information, the embedded position information Z0 is:
[0086]
[0087] Where: N is the number of image batches; is the projection of batch embedding; E POS ∈R N×D Embed for position.
[0088] The Transformer encoder contains L layers of multi-head self-attention (MSA) and multi-layer perceptron (MLP). The output of the Lth layer with Z0 as input is:
[0089] Z′ L =MSA(LN(Z L-1 ))+Z L-1 L∈1,2,…,N; (3
[0090] Z L =MLP(LN(Z′ L ))+Z′ L L∈1,2,…,N; (4
[0091]
[0092] Where: represents normalization processing; Z L represents a coded image; Represents a pixel value of a channel in an image; min(Z L ) and max(Z L ) represent the minimum and maximum grayscale values of pixels in this channel of the image respectively.
[0093] ViT incorporates the self-attention mechanism and embeds a F POS The upper layer input is the calculation result of the lower layer module. When global features are used as classifier input, there is no need to consider the potential position information stored in other modules.
[0094] 1.3.4 Self-attention mechanism In aerial forest fire image recognition, the key is to accurately locate the areas with subtle differences in similar images. ViT's multi-head attention mechanism transmits the input information with differences to the last Transformer layer to locate the areas with subtle differences in the image.
[0095] Assuming that the model has N attention heads, when it reaches the 10th layer ViT after 9 layers of ViT, the hidden layer feature Z9 input to the 10th layer is:
[0096]
[0097] Attention head weights for:
[0098]
[0099] Then the hidden layer features input to the lth layer ViT are:
[0100]
[0101] The weight of the attention head at layer l is:
[0102]
[0103] Where: a l represents the N self-attention weights of the l-th layer, and l represents the l-th layer ViT.
[0104] Abnar found that the lack of module recognizability will cause the original attention weights to not fully correspond to the input tokens. Therefore, this application uses a recursive method to apply matrix multiplication to each layer of the original attention weights:
[0105]
[0106] Where: a final Represents the final attention head weight after multiplying the weight matrices of the first l layers of attention heads.
[0107] In a final Among the N different attention heads, select the attention head with the largest weight (A1, A2, ..., A K ) as the index, extract the corresponding module in Z9 as the input selection module and combine it with the classification module as the joint input sequence, then the joint input sequence Z local It can be expressed as:
[0108]
[0109] Where: Represents the joint input sequence of the selection module and the classification module.
[0110] The input selection module represents the segmented sub-graph, and the classification module can be obtained by replacing the original input sequence with the information region module, such as Figure 4 The red box marks the area in the middle. Using the joint input sequence as the input of the last layer of ViT not only preserves the global information of the image, but also makes it easier for the model to accurately extract subtle differences between classes and weaken background areas such as the sky, snow, and vegetation.
[0111] 1.3.5 Comparative Feature Learning Cross entropy as a loss function is a way to measure the predicted value and the actual value in a neural network. It is often used in classification problems, but the cross entropy loss function L cross It is not very sensitive to small differences and cannot achieve fully supervised learning. Contrastive loss function L con It can minimize the similarity between samples with different labels and maximize the similarity between samples with the same label. In order to prevent the contrast loss function from being disturbed by extremely small negative numbers, the reconciliation threshold ɑ is introduced. The effective L is obtained only when the similarity between samples is greater than ɑ. con If there are N samples, then the contrast loss function L con for:
[0112]
[0113] Where: z i and z j is the normalized feature; Sim(z i ,z j ) is z i and z j The cosine similarity of .
[0114] The target loss function L can be constructed and used to train the model.
[0115] L=L cross (y,y′)+L con (z). (13)
[0116] Where: L cross (y,y') represents the cross entropy loss between the predicted label y' and the true label y; L con (z) denotes the contrastive loss of module z.
[0117] When L cross When the loss is large, it means that the model has poor effect but fast learning speed. When the loss is small, it means that the model has good effect but slow learning speed. conThe attention head can focus on different areas. At this time, the samples with different labels have the minimum similarity, and the samples with the same label have the maximum similarity. The SGD optimizer and L feedback value are manifested as continuous gradient descent iteration and regression in model training. At this time, L tends to 0, and the model is continuously iterated and optimized.
[0118] 1.3.6 Accuracy Evaluation The recognition accuracy (ACC) of the model in this application is expressed as the ratio of the number of successful predictions to the total number:
[0119]
[0120] Where: TP represents the number of samples predicted as positive; TN represents the number of samples predicted as negative; FP represents the number of samples predicted as negative; FN represents the number of samples predicted as positive.
[0121] 2 Results and analysis
[0122] 2.1 Forest fire image recognition results
[0123] The image dataset used in this application includes 19,992 forest fire images, of which 2,738 are fire images, 14,070 are smoke images, and 3,184 are background images. In order to compare the recognition ability of the model of this application for different categories of images, 60 representative images were selected from the test results, of which 20 are fire images, 20 are smoke images, and 20 are background images. The images cover the characteristics of the preheating stage, gas combustion stage, and charcoal combustion stage of the fire. The recognition results of the 20 images are shown in Figure 5.
[0124] The model in this application identified 21 fires, 18 smokes and 21 backgrounds, of which 2 smoke images were misclassified as fire, 1 fire image was misclassified as smoke, and 1 smoke image was misclassified as background. The misclassified images were marked with green borders. Analysis of the recognition results showed that the misclassifications were concentrated between smoke and fire and between smoke and background, and there was no misclassification between fire and background.
[0125] analyze Figure 5 When smoke was misjudged as fire in Group 1 and fire was misjudged as smoke in Group 2, it was found that during the spread of forest fires, the generation of smoke often runs through all stages of the fire development and is highly correlated with the presence of flames. When manually labeling images, images with bright and highly distinguishable flames are labeled as fire, while images labeled as smoke often have sporadic fire points. The model of this application has some common features when extracting fine-grained features of key areas of smoke and fire in certain images during training, which may cause misjudgment of the test set. Analysis of images that misjudged smoke as background found that the image was collected after a summer rain. As a turbulent motion phenomenon, water mist has a large difference in appearance and a certain degree of transparency. Although there is a small target of smoke in the middle of the image, the model of this application misjudged the target as fog.
[0126] 2.2 Impact of sample allocation ratio on recognition accuracy
[0127] The number of samples of the three subcategories in the data set is different. The confusion matrix can be used to intuitively describe the prediction results, such as Figure 6 As shown in the figure. In the confusion matrix, the horizontal axis represents the true label of the image, the vertical axis represents the predicted label of the image, the sum of each column of data represents the number of samples of this category in the test set, the sum of each row of data represents the total number of samples predicted as this category in the test set, and the main diagonal of the matrix represents the number of samples predicted correctly in the three categories.
[0128] Depend on Figure 6 It can be seen that under the four distribution ratios, there are cases where fire is predicted as smoke and background is predicted as smoke, which shows that in image recognition, in some special cases, smoke is highly similar to fire and background features, such as clouds in the sky, summer mist and smoke, which have certain similarities in form. In the prediction of fire images, except for nearly 1 / 4 of the images predicted as smoke under the 4:6 distribution ratio, nearly 50 images were misjudged under the remaining distribution ratios, indicating that the performance of the model of this application for fire image prediction is relatively stable under a high training set ratio. As for the prediction of smoke, 314 images were predicted as fire in the most cases, and 129 images were predicted as fire in the least cases, indicating that some smoke images and fire images have highly similar features. This is because when a forest fire occurs, the fire point is often accompanied by smoke of different concentrations, and smoke and fire have certain symbiotic features in the image. Regarding background identification, only a few backgrounds were misjudged as smoke. Analysis found that some of these misjudged images were from the autumn and winter seasons when there was mist in the mountains after rain. The Chongli mountain area is at a high altitude and the cloud layer is low, so the model in this application mistakenly predicted the clouds as smoke.
[0129] The prediction accuracy of the test set and training set under different allocation ratios was statistically analyzed. It was found that the model accuracy was the highest at 95.02% under the 7:3 allocation ratio, and the model accuracy was relatively low at 94.78% under the 8:2 allocation ratio. The prediction accuracy of the model of this application was relatively stable under the four allocation ratios, all higher than 94.5%, indicating that the model of this application only needs fewer training samples to learn key features and accurately identify test samples.
[0130] 2.3 Convergence speed analysis
[0131] The convergence speed of an algorithm refers to the number of iterations required for the algorithm to reach the optimal solution. Fast convergence of an algorithm means that the algorithm can obtain relatively accurate values using fewer iterations, that is, obtain satisfactory results within the allowed time. Algorithms with too slow convergence speeds are difficult to put into practical application. In order to verify the effectiveness and usability of the model in this application in aerial forest fire image recognition, a convergence comparison analysis was conducted with VGG16, GoogleNet, Resnet50, Bilinear-CNN, and CBAM, among which VGG16, GoogleNet, and Resnet50 are coarse-grained deep learning networks, and Bilinear-CNN and CBAM are fine-grained deep learning networks.
[0132] Each iteration of the data set starts a new training based on the weights and parameters of the previous training results. Iterative training can extract more effective features for the image. As the number of iterations increases, the model gradually converges and obtains a stable recognition accuracy. The experiment shows that all six models can reach convergence within 48 iterations. 48 iterations of forest fire images were tested under four training set and test set sample allocation ratios (8:2, 7:3, 6:4 and 4:6) and the average recognition and classification accuracy was plotted, as shown in the figure. Figure 7 shown.
[0133] Depend on Figure 7 It can be seen that the model of this application obtains a high recognition accuracy and converges after the first iteration. The iteration process of the three fine-grained algorithms of the model of this application, Bilinear-CNN and CBAM is more stable than that of the other coarse-grained algorithms. Among them, the accuracy of the test set of Resnet50 has been in a jitter state under the four allocation ratios, and GoogleNet has overfitting except for the 8:2 allocation ratio. The performance of VGG16, Bilinear-CNN and CBAM is relatively stable, but VGG16 has large fluctuations between the 42nd to 48th iterations of 8:2 and the 33rd to 46th iterations of 6:4. CBAM has the highest accuracy compared with the other five models, because CBAM integrates the attention mechanism to extract fine-grained features. The model of this application uses ViT instead of CNN, which can extract more feature information at each iteration. The enhanced feature extraction ability of the model improves the convergence speed of the model. The integration of the self-attention mechanism as a variant of the attention mechanism will capture the internal correlation of data or features and reduce the dependence on external information, which makes the network recognition accuracy significantly improved.
[0134] 2.4 Recognition Accuracy Analysis
[0135] For 19,992 forest fire images, the recognition accuracy of the six models was statistically analyzed under the distribution ratios of 8:2, 7:3, 6:4 and 4:6 for the training set and the test set, as shown in Table 2. Under the four distribution ratios, the average recognition accuracy of the model of this application was 94.77%, 95.02%, 94.87% and 94.81%, respectively, which were higher than the other five models. Among them, the recognition effect of GoogleNet was not ideal under the four distribution ratios. This is because GoogleNet has limited feature extraction capabilities and is not suitable for the extraction of fine-grained image features. The recognition accuracy of CBAM is not much different from that of the model of this application, both higher than 93%. The recognition accuracy is 94.28% at the ratio of 6:4. The integration of attention mechanism into CBAM is one of its core algorithms, which shows that the use of attention mechanism can improve the model's extraction of fine-grained features.
[0136] Table 2 Average recognition accuracy %
[0137]
[0138] 3 Discussions
[0139] Forest fire is a natural disaster that is sudden, destructive, and difficult to deal with (Cao Yichao et al., 2020). In view of the fact that traditional coarse-grained image recognition methods cannot meet the problem of feature extraction of small target areas in aerial forest fire images, this application adopts a method combining self-attention mechanism and weak supervision learning to mine local feature differences in images and realize fine-grained recognition of forest fire images, which can improve the ability and efficiency of predicting and predicting fire conditions and fire risks in forest areas, and effectively prevent forest fires.
[0140] Wang et al. proposed a forest fire image recognition method based on convolutional neural network, and segmented the flame area, combined with the color shape area to learn the flame features, with an accuracy of 90.7%; however, this method can only identify the flame area, and does not consider the safe environment scenarios when there is thick smoke and no fire risk during the forest fire preheating stage and charcoal burning stage. In the forest fire image recognition study based on transfer learning, the Inception-v3 technology was used to identify satellite images using local binary patterns, achieving a recognition accuracy of 96.54%; however, this method mainly considers two situations: fire and non-fire. Relatively speaking, multi-category recognition is more complicated than binary classification recognition. The average recognition accuracy of the model in this application for fire, smoke and background is 94.87%, indicating that the model in this application can solve multi-category image recognition in complex scenes.
[0141] The model of this application uses the self-attention mechanism in ViT instead of CNN for fine-grained feature extraction, uses the superimposed sliding window method to serialize the image into sub-images, superimposes multiple layers of ViT to extract the sub-image area module features, and uses the self-attention mechanism to amplify the fine-grained features of the image. Comparing the recognition accuracy of the model of this application with that of VGG16, GoogleNet, Resnet50, Bilinear-CNN, and CBAM methods, it is found that the model of this application obtains the best recognition accuracy under the four training set and test set allocation ratios, and the accuracy variance is 0.009, indicating that the training set and test set allocation ratio has little effect on the recognition accuracy of the model of this application, and the model recognition performance is stable.
[0142] The convergence comparison analysis of the six models shows that the model of this application can converge quickly and is less affected by the sample size of the training set, that is, it can capture key fine-grained features with fewer images. Even in the presence of noise images outside the learning rules, the model of this application can still give correct predictions, indicating good robustness. The small probability of fireworks misjudgment in the model of this application is due to the cross-labeling of the fireworks coexistence images during manual labeling, which leads to information overlap when extracting fine-grained features.
[0143] The model in this application has fast convergence speed, stable performance and strong generalization ability, and can provide a new idea for the application of image recognition technology based on multi-head attention mechanism deep learning in forest fire monitoring and early warning.
[0144] 4 Conclusion
[0145] This application proposes an aerial forest fire image recognition model based on the self-attention mechanism. The aerial forest fire images collected by drones in Chongli District, Zhangjiakou City, Hebei Province are used as data sets. The overlapping sliding window segmentation method is used, and the ViT self-attention mechanism is used to extract fine-grained features of forest fire images. The target loss function is constructed based on the cross entropy loss and contrast loss functions, and the model is trained. The recognition accuracy and convergence of different models under different training set and test set allocation ratios are compared. The results show that: 1) The sample allocation ratio has little effect on the recognition accuracy of the model of this application, especially at a ratio of 7:3, the model of this application obtains a recognition accuracy of 95.04%; 2) The model of this application has a faster convergence speed and stronger generalization ability than the other five classic models; 3) The average recognition accuracy of the model of this application for smoke, fire and background images is 94.87%, which is higher than the other five classic models, indicating that the model of this application has good robustness and can provide a certain reference for forest fire warning and real-time monitoring research based on aerial images.
[0146] The model in this application realizes accurate recognition of smoke, fire and background images, but the generation and development of fire has certain dynamic characteristics. Based on aerial forest fire video data, the relevant frame image data is analyzed in the time series dimension, the dynamic characteristics of forest fire are mined, the precise positioning of the fire point area, the forecast of the actual fire scene and the prediction of forest fire behavior are the focus of the next step of research.
[0147] Similar parts between the embodiments provided in this application can be referenced to each other. The specific implementation methods provided above are only a few examples under the general concept of this application and do not constitute a limitation on the protection scope of this application. For those skilled in the art, any other implementation methods expanded based on the scheme of this application without creative work belong to the protection scope of this application.
Claims
1. Aerial forest fire image recognition method based on self-attention mechanism, characterized in that: The following steps are involved: Step 1: Get forest fire video as data source; Step 2: Filter out images through preprocessing methods and build a forest fire image dataset. At the same time, use data enhancement technology to enrich data diversity and improve the generalization ability of the model. Step 3: In the feature extraction stage, a 10-layer ViT is selected as the backbone network, and the image is serialized using an overlapping sliding pane method. After embedding the position information, it is used as the input of the first layer of ViT. The region selection modules extracted by the first 9 layers of ViT are batch-embedded into the 10th layer of ViT through a multi-head self-attention mechanism and a multi-layer perceptron mechanism, effectively amplifying the slight differences between sub-images to obtain small target features; Step 4: Adopt the contrast feature learning strategy, construct the target loss function for model training, obtain the image category label, and effectively improve the model's feature learning ability and recognition accuracy.
2. The method according to claim 1, characterized in that: Step 2: The preprocessing method is to extract frames and clean the data source obtained in the first step to obtain a forest fire image dataset.
3. The method according to claim 1, characterized in that: Step 2: Use data augmentation techniques as follows: 1) Random cropping: randomly crop a sub-region with a resolution of 448448 on the original image to highlight the proportion of local features in the sub-region; 2) Random horizontal flipping: flip the image horizontally with a probability of P = 0.5, that is, randomly select 50% of the images to simulate different shooting angles of the drone; 3) Standardization: standardize the image with mean (0.485, 0.465, 0.406) and standard deviation (0.229, 0.224, 0.225).
4. The method according to claim 1, characterized in that: In the third step, the specific steps are as follows: first, the image is divided into multiple sub-images, and the sub-images are serialized and embedded with position information. After the position information is embedded, it is used as the input of the first layer ViT. After superimposing 9 layers of ViT, the region selection module information extracted by the first 9 layers of ViT is combined with the multi-head self-attention mechanism and the multi-layer perceptron mechanism to be batch embedded into the 10th layer of ViT, which effectively amplifies the slight differences between the sub-images to obtain the fine-grained features of small target images.
5. The method according to claim 1 or 4, characterized in that: In the fourth step, the key hyperparameters used in the model training process include batch size, random seed, activation function, optimizer, learning rate, and number of iterations.
6. The method according to claim 1 or 4, characterized in that: In the third step, the specific steps of image serialization are as follows: Image serialization is to divide the image into non-overlapping sub-images to improve the efficiency of image processing, but this operation will lose the local adjacent structure information between sub-images. In order to maximize the retention of local adjacent structure information between sub-images, an overlapping sliding window segmentation method is used; assuming that the image resolution is H×W, the size of the sub-image after segmentation is P, the sliding window step size is S, and the image is divided into N blocks, then N is: Where: H represents the image height; W represents the image width; N H and N W Respectively represent the number of times the image is divided in height and width; After image segmentation, two adjacent sub-images will share an overlapping area of size (PS)×P, which contains local information of the image. In this segmentation method, the smaller the step size S, the more complete the local adjacent structural feature information is retained, but as S decreases, it will also lead to the problem of high algorithm complexity.
7. The method according to claim 1 or 4, characterized in that: In the third step, the specific steps of batch embedding are: use linear projection to embed each vectorized subgraph X P Mapped into the three-dimensional embedding space, embedding the learnable coordinates to record the position information, the embedded position information Z0 is: Where: N is the number of image batches; is the projection of batch embedding; E POS ∈R N×D for position embedding; The Transformer encoder contains L layers of multi-head self-attention MSA and multi-layer perceptron MLP. The output of the Lth layer with Z0 as input is: Z L =MSA(LN(Z L-1 ))+Z L-1 L∈1,2,…,N; (3) WITH L =MLP(LN(Z′ L ))+Z L L∈1,2,…,N; (4 Where: represents normalization processing; Z L represents a coded image; Represents a pixel value of a channel in an image; min(Z L ) and max(Z L ) represent the minimum and maximum grayscale values of pixels in this channel of the image respectively; ViT incorporates the self-attention mechanism and embeds an E POS The sub-image position information of the upper layer is the calculation result of the lower layer module; the first module in the last encoder When global features are used as classifier input, there is no need to consider the potential position information stored in other modules.
8. The method according to claim 7, characterized in that: In the third step, the self-attention mechanism is key to accurately locate the subtle differences in similar images in aerial forest fire image recognition. ViT's multi-head attention mechanism transmits the input information with differences to the last Transformer layer to locate the subtle differences in the image. Assuming that the model has N attention heads, when it reaches the 10th layer ViT after 9 layers of ViT, the hidden layer feature Z9 input to the 10th layer is: Attention head weights for: Then the hidden layer features input to the lth layer ViT are: The weight of the attention head at layer l is: Where: a l represents the N self-attention weights of the lth layer, l represents the lth layer ViT; Recursively apply matrix multiplication to the original attention weights at each layer: Where: a final represents the final attention head weight after multiplying the weight matrices of the first l layers of attention heads; In a final Among the N different attention heads, select the attention head with the largest weight (A1, A2, ..., A K ) as the index, extract the corresponding module in Z9 as the input selection module and combine it with the classification module as the joint input sequence, then the joint input sequence Z local It can be expressed as: Where: Represents the joint input sequence of the selection module and the classification module; The input selection module represents the segmented sub-image. Replacing the original input sequence with the information region module can obtain the classification module. The joint input sequence is used as the input of the last layer of ViT, which not only retains the global information of the image, but also facilitates the model to accurately extract subtle differences between classes and weaken background areas such as sky, snow, and vegetation.
9. The method according to claim 1 or 4, characterized in that: In the fourth step, the cross entropy of feature learning is used as a loss function to measure the predicted value and the actual value in the neural network. The cross entropy loss function L cross It is not very sensitive to small differences and cannot achieve fully supervised learning; the contrast loss function L con It can minimize the similarity between samples with different labels and maximize the similarity between samples with the same label. In order to prevent the contrast loss function from being disturbed by extremely small negative numbers, a reconciliation threshold ɑ is introduced. The effective L is obtained only when the similarity between samples is greater than ɑ. con ; If there are N samples, then the contrast loss function L con for: Where: z i and z j is the normalized feature; sim(z i ,z j ) is z i and z j The cosine similarity of The target loss function L can be constructed and used to train the model; L=L cross (y,y′)+L con (z); (13 Where: L cross (y,y') represents the cross entropy loss between the predicted label y' and the true label y; L con (z) represents the contrast loss of module z; When L cross When the loss is large, it means that the model effect is poor but the learning speed is fast. When the loss is small, it means that the model effect is good but the learning speed is slow. con The attention head can be made to focus on different areas. At this time, the samples with different labels have the minimum similarity, and the samples with the same label have the maximum similarity. The SGD optimizer and L feedback value are expressed as continuous gradient descent iteration and regression in model training. At this time, L tends to 0, and the model is continuously iterated and optimized.
10. The method according to claim 1 or 4, characterized in that: In the fourth step, accuracy evaluation: the recognition accuracy (ACC) of the model is expressed as the ratio of the number of successful predictions to the total number: Where: TP represents the number of samples predicted as positive; TN represents the number of samples predicted as negative; FP represents the number of samples predicted as negative; FN represents the number of samples predicted as positive. In the formula, y i and They represent the measured and predicted vertical projection areas of the crown of the ith tree respectively; represents the mean of the actual crown vertical projection area; n represents the number of samples in the test set.
Citation Information
Patent Citations
ViT-based aerial image recognition method
CN114842343A
Aviation forest fire image recognition method based on self-attention mechanism
CN118115895A
Cited By
Industrial equipment indicating lamp state identification method based on image sequence and Transform network
CN120808031A
