Ice and snow crystal particle image classification method based on lightweight network
Technical Field
The invention relates to the technical field of computer vision, in particular to an ice and snow crystal particle image classification method based on a lightweight network.
Background
Ice and snow crystal particles are important atmospheric aerosol and have important influence on climate and weather. The correct classification of the ice and snow crystal particle images is beneficial to researchers to better understand and research weather patterns, so that weather changes are predicted more accurately, and the accuracy of weather forecast is improved. Secondly, the ice and snow crystal particles can change optical properties, sky colors, human visual feelings and the like in the atmosphere, and the information influences the observation capability and the feeling experience of people. The correct classification of ice and snow crystal particles is helpful for relevant workers to better understand the influencing factors, so that more reasonable weather policies are formulated to ensure the visual experience and health of the public.
In recent years, with the rapid development of deep learning, the artificial intelligence technology has a great application potential in the processing and analysis of images and big data, and the application in the atmospheric science is also valued by researchers, and the artificial intelligence, especially the deep learning technology, is successively applied to the automatic classification research of the ice and snow grain shape. The classical is that the pre-trained residual network ResNet152 is used for identifying the shape of ice and snow crystal particles, and the ICDC (Ice Crystals Database in China, ICDC) ice and snow crystal data set containing 7282 images in 10 categories is used for realizing 96% of identification accuracy, but the prediction effect on small sample data is poor. In order to improve the possible small sample prediction problem of the residual convolution network, an embedded hypergraph convolution layer based deep learning method is proposed, and the embedded hypergraph structure is used for carrying out characteristic relation construction from local and global graph structure, so that the method is improved in the small sample expression, and a better classification effect is obtained under the condition of unbalanced sample distribution.
However, the following problems exist in the prior art: 1. the method is lack of effective extraction of morphological characteristics of ice and snow crystal grains: the existing ice and snow grain sub-classification method based on the deep convolution network has limited capability when processing the problems of large intra-class difference, small inter-class difference fine granularity and unbalanced samples of ice and snow grain sub-, is difficult to fully extract and express characteristic information in ice and snow grain images, causes errors, and reduces classification accuracy and reliability. 2. The reasoning speed is slow: the existing ice and snow grain sub-classification methods based on the deep convolutional network have the problems of over-deep depth, excessive IO (input/output) expenditure calculation and the like, so that the reasoning speed is low, and the methods have a large optimization space in terms of the reasoning speed for rapidly identifying and classifying ice and snow grains. 3. The parameter number is large: the existing ice and snow crystal particle classification method based on the deep convolution network has large-scale parameter, which directly leads to the difficulty in embedding the algorithm into the terminal equipment and limits the practical application of the algorithm.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the present disclosure and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The invention aims to overcome the defects of the prior art, provides an ice and snow crystal particle image classification method based on a lightweight network, and solves the defects of the prior art.
The aim of the invention is achieved by the following technical scheme: an ice and snow crystal particle image classification method based on a lightweight network, the classification method comprises the following steps:
training the built lightweight network UDiNet by using a training sample data set containing a plurality of classified ice and snow crystal particle images, classifying, testing and verifying the ice and snow crystal particle images of the lightweight network UDiNet by using a testing data set of the ice and snow crystal particle images, and selecting model parameters with the best performance for storage;
inputting the obtained ice and snow crystal particle image into a lightweight network UDiNet which is trained and tested, and carrying out feature extraction and category reasoning calculation on ice and snow crystal particle sub-images to obtain a predicted category so as to realize automatic classification of the ice and snow crystal particle image.
The backbone network of the lightweight network UDiNet is a channel reorganization network, and the lightweight network UDiNet comprises a channel reorganization convolution unit, a lightweight attention mechanism layer and a depth separable cavity convolution layer;
the channel reorganization convolution unit is used for constructing a channel reorganization network, and rearranging information of each channel group in the feature map during grouping convolution to form a channel rearrangement mechanism, so that information fusion among channels is increased; the lightweight attention mechanism layer is used for weighting importance of the feature map, and the attention weight obtained through learning enables the lightweight network UDiNet to automatically select and pay attention to the features which are more important for the current task;
constructing a channel reorganization network by using basic units formed by group convolution and point-by-point convolution, and introducing a group channel rearrangement mechanism into the group convolution to take an output characteristic diagram of a basic unit of the last layer of the channel reorganization network as an input of a depth separable cavity convolution layer.
The depth separable cavity convolution layer uses a residual network structure and comprises depth separable cavity convolution branches and short connection analysis, wherein the two branches respectively take a feature image and the number of channels generated by a basic unit of the last layer of a channel reorganization network as standards, global feature extraction is carried out on an input feature image through the depth separable cavity convolution branches, local information acquisition is carried out on the input feature image through the short connection branches, and the two branch output feature images are connected in the channel dimension to realize channel expansion.
The global feature extraction is carried out on the input feature map through the depth separable cavity convolution branch, and the local information acquisition is carried out on the input feature map through the short connection branch specifically comprises the following steps:
a1, learning characteristic information of the detail of the ice and snow grain sub-image on a single characteristic image through depth convolution with the convolution kernel size of 3 multiplied by 3, and then integrating information of a plurality of characteristic images of the ice and snow grain particle image through point-by-point convolution with the convolution kernel size of 1 multiplied by 1;
a2, carrying out ascending dimension through point-by-point convolution with the convolution kernel size of 1×1 to obtain characteristic information of more different channels of the ice and snow crystal particle image, and then filling two layers of pixel points with the value of 0 along the periphery of the characteristic image so as to not interfere the arrival noise of the characteristic information while expanding the ice and snow crystal grain sub-characteristic image;
a3, learning the characteristic information of the whole ice and snow crystal grain sub-characteristic image on a single characteristic image through the depth convolution with the convolution kernel size of 3 multiplied by 3, and integrating the information of a plurality of characteristic images of the ice and snow crystal grain image through the point-by-point convolution with the convolution kernel size of 1 multiplied by 1;
and A4, connecting the calculation results of the step A1 and the step A2 along the channel dimension to be used as an output characteristic diagram of the depth separable cavity convolution layer.
The training of the lightweight network UDiNet comprises the following contents:
parameters of a convolutional neural network pre-trained on a large image dataset ImageNet are used for initializing a convolutional layer in a backbone network of a lightweight network UDiNet;
using the Pytorch framework, epochs set to 100 and batch Size set to 128;
using AdamW optimization algorithm, the learning rate was set to 0.0001;
in the public data set ICDC including ice and snow crystal particle images of a plurality of categories, 80% of the image data are randomly selected for training for each category.
The test data set of the ice and snow crystal particle image is used for classifying, testing and verifying the ice and snow crystal particle image of the lightweight network UDiNet, and the model parameters with the best performance are selected for storage, which specifically comprises the following contents:
when each Epoch training is finished, testing the lightweight network UDiNet by using the same test sample data set, and evaluating a classification result obtained by the test;
by the formulaCalculating classification accuracy of lightweight network UDiNet for all test sample data sets, ŷ i Representing class, y, of ith image predicted by lightweight network UDiNet i Is the corresponding true class value, M is the total number of images input into the network model at the time of testing, eq (y i, ŷ i ) Is an equal function if and only if y i Approach to ŷ i When the lightweight network UDiNet has the advantages that the better the prediction performance is, the closer the accuracy is to 1;
the data used for testing are all the remaining 20% of image data except a training sample data set in a public data set ICDC containing ice and snow crystal particle images of a plurality of categories;
and saving a lightweight network UDiNet with highest accuracy calculated in multiple tests.
The plurality of classifications of the ice and snow crystal particle image comprise rosettes, long columns, short columns, hollow columns, spheres, small irregularities, plates, hexagonal snowflakes and complex shapes; and (3) inputting the depth separable cavity convolution layer output feature map into a convolution classifier, and normalizing the output probability by using a softmax function to finish the classification task of the ice and snow grain sub-images of 10 classes.
The invention has the following advantages: the ice and snow crystal particle image classification method based on the lightweight network can effectively integrate global and local characteristics through the depth separable cavity convolution layer, has good classification effect on detail characteristics of ice and snow crystal particles with small difference in scale and structure, and can greatly reduce the calculation amount and the parameter amount of a model by dividing a common roll into two steps through the depth separable convolution; the depth separable cavity volume integral branch uses an inverse bottleneck structure, so that a low-dimensional feature map can be mapped to a high dimension under the condition of fewer input feature map channels, and feature extraction is performed on data in the high dimension, thereby reducing loss in the process of extracting feature map information; the lightweight model architecture design is used, so that the model parameter is greatly reduced, the model reasoning speed is accelerated, and the deployment application in various edge computing terminals is expected; by designing the convolution classifier, the space information is reserved, and meanwhile, the convolution classifier has certain robustness on translational invariance of input, and compared with a full-connection classifier, the convolution classifier not only improves the parameter efficiency of a model, but also enhances the generalization capability of the model.
Drawings
FIG. 1 is a schematic flow chart of the present invention;
fig. 2 is a schematic structural diagram 1 of a lightweight network UDiNet of the present invention;
fig. 3 is a schematic structural diagram of a lightweight network UDiNet of the present invention 2;
fig. 4 is a schematic structural diagram of a lightweight network UDiNet of the present invention, fig. 3;
fig. 5 is a schematic diagram of the architecture of the lightweight network UDiNet of the present invention 4;
FIG. 6 is a schematic diagram of a depth separable void convolution layer.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, which are generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Accordingly, the following detailed description of the embodiments of the present application, provided in connection with the accompanying drawings, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, are intended to be within the scope of the present application. The invention is further described below with reference to the accompanying drawings.
As shown in fig. 1, the invention specifically relates to an ice and snow crystal particle image classification method based on a lightweight network UDiNet. The network greatly reduces the parameter quantity and the calculated quantity required by the network through the depth separable rolls, and solves the pain points with overlarge parameter template and overlarge calculated quantity of the existing ice and snow grain sub-classification algorithm. Secondly, UDiNet uses a kind of deep separable cavity convolution to realize the quick fusion of space information and position information in the feature map, has increased the receptive field of network, makes the network still possess more accurate classification ability when the quick classification information of integrating. The method specifically comprises the following steps:
training the built lightweight network UDiNet by using a training sample data set containing a plurality of classified ice and snow crystal particle images, classifying, testing and verifying the ice and snow crystal particle images of the lightweight network UDiNet by using a testing data set of the ice and snow crystal particle images, and selecting model parameters with the best performance for storage;
inputting the obtained ice and snow crystal particle image into a lightweight network UDiNet which is trained and tested, and carrying out feature extraction and category reasoning calculation on ice and snow crystal particle sub-images to obtain a predicted category so as to realize automatic classification of the ice and snow crystal particle image.
The input of the lightweight network UDiNet is 224×224×3 RGB color ice and snow crystal particle image, the backbone network is channel reorganization network, the lightweight network UDiNet comprises a channel reorganization convolution unit, a lightweight attention mechanism layer and a depth separable cavity convolution layer;
wherein, the depth separable hole convolution layer is the last layer convolution network of the network, and each lightweight attention mechanism layer of the lightweight network UDiNet is activated by using ReLU6, and the batch normalization Batchnormal acceleration training with an index smoothing of momentum=0.9 improves the performance.
As shown in fig. 2-5, first, a general convolution with a convolution kernel size of 3×3 is used to perform preliminary feature extraction in shallow layers, then a channel reorganization unit and an attention mechanism module are combined to perform channel reorganization feature learning with an attention mechanism, then a depth separable hole convolution is used in the last layer of a feature extractor part of a network to perform full feature extraction and integration on all features between channels and in channels, and finally, based on the output of the network feature extractor, a full connection layer is used to predict the category of a model.
The channel reorganization convolution unit is used for constructing a channel reorganization network, and rearranges the information of each channel group in the feature map during grouping convolution to form a channel rearrangement mechanism, so that information fusion among channels is increased. In order to further increase the recognition accuracy, as shown in fig. 3 and fig. 4, a lightweight attention mechanism layer is introduced after the step 2 and the step 3 of the channel reorganization network to realize the importance weighting of the feature map, and the model can automatically select and pay attention to the features which are more important to the current task through the attention weight obtained by learning. The method is beneficial to improving the perception capability of the model to key features and reducing the interference of redundant information, so that the performance and generalization capability of the model are improved. And finally, taking the output characteristic diagram of the final layer of channel reorganization convolution unit as the input of the depth separable cavity convolution layer.
Constructing a channel reorganization network by using basic units formed by group convolution and point-by-point convolution, and introducing a group channel rearrangement mechanism into the group convolution to take an output characteristic diagram of a basic unit of the last layer of the channel reorganization network as an input of a depth separable cavity convolution layer.
The depth separable cavity convolution layer uses a residual network structure and comprises depth separable cavity convolution branches and short connection analysis, wherein the two branches respectively take a feature image and the number of channels generated by a basic unit of the last layer of a channel reorganization network as standards, global feature extraction is carried out on an input feature image through the depth separable cavity convolution branches, local information acquisition is carried out on the input feature image through the short connection branches, and the two branch output feature images are connected in the channel dimension to realize channel expansion.
As shown in fig. 6, global feature extraction is performed on an input feature map through a depth separable cavity convolution branch, and local information acquisition is performed on the input feature map through a short connection branch, which specifically includes:
a1, learning characteristic information of the detail of the ice and snow grain sub-image on a single characteristic image through depth convolution with the convolution kernel size of 3 multiplied by 3, and then integrating information of a plurality of characteristic images of the ice and snow grain particle image through point-by-point convolution with the convolution kernel size of 1 multiplied by 1;
a2, carrying out ascending dimension through point-by-point convolution with the convolution kernel size of 1×1 to obtain characteristic information of more different channels of the ice and snow crystal particle image, and then filling two layers of pixel points with the value of 0 along the periphery of the characteristic image so as to not interfere the arrival noise of the characteristic information while expanding the ice and snow crystal grain sub-characteristic image;
a3, learning the characteristic information of the whole ice and snow crystal grain sub-characteristic image on a single characteristic image through the depth convolution with the convolution kernel size of 3 multiplied by 3, and integrating the information of a plurality of characteristic images of the ice and snow crystal grain image through the point-by-point convolution with the convolution kernel size of 1 multiplied by 1;
and A4, connecting the calculation results of the step A1 and the step A2 along the channel dimension to be used as an output characteristic diagram of the depth separable cavity convolution layer.
The loss function of the lightweight network UDiNet selects a cross entropy loss function, which is defined as shown in the following formula:
wherein N is the number of samples, x i Is an inputted ice and snow crystal particle image, and the probability distribution p (x i ) For desired output, i.e. ice and snow crystal particle image x i Probability distribution q (x i ) For actually outputting, i.e. the network model is used for imaging the ice and snow crystal particles x i The smaller the losses of the predicted category, the closer the distribution of the two is, the better the classification result is.
The training of the lightweight network UDiNet comprises the following contents:
parameters of a convolutional neural network pre-trained on a large image dataset ImageNet are used for initializing a convolutional layer in a backbone network of a lightweight network UDiNet;
using the Pytorch framework, epochs set to 100 and batch Size set to 128;
using AdamW optimization algorithm, the learning rate was set to 0.0001;
in the public data set ICDC including ice and snow crystal particle images of a plurality of categories, 80% of the image data are randomly selected for training for each category. Meanwhile, as the number of samples of the existing data set is small, in order to improve the generalization capability of the model, preprocessing operations such as random aspect ratio cutting, random horizontal overturning and the like are performed on the data to enhance the data, so that the data set is expanded to a certain extent; the image is standardized, the image data is subjected to centering through mean removal, and according to the convex optimization theory and the data probability distribution related knowledge, the data centering accords with the data distribution rule, so that the generalization effect after training is easier to obtain; furthermore, to accommodate the input size of the UDiNet model, random cropping is used to unify the image size to 224×224. The specific pretreatment operation is as follows: random horizontal overturn and vertical overturn of the image are realized with probability of 0.8; filling 0 according to the size of the image to enable the size of the image to be square, and then unifying the image to 256×256 size by using a bilinear interpolation method of a traditional interpolation algorithm; 224×224 random clipping is performed again for the model UDiNet input; and performing pixel-by-pixel standardization processing, namely subtracting the average value of the pixel values of the corresponding channels from the pixel value of each channel in the image and dividing the average value by the standard deviation to realize data centralization. When the pixel-by-pixel standardization processing is performed, the average value of the three RGB channels in the training set is 0.056,0.331,0.666, and the standard deviation is 0.080,0.218,0.303.
The test data set of the ice and snow crystal particle image is used for classifying, testing and verifying the ice and snow crystal particle image of the lightweight network UDiNet, and the model parameters with the best performance are selected for storage, which specifically comprises the following contents:
when each Epoch training is finished, testing the lightweight network UDiNet by using the same test sample data set, and evaluating a classification result obtained by the test;
by the formulaCalculating classification accuracy of lightweight network UDiNet for all test sample data sets, ŷ i Representing class, y, of ith image predicted by lightweight network UDiNet i Is the corresponding true class value, M is the total number of images input into the network model at the time of testing, eq (y i, ŷ i ) Is an equal function if and only if y i Approach to ŷ i When the lightweight network UDiNet has the advantages that the better the prediction performance is, the closer the accuracy is to 1;
the data used for testing are all the remaining 20% of image data except a training sample data set in a public data set ICDC containing ice and snow crystal particle images of a plurality of categories; and the following preprocessing operation is carried out on the network before the network is input: scaling the image to 256 x 256 using bilinear interpolation; randomly cropping the image to 224×224; and performing pixel-by-pixel standardization processing, namely subtracting the average value of the pixel values of the corresponding channels from the pixel value of each channel in the image and dividing the average value by the standard deviation to realize data centralization. When pixel-by-pixel standardization processing is carried out, the average value of RGB channels in a test set is 0.056,0.331,0.666, and the standard deviation is 0.080,0.218,0.303 respectively;
and saving a lightweight network UDiNet with highest accuracy calculated in multiple tests.
The plurality of classifications of the ice and snow crystal particle image comprise rosettes, long columns, short columns, hollow columns, spheres, small irregularities, plates, hexagonal snowflakes and complex shapes; and (3) inputting the depth separable cavity convolution layer output feature map into a convolution classifier, and normalizing the output probability by using a softmax function to finish the classification task of the ice and snow grain sub-images of 10 classes.
The foregoing is merely a preferred embodiment of the invention, and it is to be understood that the invention is not limited to the form disclosed herein but is not to be construed as excluding other embodiments, but is capable of numerous other combinations, modifications and environments and is capable of modifications within the scope of the inventive concept, either as taught or as a matter of routine skill or knowledge in the relevant art. And that modifications and variations which do not depart from the spirit and scope of the invention are intended to be within the scope of the appended claims.