Road weather recognition method based on road semantic segmentation and convolutional neural network
Patent Information
- Application Number
- CN202210078289.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-24
- Publication Date
- 2024-09-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing technology has the problem of poor performance in classifying road weather images. In particular, the similar characteristics of sunny days and cloudy days make classification difficult, and it lacks fine-grained weather recognition capabilities.
Using a method based on road surface semantic segmentation and convolutional neural network, by constructing a semantic segmentation network and a weather recognition convolutional neural network, using ResNet18 and PPM pyramid pooling network to extract features, perform road surface binarization processing and global feature learning, combined with the global and pavement branch characteristics for weather classification.
It realizes end-to-end weather type identification, improves the accuracy of weather type identification, is real-time, saves redundant operations of road branch feature learning, and improves the operating efficiency of the neural network.
Smart Images

Figure CN114529877B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision and pattern recognition, and in particular to a road weather recognition method based on road semantic segmentation and convolutional neural network. Background Art
[0002] Weather recognition is one of the important classification problems in the field of computer vision. Using digital images to identify weather is helpful in various applications, especially in human-computer interaction. Highway road weather recognition is a specific identification of weather conditions on traffic roads to identify whether the weather conditions are severe. Judging the weather conditions through road images in a timely manner will help better implement traffic management.
[0003] At present, some common image classification problems have relatively mature solutions, but there are still many challenges in the road weather image classification task. For example, there is still room for improvement in the performance of existing image classification models in the field of weather classification; there are many similar features in different weather classifications, such as sunny and cloudy days; there are many challenges in the fine field of weather classification that need to be solved. Summary of the invention
[0004] The purpose of the present invention is to solve the above-mentioned defects in the prior art and provide a road weather recognition method based on road semantic segmentation and convolutional neural network.
[0005] The purpose of the present invention can be achieved by adopting the following technical solutions:
[0006] A road surface weather recognition method based on road surface semantic segmentation and convolutional neural network, the road surface weather recognition method comprising the following steps:
[0007] S1. Construct a semantic segmentation network, wherein the semantic segmentation network includes an encoder for feature extraction and downsampling and a decoder for fusing encoder multi-scale features and upsampling, the encoder adopts ResNet18 convolutional neural network, the decoder adopts PPM pyramid pooling convolutional neural network, inputs the original image P, and the semantic segmentation network outputs a semantic image S with the same size as the original image P and each pixel value equal to the semantic label of the original image P;
[0008] S2, performing road surface binarization processing on the semantic image S, retaining only the part of the semantic image S with the semantic label of road surface, and outputting a road surface binary image R;
[0009] S3, construct a weather recognition convolutional neural network, the input of the weather recognition convolutional neural network is the original image P and the road binary image R, the weather recognition convolutional neural network includes a global branch for processing global image features, a road surface branch for processing image road surface features, and a classification part for merging global branch features and road surface branch features for classification;
[0010] S4. Design a loss function to train the semantic segmentation network and the weather recognition convolutional neural network. First, train the semantic segmentation network, then obtain the road binary image R through the trained semantic segmentation network, and input the original image P and the road binary image R into the weather recognition convolutional neural network for training.
[0011] S5. Collect highway monitoring images P′ in real time, input the highway monitoring image P′ into the trained semantic segmentation network to obtain semantic image S′, and obtain road surface binary image R′ through road surface binarization operation, input the highway monitoring image P′ and road surface binary image R′ into the trained weather recognition convolutional neural network to identify the weather type corresponding to the image.
[0012] Furthermore, the encoder adopts a ResNet18 network, including a 7×7 convolution layer, a maximum pooling layer with a stride of 2, and 4 residual layers, wherein each residual layer is composed of 2 residual blocks, and each residual block is two 3×3 convolution layers of a jump connection structure. The encoder uses a residual convolution network with a jump connection structure, which can effectively avoid the gradient vanishing phenomenon when the network structure is deepened, thereby better extracting image features; the decoder adopts a PPM pyramid pooling network, which performs 4 pooling operations of different scales on the feature map output by the encoder, and the sizes of the 4 pooling operations are [1×1, 2×2, 3×3, 6×6], and then uses bilinear interpolation to upsample to the same size as the input image, and splices in the channel dimension, and finally inputs a convolution layer with a convolution kernel of 3×3 and a padding number of 1 and a convolution layer with a convolution kernel of 1×1 and the number of output channels equal to the number of label categories. The decoder using the pyramid pooling network performs multiple pooling of different scales on the feature maps learned by the encoder, and continues to perform convolution operations at different feature map scales, making full use of the coarse-grained and fine-grained contextual information of the image and performing integrated learning to improve the upsampling accuracy of the decoder.
[0013] Furthermore, in step S2, the semantic image S is subjected to road surface binarization processing to output a road surface binary image R, wherein the binarization processing formula is as follows:
[0014]
[0015] When the pixel value of the semantic image is equal to the corresponding value of the road surface label, the response value is 255, where S(x,y) represents the pixel value corresponding to the semantic image S at the coordinate (x,y); R(x,y) represents the pixel value corresponding to the road surface binary image R at the coordinate (x,y). In order to allow the weather recognition convolutional neural network to learn the characteristics of the road surface, the road surface binarization process discards the other parts of the semantic image, leaving only the road surface area as the effective part, and saves it in the form of a binary image for the mask operation of the road surface branch of the weather recognition convolutional neural network in the next step.
[0016] Furthermore, the weather recognition convolutional neural network includes a global branch, a road surface branch and a classification part, wherein the input of the global branch is the original image P, and a ResNet18 network is adopted, including a 7×7 convolution layer Conv1, a maximum pooling layer Max_Pool with a step size of 2, and 4 residual layers. The 4 residual layers are Conv2, Conv3, Conv4, and Conv5, respectively, and are all composed of 2 3×3 convolution layers using a jump connection structure. The global branch has two main functions: first, to learn all the contents of the entire image and output the deep abstract features of the entire image at the end of the global branch as one of the inputs of the classification part; second, to share the initial features learned by the global branch with the road surface branch, saving the steps of learning the initial features of the road surface branch.
[0017] The input of the road surface branch is the feature map F′, which is obtained by the road surface binary image R and the feature map F output by the Conv3 layer of the global branch. First, the feature map F output by the Conv3 layer in the global branch is obtained. The formula is as follows: F = Conv3(Conv2(Max_Pool((Conv1(P))))
[0018] The feature map F has been fully learned through the convolutional layers of Conv1, Conv2, and Conv3. Some simple and edge features of the entire image are fully learned. F is a relatively low-level and specific feature learned by the shallow part of the global branch. The purpose of the pavement branch is to focus on learning the pavement area on the basis of the global branch. Therefore, the pavement area, as a sub-area of the original image, can use the initial features learned by the global branch to further learn the deep features of the pavement area. In order to intercept the pavement area on the feature map F, the feature map F and the pavement binary image are masked to obtain the feature map F′ of the intermediate layer feature map (Conv3 layer) only about the pavement part. The formula is as follows: F′=F⊙Down_Sampling(R)
[0019] Among them, ⊙ is the element product, Down_Samplng() is the bilinear interpolation downsampling operation, which makes the size of the road binary image R consistent with the size of the feature map F. The feature map F′ is used to learn more abstract features of the road surface part. The network structure of the road surface branch is two 3×3 convolutional layers using a skip connection structure.
[0020] The classification part is used to fuse the features of the global branch and the road surface branch. The feature maps output by the global branch and the road surface branch are globally average pooled respectively, and a 512-dimensional feature vector and a 256-dimensional feature vector are output. The two are then concatenated into a 768-dimensional feature vector and input into the fully connected layer fc.
[0021] Furthermore, the loss function is as follows:
[0022]
[0023] Among them, Loss is the cross entropy function. For the semantic segmentation network, p k is the probability value of the category to which the pixel belongs predicted by the semantic segmentation network, p′ k is the probability value of the real pixel point, K represents the number of all pixels, and k represents the kth pixel point; for the weather recognition convolutional neural network, p k is the probability distribution of the category to which the input image belongs predicted by the weather recognition convolutional neural network, p′ k is the probability distribution of the real input image, K represents the total classification category, and k represents the kth classification category. Using the cross entropy function as the loss function, the learning speed is faster when the model effect is poor, and the learning speed is slower when the model effect is good, which is conducive to the training and convergence of the neural network.
[0024] Furthermore, we collected surveillance videos of highways in weather conditions including sunny, cloudy, rainy, foggy, and snowy days, and divided all the collected images into training and test datasets in a ratio of 7:3. In order to make the weather recognition results more accurate, the dataset covers as many scenes of highway monitoring sections as possible, such as toll booths, viaducts, intercity highways, and urban roads, as well as weather conditions of different severity, such as light rain that can see the road surface soaked and heavy rain that fills the entire picture with raindrops, light snow that does not form snow on the road surface and heavy snow that forms thick snow, etc.
[0025] Compared with the prior art, the present invention has the following advantages and effects:
[0026] 1) The present invention realizes the output of weather results directly from end to end, from image input to neural network, and then outputs weather types through neural network. Compared with using weather forecast to judge the road conditions of highways, it can judge the weather conditions of specific roads in a more fine-grained manner and has better real-time performance.
[0027] 2) The present invention takes advantage of the fact that the road surface features of highways can better reflect the weather conditions of the overall image, designs a global branch for learning the global features of the image and a road surface branch for learning the local features of the road surface, and combines the global features and the road surface features to achieve a higher accuracy in weather type recognition.
[0028] 3) The present invention utilizes the binary image of the road surface and the global branch to perform mask operations, which can effectively share the feature information of the road surface and save the network parameters of the road surface branch, reduce the redundant operations of re-extracting the primary features of the road surface, and improve the operating efficiency of the neural network. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0030] Figure 1 It is a step diagram of a road weather recognition method based on road semantic segmentation and convolutional neural network disclosed in the present invention;
[0031] Figure 2 It is a step diagram of preprocessing and extracting a road surface binary image of a road surface weather recognition method based on road surface semantic segmentation and convolutional neural network disclosed in the present invention;
[0032] Figure 3 It is a schematic diagram of the fusion principle of road semantic segmentation and convolutional neural network in the method of the present invention;
[0033] Figure 4 This is a comparison chart of the accuracy of weather classification and recognition performed by the method of the present invention and the convolutional neural network ResNet18. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] Example 1
[0036] like Figure 1 As shown, this embodiment discloses a road weather recognition method based on road semantic segmentation and convolutional neural network, comprising the following steps:
[0037] S1. Construct a semantic segmentation network, wherein the semantic segmentation network includes an encoder for feature extraction and downsampling and a decoder for fusing encoder multi-scale features and upsampling, the encoder adopts ResNet18 convolutional neural network, the decoder adopts PPM pyramid pooling convolutional neural network, inputs the original image P, and the semantic segmentation network outputs a semantic image S with the same size as the original image P and each pixel value equal to the semantic label of the original image P;
[0038] S2, performing road surface binarization processing on the semantic image S, retaining only the part of the semantic image S with the semantic label of road surface, and outputting a road surface binary image R;
[0039] S3, construct a weather recognition convolutional neural network, the input of the weather recognition convolutional neural network is the original image P and the road binary image R, the weather recognition convolutional neural network includes a global branch for processing global image features, a road surface branch for processing image road surface features, and a classification part for merging global branch features and road surface branch features for classification;
[0040] S4. Design a loss function to train the semantic segmentation network and the weather recognition convolutional neural network. First, train the semantic segmentation network, then obtain the road binary image R through the trained semantic segmentation network, and input the original image P and the road binary image R into the weather recognition convolutional neural network for training.
[0041] Among them, the loss function is as follows:
[0042] Among them, Loss is the cross entropy function. For the semantic segmentation network, p k is the probability value of the category to which the pixel belongs predicted by the semantic segmentation network, p′ k is the probability value of the real pixel point, K represents the number of all pixels, and k represents the kth pixel point; for the weather recognition convolutional neural network, p k is the probability distribution of the category to which the input image belongs predicted by the weather recognition convolutional neural network, p′ k is the probability distribution of the real input image, K represents the total classification category, and k represents the kth classification category.
[0043] S5. Collect highway monitoring images P′ in real time, input the highway monitoring image P′ into the trained semantic segmentation network to obtain semantic image S′, and obtain road surface binary image R′ through road surface binarization operation, input the highway monitoring image P′ and road surface binary image R′ into the trained weather recognition convolutional neural network to identify the weather type corresponding to the image.
[0044] Constructing a semantic segmentation network and inputting generated semantic images are the preprocessing steps of the entire road weather recognition method. The semantic segmentation network needs to be trained in advance to obtain good semantic segmentation performance, and only after the road surface binarization operation can the learning and training of the weather recognition convolutional neural network begin.
[0045] like Figure 2 As shown in the figure, the encoder in the semantic segmentation network adopts the ResNet18 network, including a 7×7 convolutional layer, a maximum pooling layer with a stride of 2, and 4 residual layers, where each residual layer is composed of 2 residual blocks, and each residual block is two 3×3 convolutional layers with a skip connection structure; the decoder in the semantic segmentation network adopts the PPM pyramid pooling network, which performs 4 pooling operations of different scales on the feature maps output by the encoder, and the sizes of the 4 pooling operations are [1×1, 2×2, 3×3, 6×6], respectively, and then uses bilinear interpolation to upsample to the same size as the input image, and splices it in the channel dimension, and finally inputs a convolution layer with a convolution kernel of 3×3 and a padding number of 1 and a convolution layer with a convolution kernel of 1×1 and the number of output channels equal to the number of label categories.
[0046] like Figure 2 As shown, in step S2, the semantic image S is subjected to road surface binarization processing, and a road surface binary image R is output, wherein the binarization processing formula is as follows:
[0047]
[0048] When the pixel value of the semantic image is equal to the corresponding value of the road surface label, the response value is 255, where S(x,y) represents the pixel value corresponding to the semantic image S at the coordinate (x,y); R(x,y) represents the pixel value corresponding to the road surface binary image R at the coordinate (x,y).
[0049] like Figure 3 As shown in the figure, the weather recognition convolutional neural network includes a global branch, a road surface branch and a classification part. The input of the global branch is the original image P. The ResNet18 network is used, including a 7×7 convolution layer Conv1, a maximum pooling layer Max_Pool with a step size of 2, and 4 residual layers. The 4 residual layers are Conv2, Conv3, Conv4, and Conv5, which are all composed of 2 3×3 convolution layers with a skip connection structure. The global branch is used to extract global features of the input original image P;
[0050] The input of the road surface branch is the feature map F′, which is obtained by the road surface binary image R and the feature map F output by the Conv3 layer of the global branch. First, the feature map F output by the Conv3 layer in the global branch is obtained. The formula is as follows:
[0051] F=Conv3(Conv2(Max_Pool((Conv1(P))))
[0052] The feature map F is fully learned through the convolution layers of Conv1, Conv2 and Conv3 to learn some simple and edge features of the whole image. Then, the feature map output by the Conv3 layer and the road binary image are masked to obtain the feature map F′ of the Conv3 layer only about the road surface. The formula is as follows:
[0053] F′=F⊙Down_Sampling(R)
[0054] Among them, ⊙ is the element product, Down_Samplng() is the bilinear interpolation downsampling operation, which makes the size of the road binary image R consistent with the size of the feature map F. The feature map F′ is used to learn more abstract features of the road surface part. The network structure of the road surface branch is two 3×3 convolutional layers using a skip connection structure.
[0055] The classification part is used to fuse the features of the global branch and the road surface branch. The feature maps output by the global branch and the road surface branch are globally average pooled respectively, and a 512-dimensional feature vector and a 256-dimensional feature vector are output. The two are then concatenated into a 768-dimensional feature vector and input into the fully connected layer fc.
[0056] Example 2
[0057] This embodiment further discloses the training process of the semantic segmentation network. In order to train the semantic segmentation network, this example uses the ade20k dataset (see the document: Zhou B, Zhao H, Puig X, et al. Scene parsing through ade20k dataset [C] / / Proceedings of the IEEE conference on computer vision and pattern recognition. 2017: 633-641.), which is a scene dataset with 20,000 images and 150 semantic segmentation categories, of which the road surface belongs to the sixth category; in order to train the weather recognition convolutional neural network, this embodiment samples and intercepts video frames of highway surveillance videos in Guangdong, Jiangxi and Liaoning provinces, sampling a total of 45,350 images, 5 categories (sunny, cloudy, rainy, foggy and snowy), and divides all sampled images into training sets and test sets in a ratio of 7:3.
[0058] Example 3
[0059] This embodiment performs network training and testing on a host with 32G memory. The host is equipped with 1 Nvidia1080Ti GPU and Intel Core i7-6700 CPU, running at a main frequency of 3.41GHz, Windows10 operating system, and Python programming language. Based on the pytorch deep learning framework, in the collected road weather data set, the image labels are divided into 5 categories, namely sunny, cloudy, rainy, foggy, and snowy. 36,380 images are used for network training, the learning rate is set to 0.001, the network is iterated 20 times, and 8,970 images are used as the test set. Figure 4 The weather classification accuracy of the proposed method is 84.96%, which is 3.62% higher than the accuracy of the convolutional neural network ResNet18 (81.34%). Figure 4 From the confusion matrix, it can be seen that, except for cloudy classification, the accuracy of the present invention in foggy, rainy and sunny days is higher than that of ResNet18. It can be seen that after introducing feature learning of the road surface area, the present invention has learned more features that are conducive to weather recognition, which proves the effectiveness of the present invention.
[0060] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A road weather recognition method based on road semantic segmentation and convolutional neural network, characterized in that: The road weather identification method comprises the following steps: S1. Construct a semantic segmentation network, wherein the semantic segmentation network includes an encoder for feature extraction and downsampling and a decoder for fusing encoder multi-scale features and upsampling. The encoder adopts ResNet18 convolutional neural network, and the decoder adopts PPM pyramid pooling convolutional neural network. The original image P is input, and the semantic segmentation network outputs a semantic image S with the same size as the original image P and each pixel value equal to the semantic label of the original image P; the encoder adopts ResNet18 network, including a 7×7 convolutional layer, a maximum pooling layer with a step size of 2, and 4 residual layers, wherein, Each residual layer is composed of 2 residual blocks, and each residual block is two 3×3 convolutional layers of a skip connection structure; the decoder adopts a PPM pyramid pooling network, and the PPM pyramid pooling network performs 4 pooling operations of different scales on the feature map output by the encoder, and the sizes of the 4 pooling operations are [1×1, 2×2, 3×3, 6×6], and then uses bilinear interpolation to upsample to the same size as the input image, and splices in the channel dimension, and finally inputs a convolution layer with a convolution kernel of 3×3 and a padding number of 1 and a convolution layer with a convolution kernel of 1×1 and the number of output channels equal to the number of label categories in sequence; S2, performing road surface binarization processing on the semantic image S, retaining only the part of the semantic image S with the semantic label of road surface, and outputting a road surface binary image R; S3, construct a weather recognition convolutional neural network, the input of the weather recognition convolutional neural network is the original image P and the road surface binary image R, the weather recognition convolutional neural network includes a global branch for processing global image features, a road surface branch for processing image road surface features, and a classification part for merging global branch features and road surface branch features and classifying; the weather recognition convolutional neural network includes a global branch, a road surface branch and a classification part, wherein, The input of the global branch is the original image P. The ResNet18 network is used, including a 7×7 convolution layer Conv1, a maximum pooling layer Max_Pool with a step size of 2, and 4 residual layers. The 4 residual layers are Conv2, Conv3, Conv4, and Conv5, which are all composed of 2 3×3 convolution layers with 2 skip connection structures. The global branch is used to extract global features of the input original image P; The input of the road surface branch is the feature map F′, which is obtained by the road surface binary image R and the feature map F output by the Conv3 layer of the global branch. First, the feature map F output by the Conv3 layer in the global branch is obtained. The formula is as follows: F=Conv3(Conv2(Max_Poo1((Conv1(P)))) Secondly, the feature map output by the Conv3 layer and the road binary image are masked to obtain the feature map F′ of the Conv3 layer only about the road surface. The formula is as follows: F′=F☉Dowm_Sampling(R) Among them, ⊙ is the element product, Down_Samplng() is the bilinear interpolation downsampling operation, which makes the size of the road binary image R consistent with the size of the feature map F. The feature map F′ is used to learn more abstract features of the road surface part. The network structure of the road surface branch is two 3×3 convolutional layers using a skip connection structure. The classification part is used to fuse the features of the global branch and the road surface branch. The feature maps output by the global branch and the road surface branch are globally averaged and pooled respectively, and a 512-dimensional feature vector and a 256-dimensional feature vector are output. The two are then concatenated to form a 768-dimensional feature vector and input into the fully connected layer fc. S4. Design a loss function to train the semantic segmentation network and the weather recognition convolutional neural network. First, train the semantic segmentation network, then obtain the road binary image R through the trained semantic segmentation network, and input the original image P and the road binary image R into the weather recognition convolutional neural network for training. S5. Collect highway monitoring images P′ in real time, input the highway monitoring image P′ into the trained semantic segmentation network to obtain semantic image S′, and obtain road surface binary image R′ through road surface binarization operation, input the highway monitoring image P′ and road surface binary image R′ into the trained weather recognition convolutional neural network to identify the weather type corresponding to the image.
2. The road weather recognition method based on road semantic segmentation and convolutional neural network according to claim 1 is characterized in that: In step S2, the semantic image S is subjected to road surface binarization processing to output a road surface binary image R, wherein the binarization processing formula is as follows: When the pixel value of the semantic image is equal to the corresponding value of the road surface label, the response value is 255, where S(x,y) represents the pixel value corresponding to the semantic image S at the coordinate (x,y); R(x,y) represents the pixel value corresponding to the road surface binary image R at the coordinate (x,y).
3. The road weather recognition method based on road semantic segmentation and convolutional neural network according to claim 1 is characterized in that: The loss function is as follows: Among them, Loss is the cross entropy function. For the semantic segmentation network, p k is the probability value of the category to which the pixel belongs predicted by the semantic segmentation network, p′ k is the probability value of the real pixel point, K represents the number of all pixels, and k represents the kth pixel point; for the weather recognition convolutional neural network, p k is the probability distribution of the category to which the input image belongs predicted by the weather recognition convolutional neural network, p′ k is the probability distribution of the real input image, K represents the total classification categories, and k represents the kth classification category.
4. The road weather recognition method based on road semantic segmentation and convolutional neural network according to any one of claims 1 to 3, characterized in that: Surveillance videos of highways under various weather conditions including sunny, cloudy, rainy, foggy, and snowy days are collected, and all collected images are divided into training and test data sets in a ratio of 7:3.
