A method and related device for image classification
By constructing spatial spectrum features and combining with deep network models to extract spatial and spectral features of multispectral images, the problem of low image classification accuracy in the existing technology is solved, and higher image classification accuracy and object recognition effects are achieved.
Patent Information
- Application Number
- CN201911041029.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-10-29
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2039-10-29
AI Technical Summary
The existing technology only considers the spatial characteristics of the image in image classification and cannot fully characterize all attribute information of the image, resulting in low accuracy of classification results and the inability to correctly identify objects in the image.
By obtaining the spatial and spectral features of multispectral images, constructing spatial spectral features, using deep network models to extract and fuse spatial and spectral features, and performing multi-dimensional representation of image attribute information, thereby improving the accuracy of image classification.
It effectively improves the accuracy of image classification results, accurately identifies objects in images, and comprehensively considers the spatial and spectral information of images through multi-dimensional characterization of spatial spectral features, improving the spatial correlation and spectral correlation of classification results.
Smart Images

Figure CN110991236B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence (AI), and in particular to an image classification method and related devices. Background Art
[0002] Artificial intelligence (AI) technology is a technical discipline that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence. AI technology achieves the best results by sensing the environment, acquiring knowledge and using knowledge. In other words, artificial intelligence technology is a branch of computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Using artificial intelligence for image processing is a common application of artificial intelligence.
[0003] Take the monitoring scenario as an example. In this scenario, a visible light image can be obtained through a monitoring device. The visible light image usually contains multiple types of objects, such as people, houses, boxes, etc. In order to capture a certain type of target object for monitoring, a partial image containing a certain object (or certain objects) can be selected from the visible light image as the target image to be classified, and then the spatial features of the target image (used to characterize the geometric shape, texture, etc. of the object) are extracted through a neural network, and the spatial features of the target image are classified through the neural network to determine the category to which the target image belongs.
[0004] In the above image classification process, since only the spatial features of the image are considered, it is not enough to comprehensively represent all the attribute information of the image, resulting in low accuracy of the image classification results and inability to correctly identify the objects in the image. Summary of the invention
[0005] The embodiments of the present application provide a method and related devices for image classification, which can effectively improve the accuracy of image classification results and accurately identify objects in images.
[0006] A first aspect of an embodiment of the present application provides a method for image classification, the method comprising:
[0007] If image classification is required, a target image to be classified may be obtained first, wherein the target image is an image generated based on a multispectral image;
[0008] After obtaining the target image, an image classification model can be obtained first, which is a deep network model, and then the spatial features and spectral features of the target image are extracted through the image classification model;
[0009] After obtaining the spatial and spectral features of the target image, the spatial-spectral features are constructed based on the spatial and spectral features through the image classification model;
[0010] After obtaining the spatial spectrum features, the classification results of the spatial spectrum features can be obtained through the image classification model, and the classification results include the probability that the target image is in each category;
[0011] By determining from the classification results which category the target image has the highest probability of belonging to, the category to which the target image belongs can be finally determined.
[0012] From the above image classification method, it can be seen that the image classification model used in the image classification process can extract the spatial features and spectral features of the target image. The spatial-spectral features formed by the combination of the two can characterize the attribute information of the image in multiple dimensions. Therefore, classifying images based on the spatial-spectral features can effectively improve the accuracy of the image classification results and accurately identify objects in the image.
[0013] In a possible implementation manner of the first aspect, before extracting the spatial features of the target image and the spectral features of the target image through the image classification model, the method further includes:
[0014] Acquire spatial information of a target image and spectral information of the target image, wherein the spectral information of the target image is a one-dimensional vector formed by the target image, and the spatial information of the target image is a two-dimensional vector formed by the target image and a neighborhood image of the target image;
[0015] The spatial features and spectral features of the target image extracted by the image classification model include:
[0016] The spatial information and spectral information are respectively extracted through the image classification model to obtain the spatial features and spectral features of the target image.
[0017] In the above implementation, the spatial information and spectral information of the target image may be extracted first and used as input to the image classification model to further extract the spatial features and spectral features of the target image, thereby improving the flexibility and selectivity of the solution.
[0018] In a possible implementation of the first aspect, the image classification model includes a first branch network and a second branch network, the first branch network includes a first convolution layer and a first pooling layer, the second branch network includes a second convolution layer and a second pooling layer, and the spatial information and the spectral information are respectively extracted by the image classification model to obtain the spatial features of the target image and the spectral features of the target image, including:
[0019] The spectral information is convolved through the first convolution layer to obtain the first spectral feature of the target image;
[0020] Performing maximum pooling processing on the first spectral feature through the first pooling layer to obtain a second spectral feature of the target image;
[0021] The spatial information is convolved through the second convolution layer to obtain the first spatial feature of the target image;
[0022] The first spatial feature is subjected to maximum pooling processing through the second pooling layer to obtain the second spatial feature of the target image.
[0023] In the above embodiment, the image classification model includes two branch networks, and the first branch network and the second branch network both include a convolution layer and a pooling layer. Therefore, the spectral information of the target image can be convolved by the first convolution layer of the first branch network to obtain the first spectral feature, and then the first spectral feature is subjected to maximum pooling processing by the first pooling layer to obtain the second spectral feature. Similarly, the spatial information of the target image can also be convolved by the second convolution layer of the second branch network to obtain the first spatial feature, and then the first spatial feature is subjected to maximum pooling processing by the second pooling layer to obtain the second spatial feature, thereby improving the flexibility and selectivity of the solution.
[0024] In a possible implementation manner of the first aspect, the image classification model further includes a fully connected layer, and constructing the spatial-spectral features according to the spatial features and the spectral features through the image classification model includes:
[0025] The second spectral feature and the second spatial feature are respectively stretched by the image classification model to obtain a third spectral feature and a third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors;
[0026] The third spectral feature and the third spatial feature are fused through a fully connected layer to obtain the spatial spectrum feature.
[0027] In the above embodiment, the image classification model also includes a fully connected layer. After obtaining the second spectral feature and the second spatial feature output by the first pooling layer and the second pooling layer respectively, the two features can be stretched (i.e., element reorganization) to become one-dimensional vectors, i.e., the third spectral feature and the third spatial feature. Then, the third spectral feature and the third spatial feature are fused through the fully connected layer to obtain a single-scale spatial spectrum feature, which improves the flexibility and selectivity of the solution.
[0028] In a possible implementation of the first aspect, the image classification model includes a first branch network and a second branch network, the first branch network includes n first convolutional layers and n-1 first pooling layers, the second branch network includes n second convolutional layers and n-1 second pooling layers, wherein n is greater than or equal to 2, and the spatial information and the spectral information are respectively extracted by the image classification model to obtain the spatial features of the target image and the spectral features of the target image, including:
[0029] The spectral information is convolved through the first convolution layer to obtain the first spectral feature;
[0030] Performing maximum pooling processing on the 1st first spectral feature to the n-1th first spectral feature through the 1st first pooling layer to the n-1th first pooling layer, respectively, to obtain the 1st second spectral feature to the n-1th second spectral feature;
[0031] The first second spectral feature to the n-1 second spectral feature are respectively convolved through the second first convolution layer to the n-th first convolution layer to obtain the second first spectral feature to the n-th first spectral feature;
[0032] The spatial information is convolved through the first second convolution layer to obtain the first first spatial feature;
[0033] The first spatial feature to the n-1th spatial feature are subjected to maximum pooling processing respectively through the first second pooling layer to the n-1th second pooling layer to obtain the first second spatial feature to the n-1th spatial feature;
[0034] The 1st second spatial feature to the n-1th second spatial feature are respectively convolved through the 2nd second convolution layer to the nth second convolution layer to obtain the 2nd first spatial feature to the nth first spatial feature.
[0035] In the above embodiment, the image classification model includes two branch networks, and the first branch network includes n first convolutional layers and n-1 first pooling layers. Therefore, the spectral information of the target image can be used as the input of the first first convolutional layer, and the first first spectral feature is obtained after convolution. The first first spectral feature is then used as the input of the first first pooling layer, and the first second spectral feature is obtained after maximum pooling. The first second spectral feature is then used as the input of the second first convolutional layer, and the second first spectral feature is obtained after convolution. The second first spectral feature is then used as the input of the second first pooling layer, and so on. The first first convolutional layer to the nth first convolutional layer can output the first first spectral feature to the nth first spectral feature, respectively, and the first first pooling layer to the n-1th first pooling layer can output the first second spectral feature to the n-1th second spectral feature, respectively.
[0036] Similarly, by performing feature extraction on the spatial information of the target image through the second branch network, the 1st first spatial feature to the nth first spatial feature and the 1st second spatial feature to the n-1th second spatial feature can also be obtained, thereby improving the flexibility and selectivity of the solution.
[0037] In a possible implementation of the first aspect, the image classification model further includes n fully connected layers, and constructing the spatial-spectral features according to the spatial features and the spectral features through the image classification model includes:
[0038] Through the image classification model, the first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature and the nth first spatial feature are respectively stretched to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors;
[0039] Through n fully connected layers, n pairs of feature groups are fused respectively to obtain n sub-space spectrum features, among which a third spectrum feature and a third space feature with the same ranking constitute a feature group;
[0040] The n sub-spatial spectrum features are concatenated through the image classification model to obtain the spatial spectrum feature.
[0041] In the above embodiment, the image classification model also includes n fully connected layers. The first second spectral feature to the n-1th second spectral feature, and the nth first spectral feature can be stretched to obtain the first third spectral feature to the nth third spectral feature. Similarly, the first second spatial feature to the n-1th second spatial feature, and the nth first spatial feature can also be stretched to obtain the first third spatial feature to the nth third spatial feature. Then the first third spectral feature and the first third spatial feature are used as the input of the first fully connected layer, and the first sub-spatial spectrum feature is obtained after fusion. The second third spectral feature and the second third spatial feature are used as the input of the second fully connected layer, and the second sub-spatial spectrum feature is obtained after fusion, and so on, until n sub-spatial spectrum features are obtained, and then the n sub-spatial spectrum features are spliced to obtain a multi-scale spatial spectrum feature, which improves the flexibility and selectivity of the solution.
[0042] In a possible implementation manner of the first aspect, the image classification model further includes a classification layer, and obtaining a classification result of the spatial spectrum feature through the image classification model includes:
[0043] The spatial spectrum features are classified through the classification layer to obtain the classification results.
[0044] In the above implementation, the image classification model also includes a classification layer. After obtaining the spatial spectrum features, the spatial spectrum features can be split through the classification layer to obtain the classification results of the target image, thereby improving the flexibility and selectivity of the solution.
[0045] A second aspect of an embodiment of the present application provides a method for model training, the method comprising:
[0046] Acquire an image to be trained, where the image to be trained is an image generated based on a hyperspectral image;
[0047] Extracting spatial features of the image to be trained and spectral features of the image to be trained through the classification model to be trained;
[0048] Constructing spatial-spectral features according to spatial features and spectral features through the classification model to be trained;
[0049] Obtaining the classification results of the spatial spectrum features through the classification model to be trained;
[0050] According to the classification results and the true results, the classification model to be trained is trained through the target loss function to obtain the image classification model.
[0051] The image classification model obtained from the above model training method can extract the spatial features and spectral features of the target image. The spatial-spectral features formed by the combination of the two can characterize the attribute information of the image in multiple dimensions. Therefore, classifying the image based on the spatial-spectral features can effectively improve the accuracy of the image classification results and accurately identify the objects in the image.
[0052] In a possible implementation manner of the second aspect, before extracting the spatial features of the to-be-trained image and the spectral features of the to-be-trained image by the to-be-trained classification model, the method further includes:
[0053] Acquire spatial information of the image to be trained and spectral information of the image to be trained, wherein the spectral information of the image to be trained is a one-dimensional vector formed by the image to be trained, and the spatial information of the image to be trained is a two-dimensional vector formed by the image to be trained and a neighborhood image of the image to be trained;
[0054] The spatial features of the image to be trained and the spectral features of the image to be trained are extracted by the classification model to be trained, including:
[0055] The spatial information and the spectral information are respectively extracted by the classification model to be trained to obtain the spatial features of the image to be trained and the spectral features of the image to be trained.
[0056] In a possible implementation of the second aspect, the classification model to be trained includes a first branch network and a second branch network, the first branch network includes n first convolutional layers and n-1 first pooling layers, and the second branch network includes n second convolutional layers and n-1 second pooling layers, wherein n is greater than or equal to 2, and feature extraction is performed on spatial information and spectral information respectively through the classification model to be trained, and the spatial features of the image to be trained and the spectral features of the image to be trained are obtained, including:
[0057] The spectral information is convolved through the first convolution layer to obtain the first spectral feature;
[0058] Performing maximum pooling processing on the 1st first spectral feature to the n-1th first spectral feature through the 1st first pooling layer to the n-1th first pooling layer, respectively, to obtain the 1st second spectral feature to the n-1th second spectral feature;
[0059] The first second spectral feature to the n-1 second spectral feature are respectively convolved through the second first convolution layer to the n-th first convolution layer to obtain the second first spectral feature to the n-th first spectral feature;
[0060] The spatial information is convolved through the first second convolution layer to obtain the first first spatial feature;
[0061] The first spatial feature to the n-1th spatial feature are subjected to maximum pooling processing respectively through the first second pooling layer to the n-1th second pooling layer to obtain the first second spatial feature to the n-1th spatial feature;
[0062] The 1st second spatial feature to the n-1th second spatial feature are respectively convolved through the 2nd second convolution layer to the nth second convolution layer to obtain the 2nd first spatial feature to the nth first spatial feature.
[0063] In a possible implementation manner of the second aspect, the classification model to be trained further includes n fully connected layers, and constructing the spatial-spectral features according to the spatial features and the spectral features through the classification model to be trained includes:
[0064] The first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature and the nth first spatial feature are respectively stretched by the classification model to be trained to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors;
[0065] Through n fully connected layers, n pairs of feature groups are fused respectively to obtain n sub-space spectrum features, among which a third spectrum feature and a third space feature with the same ranking constitute a feature group;
[0066] The n sub-space spectrum features are concatenated through the classification model to be trained to obtain the space spectrum feature.
[0067] In a possible implementation manner of the second aspect, the classification model to be trained further includes a classification layer, and obtaining a classification result of the spatial spectrum feature through the classification model to be trained includes:
[0068] The spatial spectrum features are classified through the classification layer to obtain the classification results.
[0069] A third aspect of an embodiment of the present application provides an image classification device, including:
[0070] A first acquisition module is used to acquire a target image, where the target image is an image generated based on a hyperspectral image;
[0071] An extraction module, used for extracting the spatial features and spectral features of the target image through an image classification model;
[0072] A construction module, used for constructing spatial-spectral features according to spatial features and spectral features through an image classification model;
[0073] The second acquisition module is used to obtain the classification result of the spatial spectrum feature through the image classification model;
[0074] The determination module is used to determine the category to which the target image belongs according to the classification result.
[0075] In a possible implementation manner of the third aspect, the device further includes:
[0076] A third acquisition module is used to acquire spatial information of a target image and spectral information of the target image, wherein the spectral information of the target image is a one-dimensional vector formed by the target image, and the spatial information of the target image is a two-dimensional vector formed by the target image and a neighborhood image of the target image;
[0077] The extraction module is also used to extract features of the spatial information and the spectral information respectively through an image classification model to obtain the spatial features of the target image and the spectral features of the target image.
[0078] In a possible implementation of the third aspect, the image classification model includes a first branch network and a second branch network, the first branch network includes a first convolutional layer and a first pooling layer, the second branch network includes a second convolutional layer and a second pooling layer, and the extraction module is further used to:
[0079] The spectral information is convolved through the first convolution layer to obtain the first spectral feature of the target image;
[0080] Performing maximum pooling processing on the first spectral feature through the first pooling layer to obtain a second spectral feature of the target image;
[0081] The spatial information is convolved through the second convolution layer to obtain the first spatial feature of the target image;
[0082] The first spatial feature is subjected to maximum pooling processing through the second pooling layer to obtain the second spatial feature of the target image.
[0083] In a possible implementation manner of the third aspect, the image classification model further includes a fully connected layer, and the building module is further used for:
[0084] The second spectral feature and the second spatial feature are respectively stretched by the image classification model to obtain a third spectral feature and a third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors;
[0085] The third spectral feature and the third spatial feature are fused through a fully connected layer to obtain the spatial spectrum feature.
[0086] In a possible implementation of the third aspect, the image classification model includes a first branch network and a second branch network, the first branch network includes n first convolutional layers and n-1 first pooling layers, the second branch network includes n second convolutional layers and n-1 second pooling layers, wherein n is greater than or equal to 2, and the extraction module is further used to:
[0087] The spectral information is convolved through the first convolution layer to obtain the first spectral feature;
[0088] Performing maximum pooling processing on the 1st first spectral feature to the n-1th first spectral feature through the 1st first pooling layer to the n-1th first pooling layer, respectively, to obtain the 1st second spectral feature to the n-1th second spectral feature;
[0089] The first second spectral feature to the n-1 second spectral feature are respectively convolved through the second first convolution layer to the n-th first convolution layer to obtain the second first spectral feature to the n-th first spectral feature;
[0090] The spatial information is convolved through the first second convolution layer to obtain the first first spatial feature;
[0091] The first spatial feature to the n-1th spatial feature are subjected to maximum pooling processing respectively through the first second pooling layer to the n-1th second pooling layer to obtain the first second spatial feature to the n-1th spatial feature;
[0092] The 1st second spatial feature to the n-1th second spatial feature are respectively convolved through the 2nd second convolution layer to the nth second convolution layer to obtain the 2nd first spatial feature to the nth first spatial feature.
[0093] In a possible implementation of the third aspect, the image classification model further includes n fully connected layers, and the building module is further used for:
[0094] Through the image classification model, the first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature and the nth first spatial feature are respectively stretched to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors;
[0095] Through n fully connected layers, n pairs of feature groups are fused respectively to obtain n sub-space spectrum features, among which a third spectrum feature and a third space feature with the same ranking constitute a feature group;
[0096] The n sub-spatial spectrum features are concatenated through the image classification model to obtain the spatial spectrum feature.
[0097] In a possible implementation of the third aspect, the image classification model further includes a classification layer, and the second acquisition module is further used to perform classification processing on the spatial spectrum features through the classification layer to obtain a classification result.
[0098] A fourth aspect of an embodiment of the present application provides a model training device, the device comprising:
[0099] A first acquisition module is used to acquire an image to be trained, where the image to be trained is an image generated based on a hyperspectral image;
[0100] An extraction module, used for extracting the spatial features of the image to be trained and the spectral features of the image to be trained through the classification model to be trained;
[0101] A construction module, used for constructing spatial-spectral features according to spatial features and spectral features through a classification model to be trained;
[0102] The second acquisition module is used to obtain the classification result of the spatial spectrum feature through the classification model to be trained;
[0103] The training module is used to train the classification model to be trained according to the classification results and the actual results through the target loss function to obtain the image classification model.
[0104] In a possible implementation manner of the fourth aspect, the device further includes:
[0105] A third acquisition module is used to acquire spatial information of the image to be trained and spectral information of the image to be trained, wherein the spectral information of the image to be trained is a one-dimensional vector formed by the image to be trained, and the spatial information of the image to be trained is a two-dimensional vector formed by the image to be trained and a neighborhood image of the image to be trained;
[0106] The extraction module is also used to perform feature extraction on the spatial information and the spectral information respectively through the classification model to be trained, so as to obtain the spatial features of the image to be trained and the spectral features of the image to be trained.
[0107] In a possible implementation of the fourth aspect, the classification model to be trained includes a first branch network and a second branch network, the first branch network includes n first convolutional layers and n-1 first pooling layers, the second branch network includes n second convolutional layers and n-1 second pooling layers, wherein n is greater than or equal to 2, and the extraction module is further used to:
[0108] The spectral information is convolved through the first convolution layer to obtain the first spectral feature;
[0109] Performing maximum pooling processing on the 1st first spectral feature to the n-1th first spectral feature through the 1st first pooling layer to the n-1th first pooling layer, respectively, to obtain the 1st second spectral feature to the n-1th second spectral feature;
[0110] The first second spectral feature to the n-1 second spectral feature are respectively convolved through the second first convolution layer to the n-th first convolution layer to obtain the second first spectral feature to the n-th first spectral feature;
[0111] The spatial information is convolved through the first second convolution layer to obtain the first first spatial feature;
[0112] The first spatial feature to the n-1th spatial feature are subjected to maximum pooling processing respectively through the first second pooling layer to the n-1th second pooling layer to obtain the first second spatial feature to the n-1th spatial feature;
[0113] The 1st second spatial feature to the n-1th second spatial feature are respectively convolved through the 2nd second convolution layer to the nth second convolution layer to obtain the 2nd first spatial feature to the nth first spatial feature.
[0114] In a possible implementation manner of the fourth aspect, the classification model to be trained further includes n fully connected layers, and the construction module is further used for:
[0115] The first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature and the nth first spatial feature are respectively stretched by the classification model to be trained to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors;
[0116] Through n fully connected layers, n pairs of feature groups are fused respectively to obtain n sub-space spectrum features, among which a third spectrum feature and a third space feature with the same ranking constitute a feature group;
[0117] The n sub-space spectrum features are concatenated through the classification model to be trained to obtain the space spectrum feature.
[0118] In a possible implementation of the fourth aspect, the classification model to be trained further includes a classification layer, and the second acquisition module is further used to classify the spatial spectrum features through the classification layer to obtain a classification result.
[0119] A fifth aspect of an embodiment of the present application provides an image classification device, including:
[0120] One or more central processing units, memory, input and output interfaces, wired or wireless network interfaces, and power supplies;
[0121] The memory is either transient storage memory or persistent storage memory;
[0122] The central processing unit is configured to communicate with the memory, and execute instruction operations in the memory on the image classification device to perform the method in the first aspect and any possible implementation of the first aspect, and the second aspect and any possible implementation of the second aspect.
[0123] A sixth aspect of an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a computer, enable the computer to execute a method such as the first aspect and any possible implementation of the first aspect, and the second aspect and any possible implementation of the second aspect.
[0124] A seventh aspect of an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute a method in the first aspect and any possible implementation of the first aspect, or in the second aspect and any possible implementation of the second aspect.
[0125] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0126] The embodiment of the present application provides a method and related device for image classification, wherein the method first obtains a target image to be classified, the target image is an image generated based on a hyperspectral image, and then extracts the spatial features and spectral features of the target image through an image classification model, and then constructs a spatial-spectral feature based on the spatial features and spectral features through the image classification model, and obtains the classification result of the spatial-spectral feature through the image classification model, and finally determines the category to which the target image belongs based on the classification result. The image classification model used in the above process can extract the spatial features and spectral features of the target image, and the spatial-spectral features formed by the combination of the two can characterize the attribute information of the image in multiple dimensions. Therefore, classifying the image based on the spatial-spectral features can effectively improve the accuracy of the image classification results and accurately identify the objects in the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0127] Figure 1 A schematic diagram of an image classification model provided in an embodiment of the present application;
[0128] Figure 2 A schematic diagram of a flow chart of an image classification method provided in an embodiment of the present application;
[0129] Figure 3 Another schematic diagram of an image classification model provided in an embodiment of the present application;
[0130] Figure 4 Another flowchart of the image classification method provided in the embodiment of the present application;
[0131] Figure 5 A schematic diagram of feature extraction provided in an embodiment of the present application;
[0132] Figure 6 A flowchart of a model training method provided in an embodiment of the present application;
[0133] Figure 7 Another flowchart of the model training method provided in the embodiment of the present application;
[0134] Figure 8 A schematic diagram of the structure of an image classification device provided in an embodiment of the present application;
[0135] Fig. 9 A schematic diagram of the structure of a device for model training provided in an embodiment of the present application;
[0136] Fig.10 A structural schematic diagram of an image classification device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0137] The embodiment of the present application provides a method and related device for image classification. If a multispectral image needs to be classified, a trained image classification model can be obtained first. The image classification model consists of two branch networks, a fully connected layer and a classification layer. When classifying an image, the spectral features of the image can be extracted through the first branch network to characterize the distribution of spectral reflectance on the surface of the object in the image, and the spatial features of the image can be extracted through the second branch network to characterize the contour, surface texture, shadow and other features of the object in the image. Then, the spectral features and spatial features are fused through the fully connected layer to obtain the spatial spectral features of the image. Then, the spatial spectral features of the image are classified through the classification layer to obtain the classification result of the image, and finally the category to which the image belongs is determined. In the process of image classification, since the object analyzed by the image classification model is the spatial-spectral features of the image, the spatial-spectral features not only involve the spatial features of the image, but also take into account the spectral features of the image. Therefore, the spatial-spectral features can more comprehensively characterize the attribute information of the image, such as comprehensively reflecting the distribution of spectral reflectance on the surface of the object in the image, as well as the contour, surface texture and shadow of the object. Therefore, compared with the traditional method of only considering the spatial features, the spatial-spectral features in the present application can analyze the effective attribute information of the image from multiple aspects, thereby making the image classification model have a higher accuracy rate for the classification results of the image, and can accurately identify the objects in the image.
[0138] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0139] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0140] This application uses AI technology to classify images. Specifically, a monitoring scene is used as an example. In this scene, images can be collected by monitoring equipment. The images usually contain multiple types of objects, such as people, vehicles, and houses. In order to achieve real-time monitoring of a certain type of object, it is generally necessary to classify the objects contained in the image to correctly identify the category to which the object belongs.
[0141] In order to improve the accuracy of image classification results, the present application provides an image classification method, which is implemented by an image classification device, wherein the image classification device includes a monitoring device for acquiring multiple frames of images to be classified. It is worth noting that the images collected by the monitoring device in the present application are usually multispectral images, which refer to images with a spectral channel number greater than 3, for example, a hyperspectral image with a spectral channel number of 128, etc.
[0142] In addition, the image classification model used to classify multispectral images in the present application is a deep network model, which can extract features and classify multispectral images, and then identify the categories of objects in the images. Figure 1 A schematic diagram of an image classification model provided in an embodiment of the present application, such as Figure 1As shown, the image classification model includes a fully connected layer, a classification layer and two branch networks, wherein the first branch network includes a first convolution layer and a first pooling layer, and the second branch network also includes a second convolution layer and a second pooling layer. When the multispectral image is used as the input of the two branch networks of the image splitting model, the first branch network can be used to extract the spectral features of the multispectral image, the second branch network can be used to extract the spatial features of the multispectral image, the fully connected layer can construct the spatial spectral features based on the spectral features and the spatial features, and the classification layer can perform classification based on the spatial spectral features to obtain the classification results of the image.
[0143] Figure 2 A flowchart of the image classification method provided in the embodiment of the present application is shown in FIG. Figure 2 , this method is based on Figure 1 The image classification model shown performs image classification, including:
[0144] 201. Acquire a target image;
[0145] After the image classification device obtains the multispectral image through the monitoring device, it can generate a target image to be classified based on the multispectral image. It should be noted that in the process of classifying a certain frame of multispectral image, the image classification model can classify the entire multispectral image or part of the multispectral image. Since the multispectral image can be regarded as an image composed of multiple pixels, the process of classifying the multispectral image by the image classification model can be regarded as the process of classifying multiple parallel input pixels. Relative to each pixel, the operation performed by the image classification model is the same, so any pixel in the multispectral image can be used as the input of the image classification model, that is, the target image to be classified.
[0146] 202. Acquire spatial information of a target image and spectral information of the target image;
[0147] After acquiring the target image, the spatial information and spectral information of the target image can be further acquired, wherein the spectral information of the target image is a one-dimensional vector formed by the target image, and the spatial information of the target image is a two-dimensional vector formed by the target image and its neighborhood image.
[0148] Specifically, the target image is a pixel in the multispectral image, and a spectral curve of the pixel can be generated based on the pixel, and the spectral curve is used as the spectral information of the pixel, as the input of the first branch network. For example, a continuous multi-frame multispectral image within a certain period of time is obtained through a monitoring device (wherein a certain frame of multispectral image is a multispectral image N currently required to be classified), and each pixel in the multispectral image N is a target image, and pixel n (such as the nth pixel in the multispectral image N) is taken as an example for explanation. Multiple frames of continuous multispectral images form a three-dimensional image block, which has three dimensions, namely, a width dimension, a height dimension, and a spectral dimension. After determining the pixel n, the pixel corresponding to the pixel n (such as the nth pixel in each frame of the multispectral image) can be obtained from each frame of the multispectral image along the spectral dimension of the image block, that is, the pixel n and the multiple pixels corresponding to the pixel n are obtained. This part of the pixels can constitute the spectral curve of the pixel n, and the spectral curve is presented in the form of a one-dimensional vector, that is, the spectral information of the pixel n.
[0149] In addition, while obtaining the spectral information of the target image, the spatial information of the target image can also be obtained. Since the target image is a pixel point in the multispectral image, the spatial information of the pixel point can be generated based on the pixel point and the neighborhood information of the pixel point as the input of the second branch network. The above example is still used for explanation. Since the number of bands of the multispectral image is too large, the above image block can be first reduced in dimension by principal component analysis technology, and the pixel point n is determined from the first principal component obtained (which can be understood as a frame of image obtained by compressing the image block), and the neighborhood image of pixel point n is selected, such as r×r pixels centered on pixel point n, and the value of r can be set according to actual needs. At this time, pixel point n and the neighborhood image of pixel point n constitute the spatial information of pixel point n, and the spatial information is presented in the form of a two-dimensional vector.
[0150] After obtaining the spectral information and spatial information of the target image, the two pieces of information can be input into the two branch networks of the image classification model accordingly, thereby realizing feature extraction and image classification.
[0151] 203. Perform convolution processing on the spectral information through a first convolution layer to obtain a first spectral feature of the target image;
[0152] After obtaining the spectral information of the target image, it can be input into the first convolution layer of the first branch network of the image classification model. After the first convolution layer performs convolution processing on the spectral information, the first spectral feature of the target image can be obtained. Specifically, the spectral information is a one-dimensional vector. After being processed by the first convolution layer, a first spectral feature composed of m one-dimensional vectors (for example, a plane image composed of m one-dimensional vectors arranged side by side) can be obtained, where m is greater than or equal to 2.
[0153] 204. Perform maximum pooling processing on the first spectral feature through the first pooling layer to obtain a second spectral feature of the target image;
[0154] After obtaining the first spectral feature, the first spectral feature can be used as the input of the first pooling layer. After the first pooling layer performs maximum pooling on the first spectral feature, the second spectral feature can be obtained. Specifically, the first pooling layer can halve the length of each one-dimensional vector in the first spectral feature, thereby obtaining a compressed spectral feature, that is, the second spectral feature.
[0155] 205. Perform convolution processing on the spatial information through the second convolution layer to obtain a first spatial feature of the target image;
[0156] After obtaining the spatial information of the target image, it can be input into the second convolution layer of the second branch network of the image classification model. After the second convolution layer performs convolution processing on the spatial information, the first spatial feature of the target image can be obtained. Specifically, the spectral information is a two-dimensional vector. After being processed by the second convolution layer, a first spatial feature composed of k two-dimensional vectors (for example, an image block with a certain thickness composed of k two-dimensional vectors arranged side by side) can be obtained, where k is greater than or equal to 2.
[0157] It should be understood that the execution order of step 205 and step 203 is not specific, and they can be performed simultaneously or asynchronously, and no specific limitation is made here.
[0158] 206. Perform maximum pooling processing on the first spatial feature through a second pooling layer to obtain a second spatial feature of the target image;
[0159] After obtaining the first spatial feature, the first spatial feature can be used as the input of the second pooling layer. After the second pooling layer performs maximum pooling on the first spatial feature, the second spatial feature can be obtained. Specifically, the second pooling layer can halve the length and width of each two-dimensional vector in the first spatial feature, and the number of two-dimensional vectors of the first spatial feature (i.e., the thickness of the image block) remains unchanged, thereby obtaining a compressed spatial feature, i.e., the second spatial feature.
[0160] 207. Perform stretching processing on the second spectral feature and the second spatial feature respectively through the image classification model to obtain a third spectral feature and a third spatial feature;
[0161] After obtaining the second spectral feature and the second spatial feature, since the second spectral feature is a two-dimensional vector composed of m one-dimensional vectors, and the second spatial feature is a three-dimensional vector composed of k two-dimensional vectors, the second spectral feature and the second spatial feature can be stretched through the image classification model, so that the elements of the second spectral feature and the second spatial feature are rearranged to form a one-dimensional third spectral feature and a third spatial feature, that is, the third spectral feature and the third spatial feature are one-dimensional vectors.
[0162] 208. Fusing the third spectral feature and the third spatial feature through a fully connected layer to obtain a spatial spectrum feature;
[0163] After obtaining the one-dimensional third spectral feature and the third spatial feature, the third spectral feature and the third spatial feature can be used as the input of the fully connected layer, so that the fully connected layer fuses the third spectral feature and the third spatial feature to obtain the spatial spectral feature. At this point, the spatial spectral feature of the target image is obtained.
[0164] 209. Classify the spatial spectrum features through the classification layer to obtain a classification result;
[0165] After obtaining the spatial-spectral features of the target image, the spatial-spectral features can be classified through the classification layer of the image classification model to obtain a classification result, which includes the probability that the target image is in each category. For example, the classification result includes: the probability that the pixel point n belongs to category A is 67%, the probability that the pixel point n belongs to category B is 20%, and the probability that the pixel point n belongs to category C is 13%.
[0166] 210. According to the classification result, determine the category to which the target image belongs.
[0167] By determining from the classification results which category the target image has the highest probability of belonging to, the category to which the target image belongs can be finally determined. As in the above example, when the classification results show that the probability of pixel point n belonging to category A is the highest, it can be determined that the category to which pixel point n belongs is category A.
[0168] The image classification model used in this embodiment can extract the spatial features and spectral features of the target image. The spatial spectrum features formed by the combination of the two can characterize the attribute information of the image in multiple dimensions, so this embodiment can effectively obtain high-reliability attribute information of the image. Furthermore, the image is classified based on the spatial spectrum features, and the classification results have better effects in terms of spatial correlation and spectral correlation, which can effectively improve the accuracy of the image classification results and accurately identify the objects in the image.
[0169] The spatial-spectral features generated in the above embodiment are single-scale features. In the process of classifying multispectral images, the scenes reflected by the images usually contain objects of various scales, such as large-scale buildings and small-scale suitcases. However, single-scale spatial-spectral features generally cannot fully describe the scenes of multispectral images, which can easily cause information loss of small objects, thereby affecting the accuracy of image classification results.
[0170] Therefore, in order to further improve the accuracy of image classification results, this application also provides another image classification model: Figure 3 Another schematic diagram of the image classification model provided in the embodiment of the present application is as follows: Figure 3 As shown in FIG. 1 , the image classification model is a multiscale spectral-spatial unified network (MSSN), which includes two branch networks, n fully connected layers and a classification layer, wherein the first branch network includes n first convolutional layers and n-1 first pooling layers, and the n first convolutional layers and n-1 first pooling layers are alternately connected, and the second branch network includes n second convolutional layers and n-1 second pooling layers, and the n second convolutional layers and n-1 second pooling layers are alternately connected. It is worth noting that the input of the first fully connected layer is the output of the first first pooling layer and the output of the first second pooling layer, the input of the second fully connected layer is the output of the second first pooling layer and the output of the second second pooling layer, and so on, the input of the n-1th fully connected layer is the output of the n-1th first pooling layer and the output of the n-1th second pooling layer, and the input of the nth fully connected layer is the output of the nth first convolutional layer and the output of the nth second convolutional layer. In addition, the outputs of all fully connected layers are concatenated and used as the input of the classification layer for the final image classification.
[0171] Figure 4 For another flowchart of the image classification method provided in the embodiment of the present application, please refer to Figure 4 , this method is based on Figure 3 The image classification model shown performs image classification, including:
[0172] 401. Acquire a target image;
[0173] 402. Acquire spatial information of a target image and spectral information of the target image;
[0174] The specific description of step 401 to step 402 can refer to the relevant description of step 201 to step 202 in the above embodiment, which will not be repeated here.
[0175] 403. Perform convolution processing on the spectral information through a first convolution layer to obtain a first first spectral feature;
[0176] 404. Perform maximum pooling processing on the first first spectral feature to the n-1th first spectral feature through the first first pooling layer to the n-1th first pooling layer, respectively, to obtain the first second spectral feature to the n-1th second spectral feature;
[0177] 405. Perform convolution processing on the first second spectral feature to the (n-1)th second spectral feature through the second first convolution layer to the nth first convolution layer, respectively, to obtain the second first spectral feature to the nth first spectral feature;
[0178] After obtaining the spectral information of the target image, it can be used as the input of the first branch network of the image classification model. Figure 3 The process of extracting spectral features by the first branch network is introduced: the spectral information of the target image is input into the first first convolutional layer, and the first first convolutional layer convolves the spectral information to obtain the first first spectral feature, and then the first first spectral feature is input into the first first pooling layer for maximum pooling to obtain a second spectral feature, and then the first second spectral feature is input into the second first convolutional layer for convolution to obtain the second first spectral feature, and then the second first spectral feature is input into the second first pooling layer for maximum pooling to obtain the second second spectral feature, and so on, until the n-1th second spectral feature is input into the nth first convolutional layer for convolution to obtain the nth first spectral feature. At this point, the spectral feature extraction of the target image is completed.
[0179] Since the n first convolutional layers and n-1 first pooling layers in the first branch network are alternately connected, 2n-1 spectral features (including n first spectral features and n-1 second spectral features) can be generated, and each spectral feature has a different size. Figure 5 The size change between two adjacent spectral features is introduced. For the sake of convenience, n is taken as 3. Figure 5 A schematic diagram of feature extraction provided in an embodiment of the present application, such as Figure 5As shown, suppose the first branch network includes 3 first convolutional layers and 2 first pooling layers. When the spectral information (a one-dimensional vector) is input into the first first convolutional layer, a first spectral feature a consisting of m one-dimensional vectors can be obtained, where m is greater than or equal to 2. Then the first spectral feature a is input into the first first pooling layer, so that the length of each one-dimensional vector of the first spectral feature a is halved, and the second spectral feature x is obtained. Then the second spectral feature x is input into the second first convolutional layer, and the first spectral feature b consisting of p one-dimensional vectors can be obtained, where p is greater than m. Then the first spectral feature b is input into the second first pooling layer, so that the length of each one-dimensional vector of the first spectral feature b is halved, and the second spectral feature y is obtained. Finally, the second spectral feature y is input into the third first convolutional layer, and the first spectral feature c consisting of t one-dimensional vectors can be obtained, where t is greater than p.
[0180] It should be understood that Figure 5 In the example, each branch network is schematically illustrated with only three convolutional layers and two pooling layers, and does not limit the number of convolutional layers and pooling layers of each branch network in the embodiment of the present application. Figure 5 Only three fully connected layers are used for schematic illustration, and the number of fully connected layers in the embodiment of the present application is not limited.
[0181] 406. Perform convolution processing on the spatial information through the first second convolution layer to obtain a first first spatial feature;
[0182] 407. Perform maximum pooling processing on the first first spatial feature to the n-1th first spatial feature through the first second pooling layer to the n-1th second pooling layer, respectively, to obtain the first second spatial feature to the n-1th second spatial feature;
[0183] 408. Perform convolution processing on the first second spatial feature to the n-1th second spatial feature through the second second convolution layer to the nth second convolution layer, respectively, to obtain the second first spatial feature to the nth first spatial feature;
[0184] Similarly, after obtaining the spatial information of the target image, it can be used as the input of the second branch network of the image classification model. Figure 3The process of extracting spatial features by the first branch network is introduced as follows: the spatial information of the target image is input into the first second convolution layer, and the first second convolution layer performs convolution processing on the spatial information to obtain the first first spatial feature, and then the first first spatial feature is input into the first second pooling layer for maximum pooling processing to obtain a second spatial feature, and then the first second spatial feature is input into the second second convolution layer for convolution processing to obtain the second first spatial feature, and then the second first spatial feature is input into the second second pooling layer for maximum pooling processing to obtain the second second spatial feature, and so on, until the n-1 second spatial feature is input into the n-2 convolution layer for convolution processing to obtain the n-1 first spatial feature, and thus the spatial feature extraction of the target image is completed. Since the n second convolution layers and n-1 second pooling layers in the first branch network are alternately connected, n first spatial features and n-1 second spatial features can be generated.
[0185] Since the n second convolutional layers and n-1 second pooling layers in the second branch network are alternately connected, 2n-1 spatial features (including n first spatial features and n-1 second spatial features) can be generated, and each spatial feature has a different size. Figure 5 The size change between two adjacent spatial features is introduced, such as Figure 5 As shown, the second branch network includes 3 second convolutional layers and 2 second pooling layers. When the spatial information (a two-dimensional vector) is input into the first second convolutional layer, the first spatial feature d composed of k two-dimensional vectors (an image block with a certain thickness composed of k two-dimensional vectors arranged side by side) can be obtained, where k is greater than or equal to 2. Then the first spatial feature d is input into the first second pooling layer, so that the length and width of each two-dimensional vector of the first spatial feature d are halved, and the second spatial feature z is obtained. Then the second spatial feature z is input into the second second convolutional layer, and the first spatial feature e composed of q two-dimensional vectors can be obtained, where q is greater than k. Then the first spatial feature e is input into the second second pooling layer, so that the length and width of each two-dimensional vector of the first spatial feature e are halved, and the second spatial feature u is obtained. Finally, the second spatial feature u is input into the third second convolutional layer, and the first spatial feature f composed of s two-dimensional vectors can be obtained, where s is greater than q.
[0186] 409. Performing stretching processing on the first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature, and the nth first spatial feature respectively through the image classification model to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature;
[0187] After obtaining n first spectral features, n-1 second spectral features, n first spatial features and n-1 second spatial features, the image classification model can be used to stretch the 1st second spectral feature to the n-1th second spectral feature, and the nth first spectral feature, so that the elements of this part of the features are reorganized, and the 1st third spectral feature to the nth third spectral feature are obtained, and each third spectral feature is a one-dimensional vector. Similarly, the image classification model can also be used to stretch the 1st second spatial feature to the n-1th second spatial feature, and the nth first spatial feature, and the 1st third spatial feature to the nth third spatial feature are obtained, and each third spatial feature is a one-dimensional vector.
[0188] 410. Perform fusion processing on n pairs of feature groups through n fully connected layers to obtain n sub-space spectrum features, wherein a third spectrum feature and a third space feature with the same order constitute a feature group;
[0189] After obtaining n third spectral features and n third spatial features, the first third spectral feature and the first third spatial feature can be combined into a feature group, the second third spectral feature and the second third spatial feature can be combined into a feature group, and so on, until the nth third spectral feature and the nth third spatial feature are combined into a feature group, and finally n feature groups are obtained. Then the first feature group is input into the first fully connected layer, so that the first fully connected layer fuses the two features in the feature group to obtain the first sub-space spectrum feature, and at the same time, the second feature group is input into the second fully connected layer, so that the second fully connected layer fuses the two features in the feature group to obtain the second sub-space spectrum feature, and so on, until the nth feature group is input into the nth fully connected layer, so that the nth fully connected layer fuses the two features in the feature group to obtain the nth sub-space spectrum feature.
[0190] Specifically, the formula used for fusion processing in the fully connected layer is as follows:
[0191] y i =f[W i (spe i +spa i )+b i ]
[0192] In the formula, y i is the sub-space spectrum feature output by the i-th fully connected layer, f() is the activation function, W i is the preset weight, b i is the preset bias. When i is any value from 1 to n-1, spe i is the i-th second spectral feature, spa iis the i-th second spatial feature. When i is n, spe i is the i-th first spectral feature, spa i is the i-th first spatial feature.
[0193] 411. The n sub-space spectrum features are concatenated through an image classification model to obtain a space spectrum feature;
[0194] After obtaining n sub-spatial spectrum features, the n sub-spatial spectrum features can be spliced through the image classification model to obtain the spatial spectrum feature. Specifically, the formula used by the image classification model for splicing is as follows:
[0195] output = concat(y 1 ,y 2 ,y 3 ,...)
[0196] Wherein, output is the spatial spectral feature obtained by concatenating multiple sub-spatial spectral features. Since each sub-spatial spectral feature represents a different scale, the sub-spatial spectral features of multiple different scales can be concatenated to obtain a multi-scale spatial spectral feature.
[0197] 412. Classify the spatial spectrum features through the classification layer to obtain a classification result;
[0198] 413. Determine the category to which the target image belongs based on the classification result.
[0199] The specific description of step 412 to step 413 can refer to the relevant description of step 209 to step 210 in the above embodiment, which will not be repeated here.
[0200] The image classification model used in this embodiment can effectively extract the multi-scale spatial-spectral features of the multispectral image, and perform image classification based on the spatial-spectral features. The obtained classification results can effectively distinguish objects of different sizes, accurately interpret the complex scenes in the image, and accurately identify the object categories in the scene.
[0201] In order to further illustrate the image classification method provided in the embodiment of the present application, an application example is provided below for specific introduction. The application example includes:
[0202] The image classification device obtains a hyperspectral image for classification through a hyperspectral imager. The scene of the hyperspectral image contains objects of various scales, such as large-scale walls, cars, and people, as well as small-scale objects such as glasses and skin. 17 types of image samples are marked from the hyperspectral image, for example, the first type of image sample is a wall, the second type of image sample is a car, etc. Then, the trained MSSN is obtained, and the aforementioned hyperspectral image is input into the MSSN for image classification to obtain the corresponding classification result.
[0203] The classification results are quantitatively analyzed and the analysis results are shown in Table 1. Table 1 shows the scene interpretation accuracy of MSSN for hyperspectral images. In this application example, the performance of image classification using a support vector machine (SVM) is also used for comparison. It should be noted that the samples used in the training process of SVM and MSSN are the same, and the hyperspectral images used by SVM and MSSN for image classification are also the same.
[0204] Table 1 Analysis results
[0205]
[0206] As shown in Table 1, compared with SVM, the hyperspectral image scene interpretation based on MSSN network can obtain higher classification accuracy. For example, the classification accuracy of the first category sample is 100 under MSSN, and the classification accuracy is 98.96 under SVM, which means that after the first category sample (i.e., wall image sample) marked in the hyperspectral image is input into MSSN, the accuracy rate of correct identification is 100%, while after the first category sample is input into SVN, the accuracy rate of correct identification is 98.96%. Therefore, the classification accuracy of MSSN for each category is higher than that of SVM, especially for the three categories of samples 7, 8, and 9. MSSN has greatly improved the classification accuracy, which effectively demonstrates the performance of MSSN.
[0207] It is worth noting that in this application example, the performance of MSSN and SVM is measured mainly through the following three indicators:
[0208] (1) Overall accuracy OA, OA = number of correctly classified samples / total number of samples to be classified. For example, the number of samples in category 1 is 100 (such as 100 pixels belonging to the wall in the hyperspectral image). After classification, the number of samples correctly classified into category 1 among the 100 samples is the number of correctly classified samples.
[0209] (2) Average accuracy AA, AA = the sum of the correct rates of each category / number of categories.
[0210] (3) Kappa coefficient, Kappa = (OA-OO) / (1-AO), where AO is the theoretical accuracy, which is a preset accuracy value.
[0211] The above is a detailed introduction to the image classification method provided in the embodiment of the present application. The following is an explanation of the model training method provided in the embodiment of the present application. Figure 6 A flow chart of the model training method provided in the embodiment of the present application is shown in FIG. Figure 6, the method comprising:
[0212] 601. Obtain an image to be trained;
[0213] 602. Acquire spatial information of the image to be trained and spectral information of the image to be trained;
[0214] 603. Perform convolution processing on the spectral information through a first convolution layer to obtain a first spectral feature of the image to be trained;
[0215] 604. Perform maximum pooling processing on the first spectral feature through the first pooling layer to obtain a second spectral feature of the image to be trained;
[0216] 605. Perform convolution processing on the spatial information through the second convolution layer to obtain a first spatial feature of the image to be trained;
[0217] 606. Perform maximum pooling processing on the first spatial feature through a second pooling layer to obtain a second spatial feature of the image to be trained;
[0218] 607. Perform stretching processing on the second spectral feature and the second spatial feature respectively through the classification model to be trained to obtain a third spectral feature and a third spatial feature;
[0219] 608. Fusing the third spectral feature and the third spatial feature through a fully connected layer to obtain a spatial spectrum feature;
[0220] 609. Classify the spatial spectrum features through the classification layer to obtain a classification result;
[0221] For the specific description of steps 601 to 609, reference may be made to the relevant description of steps 201 to 209 in the above embodiment, which will not be repeated here.
[0222] 610. According to the classification results and the true results, the classification model to be trained is trained by using the target loss function to obtain an image classification model.
[0223] Since the image to be trained is a pixel point in the multispectral image, its classification result contains the probability that the image to be trained belongs to each category, but the classification result is not necessarily correct. Since the correct category to which the image to be trained belongs in the multispectral image has been marked in advance when the image to be trained is obtained, that is, the true result, the gap between the classification result of the image to be trained and the true result can be calculated by the target loss function. If the gap between the two exceeds the qualified range, the parameters of the classification model to be trained are adjusted, and additional training samples are used for retraining until the gap between the classification result of the image to be trained and the true result meets the requirements, then Figure 2 The image classification model in the corresponding embodiment.
[0224] The image classification model obtained in this embodiment can extract the spatial features and spectral features of the target image. The spatial-spectral features formed by the combination of the two can characterize the attribute information of the image in multiple dimensions. Therefore, classifying the image based on the spatial-spectral features can effectively improve the accuracy of the image classification results and accurately identify the objects in the image.
[0225] Figure 7 For another flow chart of the model training method provided in the embodiment of the present application, please refer to Figure 7 , the method comprising:
[0226] 701. Obtain an image to be trained;
[0227] 702. Acquire spatial information of the image to be trained and spectral information of the image to be trained;
[0228] 703. Perform convolution processing on the spectral information through a first convolution layer to obtain a first first spectral feature;
[0229] 704. Perform maximum pooling processing on the first first spectral feature to the n-1th first spectral feature through the first first pooling layer to the n-1th first pooling layer, respectively, to obtain the first second spectral feature to the n-1th second spectral feature;
[0230] 705. Perform convolution processing on the first second spectral feature to the (n-1)th second spectral feature through the second first convolution layer to the nth first convolution layer, respectively, to obtain the second first spectral feature to the nth first spectral feature;
[0231] 706. Perform convolution processing on the spatial information through the first second convolution layer to obtain a first first spatial feature;
[0232] 707. Perform maximum pooling processing on the first first spatial feature to the n-1th first spatial feature through the first second pooling layer to the n-1th second pooling layer, respectively, to obtain the first second spatial feature to the n-1th second spatial feature;
[0233] 708. Perform convolution processing on the first second spatial feature to the n-1th second spatial feature through the second second convolution layer to the nth second convolution layer, respectively, to obtain the second first spatial feature to the nth first spatial feature;
[0234] 709. Performing stretching processing on the first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature, and the nth first spatial feature respectively through the classification model to be trained to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature;
[0235] 710. Perform fusion processing on n pairs of feature groups through n fully connected layers to obtain n sub-space spectrum features, wherein a third spectrum feature and a third space feature with the same order constitute a feature group;
[0236] 711. Concatenate the n sub-space spectrum features through the classification model to be trained to obtain a space spectrum feature;
[0237] 712. Classify the spatial spectrum features through the classification layer to obtain a classification result;
[0238] For the detailed description of steps 701 to 712, reference may be made to the relevant description of steps 401 to 412 in the above embodiment, which will not be repeated here.
[0239] According to the classification results and the true results, the classification model to be trained is trained through the target loss function to obtain the image classification model.
[0240] Since the image to be trained is a pixel point in the multispectral image, its classification result contains the probability that the image to be trained belongs to each category, but the classification result is not necessarily correct. Since the correct category to which the image to be trained belongs in the multispectral image has been marked in advance when the image to be trained is obtained, that is, the true result, the gap between the classification result of the image to be trained and the true result can be calculated by the target loss function. If the gap between the two exceeds the qualified range, the parameters of the classification model to be trained are adjusted, and additional training samples are used for retraining until the gap between the classification result of the image to be trained and the true result meets the requirements, then Figure 4 The image classification model in the corresponding embodiment.
[0241] The image classification model obtained in this embodiment can extract the spatial features and spectral features of the target image. The spatial-spectral features formed by the combination of the two can characterize the attribute information of the image in multiple dimensions. Therefore, classifying the image based on the spatial-spectral features can effectively improve the accuracy of the image classification results and accurately identify the objects in the image.
[0242] The above is a detailed introduction to the model training method provided in the embodiment of the present application. The image classification device and model training device provided in the embodiment of the present application will be described below respectively. Figure 8 A schematic diagram of the structure of an image classification device provided in an embodiment of the present application, such as Figure 8 As shown, the device comprises:
[0243] A first acquisition module 801 is used to acquire a target image, where the target image is an image generated based on a hyperspectral image;
[0244] An extraction module 802 is used to extract the spatial features and spectral features of the target image through an image classification model;
[0245] A construction module 803 is used to construct a spatial-spectral feature according to the spatial feature and the spectral feature through an image classification model;
[0246] The second acquisition module 804 is used to obtain the classification result of the spatial spectrum feature through the image classification model;
[0247] The determination module 805 is used to determine the category to which the target image belongs according to the classification result.
[0248] Optionally, the device further comprises:
[0249] A third acquisition module is used to acquire spatial information of a target image and spectral information of the target image, wherein the spectral information of the target image is a one-dimensional vector formed by the target image, and the spatial information of the target image is a two-dimensional vector formed by the target image and a neighborhood image of the target image;
[0250] The extraction module 802 is further used to perform feature extraction on the spatial information and the spectral information respectively through an image classification model to obtain the spatial features of the target image and the spectral features of the target image.
[0251] Optionally, the image classification model includes a first branch network and a second branch network, the first branch network includes a first convolution layer and a first pooling layer, the second branch network includes a second convolution layer and a second pooling layer, and the extraction module 802 is further used to:
[0252] The spectral information is convolved through the first convolution layer to obtain the first spectral feature of the target image;
[0253] Performing maximum pooling processing on the first spectral feature through the first pooling layer to obtain a second spectral feature of the target image;
[0254] The spatial information is convolved through the second convolution layer to obtain the first spatial feature of the target image;
[0255] The first spatial feature is subjected to maximum pooling processing through the second pooling layer to obtain the second spatial feature of the target image.
[0256] Optionally, the image classification model further includes a fully connected layer, and the construction module 803 is further used to:
[0257] The second spectral feature and the second spatial feature are respectively stretched by the image classification model to obtain a third spectral feature and a third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors;
[0258] The third spectral feature and the third spatial feature are fused through a fully connected layer to obtain the spatial spectrum feature.
[0259] Optionally, the image classification model includes a first branch network and a second branch network, the first branch network includes n first convolutional layers and n-1 first pooling layers, the second branch network includes n second convolutional layers and n-1 second pooling layers, wherein n is greater than or equal to 2, and the extraction module 802 is further used to:
[0260] The spectral information is convolved through the first convolution layer to obtain the first spectral feature;
[0261] Performing maximum pooling processing on the 1st first spectral feature to the n-1th first spectral feature through the 1st first pooling layer to the n-1th first pooling layer, respectively, to obtain the 1st second spectral feature to the n-1th second spectral feature;
[0262] The first second spectral feature to the n-1 second spectral feature are respectively convolved through the second first convolution layer to the n-th first convolution layer to obtain the second first spectral feature to the n-th first spectral feature;
[0263] The spatial information is convolved through the first second convolution layer to obtain the first first spatial feature;
[0264] The first spatial feature to the n-1th spatial feature are subjected to maximum pooling processing respectively through the first second pooling layer to the n-1th second pooling layer to obtain the first second spatial feature to the n-1th spatial feature;
[0265] The 1st second spatial feature to the n-1th second spatial feature are respectively convolved through the 2nd second convolution layer to the nth second convolution layer to obtain the 2nd first spatial feature to the nth first spatial feature.
[0266] Optionally, the image classification model further includes n fully connected layers, and the construction module 803 is further used for:
[0267] Through the image classification model, the first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature and the nth first spatial feature are respectively stretched to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors;
[0268] Through n fully connected layers, n pairs of feature groups are fused respectively to obtain n sub-space spectrum features, among which a third spectrum feature and a third space feature with the same ranking constitute a feature group;
[0269] The n sub-spatial spectrum features are concatenated through the image classification model to obtain the spatial spectrum feature.
[0270] Optionally, the image classification model further includes a classification layer, and the second acquisition module 804 is further configured to perform classification processing on the spatial spectrum features through the classification layer to obtain a classification result.
[0271] Fig. 9 A schematic diagram of the structure of the device for model training provided in the embodiment of the present application, such as Fig. 9 As shown, the device comprises:
[0272] A first acquisition module 901 is used to acquire an image to be trained, where the image to be trained is an image generated based on a hyperspectral image;
[0273] An extraction module 902 is used to extract the spatial features of the image to be trained and the spectral features of the image to be trained through the classification model to be trained;
[0274] A construction module 903 is used to construct a spatial-spectral feature according to the spatial feature and the spectral feature through the classification model to be trained;
[0275] The second acquisition module 904 is used to obtain the classification result of the spatial spectrum feature through the classification model to be trained;
[0276] The training module 905 is used to train the classification model to be trained according to the classification results and the true results through the target loss function to obtain the image classification model.
[0277] Optionally, the device further comprises:
[0278] A third acquisition module is used to acquire spatial information of the image to be trained and spectral information of the image to be trained, wherein the spectral information of the image to be trained is a one-dimensional vector formed by the image to be trained, and the spatial information of the image to be trained is a two-dimensional vector formed by the image to be trained and a neighborhood image of the image to be trained;
[0279] The extraction module 902 is further used to perform feature extraction on the spatial information and the spectral information respectively through the classification model to be trained, so as to obtain the spatial features of the image to be trained and the spectral features of the image to be trained.
[0280] Optionally, the classification model to be trained includes a first branch network and a second branch network, the first branch network includes n first convolutional layers and n-1 first pooling layers, the second branch network includes n second convolutional layers and n-1 second pooling layers, wherein n is greater than or equal to 2, and the extraction module 902 is further used to:
[0281] The spectral information is convolved through the first convolution layer to obtain the first spectral feature;
[0282] Performing maximum pooling processing on the 1st first spectral feature to the n-1th first spectral feature through the 1st first pooling layer to the n-1th first pooling layer, respectively, to obtain the 1st second spectral feature to the n-1th second spectral feature;
[0283] The first second spectral feature to the n-1 second spectral feature are respectively convolved through the second first convolution layer to the n-th first convolution layer to obtain the second first spectral feature to the n-th first spectral feature;
[0284] The spatial information is convolved through the first second convolution layer to obtain the first first spatial feature;
[0285] The first spatial feature to the n-1th spatial feature are subjected to maximum pooling processing respectively through the first second pooling layer to the n-1th second pooling layer to obtain the first second spatial feature to the n-1th spatial feature;
[0286] The 1st second spatial feature to the n-1th second spatial feature are respectively convolved through the 2nd second convolution layer to the nth second convolution layer to obtain the 2nd first spatial feature to the nth first spatial feature.
[0287] Optionally, the classification model to be trained further includes n fully connected layers, and the construction module 903 is further used for:
[0288] The first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature and the nth first spatial feature are respectively stretched by the classification model to be trained to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors;
[0289] Through n fully connected layers, n pairs of feature groups are fused respectively to obtain n sub-space spectrum features, among which a third spectrum feature and a third space feature with the same ranking constitute a feature group;
[0290] The n sub-space spectrum features are concatenated through the classification model to be trained to obtain the space spectrum feature.
[0291] Optionally, the classification model to be trained further includes a classification layer, and the second acquisition module 904 is further configured to perform classification processing on the spatial spectrum features through the classification layer to obtain a classification result.
[0292] It should be noted that the information interaction, execution process, etc. between the modules / units of the above-mentioned device are based on the same concept as the method embodiment of the present application, and the technical effects they bring are the same as those of the method embodiment of the present application. For specific contents, please refer to the description in the method embodiment shown above in the present application, and will not be repeated here.
[0293] Fig.10 A structural diagram of an image classification device provided in an embodiment of the present application, see Fig.10 , the device includes: one or more central processors 1001, a memory 1002, an input and output interface 1003, a wired or wireless network interface 1004, and a power supply 1005;
[0294] The memory 1002 is a temporary storage memory or a permanent storage memory;
[0295] The CPU 1001 is configured to communicate with the memory 1002 and execute instructions in the memory 1002 on the image classification device to perform Figure 2 or Figure 4 The operations performed by the image classification device are not described in detail here.
[0296] The present application also relates to a computer-readable storage medium, including instructions, which, when executed on a computer, cause the computer to execute Figure 2 or Figure 4 The corresponding method.
[0297] The present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute Figure 2 or Figure 4 The corresponding method.
[0298] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0299] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0300] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0301] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0302] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
Claims
1. A method for image classification, characterized in that: The method comprises: Acquire a target image, where the target image is an image generated based on a multispectral image; Acquire spatial information of the target image and spectral information of the target image, wherein the spectral information of the target image is a one-dimensional vector formed by the target image, and the spatial information of the target image is a two-dimensional vector formed by the target image and a neighborhood image of the target image; Extracting features of the spatial information and the spectral information respectively through an image classification model to obtain spatial features of the target image and spectral features of the target image; Constructing a spatial-spectral feature according to the spatial feature and the spectral feature by using the image classification model; Obtaining a classification result of the spatial spectrum feature through the image classification model; Determining the category to which the target image belongs according to the classification result; The image classification model includes a first branch network and a second branch network, the first branch network includes a first convolution layer and a first pooling layer, the second branch network includes a second convolution layer and a second pooling layer, and the spatial information and the spectral information are respectively extracted by the image classification model to obtain the spatial features of the target image and the spectral features of the target image, including: Performing convolution processing on the spectral information through the first convolution layer to obtain a first spectral feature of the target image; Performing maximum pooling processing on the first spectral feature through the first pooling layer to obtain a second spectral feature of the target image; Performing convolution processing on the spatial information through the second convolution layer to obtain a first spatial feature of the target image; Performing maximum pooling processing on the first spatial feature through the second pooling layer to obtain a second spatial feature of the target image; The image classification model further includes a fully connected layer, and constructing a spatial-spectral feature according to the spatial feature and the spectral feature through the image classification model includes: The second spectral feature and the second spatial feature are respectively stretched by the image classification model to obtain a third spectral feature and a third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors; The third spectral feature and the third spatial feature are fused through the fully connected layer to obtain a spatial spectrum feature.
2. The method according to claim 1, characterized in that: The image classification model includes a first branch network and a second branch network, the first branch network includes n first convolutional layers and n-1 first pooling layers, the n first convolutional layers and the n-1 first pooling layers are cross-connected, the second branch network includes n second convolutional layers and n-1 second pooling layers, the n second convolutional layers and the n-1 second pooling layers are cross-connected, wherein n is greater than or equal to 2, and the spatial information and the spectral information are respectively feature extracted by the image classification model, and the spatial features of the target image and the spectral features of the target image are obtained, including: Performing convolution processing on the spectral information through the first first convolution layer to obtain a first first spectral feature; Performing maximum pooling processing on the first spectral feature to the n-1th first spectral feature through the first pooling layer to the n-1th first pooling layer, respectively, to obtain the first second spectral feature to the n-1th second spectral feature; Performing convolution processing on the first second spectral feature to the (n-1)th second spectral feature through the second first convolution layer to the nth first convolution layer, respectively, to obtain the second first spectral feature to the nth first spectral feature; Performing convolution processing on the spatial information through the first second convolution layer to obtain a first first spatial feature; Performing maximum pooling processing on the first first spatial feature to the n-1th first spatial feature through the first second pooling layer to the n-1th second pooling layer, respectively, to obtain the first second spatial feature to the n-1th second spatial feature; The first second spatial feature to the n-1th second spatial feature are respectively convolved through the second second convolution layer to the nth second convolution layer to obtain the second first spatial feature to the nth first spatial feature.
3. The method according to claim 2, characterized in that The image classification model further includes n fully connected layers, and constructing spatial-spectral features according to the spatial features and the spectral features through the image classification model includes: The first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature and the nth first spatial feature are respectively stretched by the image classification model to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors; By using the n fully connected layers, the n pairs of feature groups are fused respectively to obtain n sub-space spectrum features, wherein one of the third spectral features and one of the third spatial features with the same order constitute one of the feature groups; The n sub-spatial spectrum features are spliced together through the image classification model to obtain a spatial spectrum feature.
4. The method according to any one of claims 1 to 3, characterized in that: The image classification model further includes a classification layer, and the classification result of the spatial spectrum feature obtained by the image classification model includes: The spatial spectrum features are classified by the classification layer to obtain a classification result.
5. A model training method, characterized in that: include: Acquire an image to be trained, where the image to be trained is an image generated based on a hyperspectral image; Acquire spatial information of the image to be trained and spectral information of the image to be trained, wherein the spectral information of the image to be trained is a one-dimensional vector formed by the image to be trained, and the spatial information of the image to be trained is a two-dimensional vector formed by the image to be trained and a neighborhood image of the image to be trained; Extracting features of the spatial information and the spectral information respectively through the classification model to be trained, so as to obtain the spatial features of the image to be trained and the spectral features of the image to be trained; Constructing a spatial-spectral feature according to the spatial feature and the spectral feature by using the classification model to be trained; Obtaining the classification result of the spatial spectrum feature through the classification model to be trained; According to the classification result and the true result, the classification model to be trained is trained by using a target loss function to obtain an image classification model; The classification model to be trained includes a first branch network and a second branch network, the first branch network includes a first convolution layer and a first pooling layer, the second branch network includes a second convolution layer and a second pooling layer, and the spatial information and the spectral information are respectively extracted by the classification model to be trained to obtain the spatial features of the image to be trained and the spectral features of the image to be trained, including: Performing convolution processing on the spectral information through the first convolution layer to obtain a first spectral feature of the image to be trained; Performing maximum pooling processing on the first spectral feature through the first pooling layer to obtain a second spectral feature of the image to be trained; Performing convolution processing on the spatial information through the second convolution layer to obtain a first spatial feature of the image to be trained; The second pooling layer performs maximum pooling processing on the first spatial feature to obtain the second spatial feature of the image to be trained The classification model to be trained also includes a fully connected layer, and constructing a spatial-spectral feature according to the spatial feature and the spectral feature through the classification model to be trained includes: The second spectral feature and the second spatial feature are respectively stretched by the classification model to be trained to obtain a third spectral feature and a third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors; The third spectral feature and the third spatial feature are fused through the fully connected layer to obtain a spatial spectrum feature.
6. The method according to claim 5, characterized in that The classification model to be trained includes a first branch network and a second branch network, the first branch network includes n first convolutional layers and n-1 first pooling layers, the n first convolutional layers and the n-1 first pooling layers are cross-connected, the second branch network includes n second convolutional layers and n-1 second pooling layers, the n second convolutional layers and the n-1 second pooling layers are cross-connected, wherein n is greater than or equal to 2, and the spatial information and the spectral information are respectively feature extracted by the classification model to be trained, and the spatial features of the image to be trained and the spectral features of the image to be trained are obtained, including: Performing convolution processing on the spectral information through the first first convolution layer to obtain a first first spectral feature; Performing maximum pooling processing on the first spectral feature to the n-1th first spectral feature through the first pooling layer to the n-1th first pooling layer, respectively, to obtain the first second spectral feature to the n-1th second spectral feature; Performing convolution processing on the first second spectral feature to the (n-1)th second spectral feature through the second first convolution layer to the nth first convolution layer, respectively, to obtain the second first spectral feature to the nth first spectral feature; Performing convolution processing on the spatial information through the first second convolution layer to obtain a first first spatial feature; Performing maximum pooling processing on the first first spatial feature to the n-1th first spatial feature through the first second pooling layer to the n-1th second pooling layer, respectively, to obtain the first second spatial feature to the n-1th second spatial feature; The first second spatial feature to the n-1th second spatial feature are respectively convolved through the second second convolution layer to the nth second convolution layer to obtain the second first spatial feature to the nth first spatial feature.
7. The method according to claim 6, characterized in that The classification model to be trained also includes n fully connected layers, and constructing the spatial-spectral features according to the spatial features and the spectral features through the classification model to be trained includes: The first second spectral feature to the n-1th second spectral feature, the first second spatial feature to the n-1th second spatial feature, the nth first spectral feature and the nth first spatial feature are respectively stretched by the classification model to be trained to obtain the first third spectral feature to the nth third spectral feature, and the first third spatial feature to the nth third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors; By using the n fully connected layers, the n pairs of feature groups are fused respectively to obtain n sub-space spectrum features, wherein one of the third spectral features and one of the third spatial features with the same order constitute one of the feature groups; The n sub-spatial spectrum features are concatenated through the classification model to be trained to obtain a spatial spectrum feature.
8. The method according to any one of claims 5 to 7, characterized in that: The classification model to be trained also includes a classification layer, and the classification result of the spatial spectrum feature obtained by the classification model to be trained includes: The spatial spectrum features are classified by the classification layer to obtain a classification result.
9. An image classification device, characterized in that: include: A first acquisition module, used to acquire a target image, wherein the target image is an image generated based on a hyperspectral image; A third acquisition module is used to acquire the spatial information of the target image and the spectral information of the target image, wherein the spectral information of the target image is a one-dimensional vector formed by the target image, and the spatial information of the target image is a two-dimensional vector formed by the target image and a neighborhood image of the target image; An extraction module, used for performing feature extraction on the spatial information and the spectral information respectively through an image classification model to obtain the spatial features of the target image and the spectral features of the target image; A construction module, used for constructing a spatial-spectral feature according to the spatial feature and the spectral feature through the image classification model; A second acquisition module, used for acquiring the classification result of the spatial spectrum feature through the image classification model; A determination module, used to determine the category to which the target image belongs according to the classification result; The image classification model includes a first branch network and a second branch network, the first branch network includes a first convolution layer and a first pooling layer, the second branch network includes a second convolution layer and a second pooling layer, and the extraction module is used to: Performing convolution processing on the spectral information through the first convolution layer to obtain a first spectral feature of the target image; Performing maximum pooling processing on the first spectral feature through the first pooling layer to obtain a second spectral feature of the target image; Performing convolution processing on the spatial information through the second convolution layer to obtain a first spatial feature of the target image; Performing maximum pooling processing on the first spatial feature through the second pooling layer to obtain a second spatial feature of the target image; The image classification model further includes a fully connected layer, and the building block is used to: The second spectral feature and the second spatial feature are respectively stretched by the image classification model to obtain a third spectral feature and a third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors; The third spectral feature and the third spatial feature are fused through the fully connected layer to obtain a spatial spectrum feature.
10. A device for model training, characterized in that: include: A first acquisition module is used to acquire an image to be trained, where the image to be trained is an image generated based on a hyperspectral image; a third acquisition module, configured to acquire spatial information of the image to be trained and spectral information of the image to be trained, wherein the spectral information of the image to be trained is a one-dimensional vector formed by the image to be trained, and the spatial information of the image to be trained is a two-dimensional vector formed by the image to be trained and a neighborhood image of the image to be trained; An extraction module, used to perform feature extraction on the spatial information and the spectral information respectively through a classification model to be trained, so as to obtain the spatial features of the image to be trained and the spectral features of the image to be trained; A construction module, used for constructing a spatial-spectral feature according to the spatial feature and the spectral feature through the classification model to be trained; A second acquisition module, used for acquiring the classification result of the spatial spectrum feature through the classification model to be trained; A training module, used to train the classification model to be trained through a target loss function according to the classification result and the true result, so as to obtain an image classification model; The classification model to be trained includes a first branch network and a second branch network, the first branch network includes a first convolution layer and a first pooling layer, the second branch network includes a second convolution layer and a second pooling layer, and the extraction module is used to: Performing convolution processing on the spectral information through the first convolution layer to obtain a first spectral feature of the image to be trained; Performing maximum pooling processing on the first spectral feature through the first pooling layer to obtain a second spectral feature of the image to be trained; Performing convolution processing on the spatial information through the second convolution layer to obtain a first spatial feature of the image to be trained; The second pooling layer performs maximum pooling processing on the first spatial feature to obtain the second spatial feature of the image to be trained The classification model to be trained also includes a fully connected layer, and the building module is used to: The second spectral feature and the second spatial feature are respectively stretched by the classification model to be trained to obtain a third spectral feature and a third spatial feature, wherein the third spectral feature and the third spatial feature are one-dimensional vectors; The third spectral feature and the third spatial feature are fused through the fully connected layer to obtain a spatial spectrum feature.
11. An image classification device, characterized in that: include: One or more central processing units, memory, input and output interfaces, wired or wireless network interfaces, and power supplies; The memory is a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory, and execute instruction operations in the memory on the image classification device to perform the method according to any one of claims 1 to 8.
12. A computer-readable storage medium comprising instructions, which, when executed on a computer, enable the computer to perform the method according to any one of claims 1 to 8.
13. A computer program product comprising instructions, which, when executed on a computer, causes the computer to perform the method according to any one of claims 1 to 8.
