Soil image soil type identification method based on multi-scale feature fusion
By using the MAFL-SoilMobileNet model with multi-scale feature fusion and multi-scale expansion attention mechanism in soil image recognition, the problem of sample category imbalance and insignificant differences between classes in soil species recognition is solved, and efficient soil species recognition is achieved.
Patent Information
- Application Number
- CN202411530609.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-28
AI Technical Summary
The existing machine learning recognition methods have problems such as imbalance in sample categories and insignificant differences between classes in soil species recognition, resulting in low recognition accuracy.
The soil image recognition method based on multi-scale feature fusion is adopted, and the MAFL-SoilMobileNet model is constructed, combining the multi-scale feature fusion module and the multi-scale expansion attention module to improve the learning ability of the identification model for discriminant feature information.
It effectively improves the accuracy of soil species identification, enhances attention to a few soil category samples, and does not increase the number of parameters, and is efficient.
Smart Images

Figure CN119540716A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a soil type recognition method, and in particular to a soil type recognition method of soil images based on multi-scale feature fusion. Background Art
[0002] The identification of soil types is currently generally achieved through machine learning, that is, by acquiring soil images and then building a corresponding machine learning recognition model for identification. This method is highly efficient.
[0003] However, in the existing machine learning recognition methods, the machine learning model is trained through sample images, and then the image to be tested is input into the machine learning model for recognition. In practice, there is an imbalance in the category samples of the soil sample images, which makes the machine learning model pay insufficient attention to the samples of the minority categories, resulting in low recognition accuracy. On the other hand, the inter-class differences of the sample images are not obvious, that is, the difference between two different types of soil is small, which reduces the accuracy of the machine learning model in the recognition process.
[0004] Therefore, in order to solve the above technical problems, it is urgent to propose a new technical means. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a soil type recognition method for soil images based on multi-scale feature fusion, which can extract the key features of soil type recognition in soil images, enhance the discrimination of soil type recognition features, and improve the dynamic attention to a few soil category samples and improve the recognition model's ability to learn discriminative feature information, thereby effectively ensuring the final soil type recognition accuracy without increasing the amount of parameters and with high efficiency.
[0006] The present invention provides a soil image soil type identification method based on multi-scale feature fusion, comprising the following steps:
[0007] S1. Obtaining a sample soil image and preprocessing the sample soil image;
[0008] S2. Build a MAFL-SoilMobileNet model based on multi-scale feature fusion and multi-scale dilation attention mechanism, and input sample images into the MAFL-SoilMobileNet model for training;
[0009] S3. Obtain the soil image to be identified, and input the soil image to be identified into the trained MAFL-SoilMobileNet model after preprocessing to obtain the soil type identification result.
[0010] Further, in step S2, the MAFL-SoilMobileNet model specifically includes a first convolution module, a multi-scale feature fusion module, a multi-scale dilated attention module, a second convolution module, a pooling module, and a fully connected module;
[0011] The input end of the first convolution module inputs the preprocessed soil image, the first convolution module is used to extract the primary features of the soil image and output them to the multi-scale feature fusion module, the multi-scale feature fusion module extracts the primary features again and performs fusion processing; the output end of the multi-scale feature fusion module is connected to the multi-scale dilated attention module, the output end of the multi-scale dilated attention module is connected to the input end of the second convolution module, the output end of the second convolution module is connected to the input end of the pooling module, the output end of the pooling module is connected to the input end of the fully connected module, and the fully connected module outputs the soil type.
[0012] Furthermore, the multi-scale feature fusion module includes 8 Bottleneck modules, and the 8 Bottleneck modules are connected in sequence, the Bottleneck module whose input end is connected to the output end of the first convolution module is numbered 1, and the Bottleneck module whose output end is connected to the input end of the multi-scale dilated attention module is numbered 8, wherein the output channel numbers of the Bottleneck modules numbered 1, 2, 4 and 8 are 16, 24, 40 and 48 respectively; wherein:
[0013] The output information of the Bottleneck modules numbered 1, 2, 4 and 8 are output results I, output result II, output result III and output result IV respectively. Output result IV and output result III are added to form output result V, output result V and output result II are added to form output result VI, output result VI is added to output result I to form output result VII, output result VII, output result VI, output result V and I are added to obtain the final output result and output it to the multi-scale dilated attention module.
[0014] Furthermore, the multi-scale attention module includes three dilated convolutional layers and three SE attention modules. Each dilated convolutional layer inputs the final output result of the multi-scale feature fusion module. Each dilated convolutional layer corresponds to an SE attention module. The output results of the three SE attention modules are added together and multiplied by the final output result of the multi-scale feature fusion module to form the output result of the multi-scale attention module. The dilation rates of the three dilated convolutional layers are 1, 2 and 4, respectively.
[0015] Furthermore, the MAFL-SoilMobileNet model uses the following loss function for training and parameter update:
[0016] L ASBCC=L ASB +λL CC
[0017] Where: L ASBCC is the training loss function of the MAFL-SoilMobileNet model, L ASB is the adaptive category loss, L CC is the cross-channel loss;
[0018] L CC =L DIS +μL DIV ;
[0019] Where: L DIV is the diversity loss, L DIS is the discriminative loss of each soil category, and λ and μ are hyperparameters.
[0020] Furthermore, the adaptive category loss L is determined by the following method: ASB :
[0021]
[0022] Where: ω is the adaptive factor, M represents the number of samples, y i,j Represents sample x i The true label belonging to the jth soil category, p i,j Represents sample x i The predicted probability of belonging to the jth class of the true label, C is the number of soil categories; where:
[0023]
[0024] Furthermore, the adaptive factor ω is determined by the following method:
[0025] Construct the one-hot encoding matrix Y of the soil image dataset:
[0026]
[0027] The soil image dataset is input into the MAFL-SoilMobileNet model, and the prediction probability matrix generated is P:
[0028]
[0029] Construct the probability matrix E of sample prediction error:
[0030] E=Y—Y⊙P; where ⊙ represents the Hadamard product;
[0031] Determine the Frobenius norm of the matrix E and use it as the adaptation factor ω:
[0032] Among them, E i,j Represents the element in the i-th row and j-th column of the probability matrix E.
[0033] Furthermore, the discriminative loss L of each soil type was determined by the following method: DIS :
[0034] Each soil category is assigned 3 characteristic channels, and the number of characteristic channels for all soil categories is 3C;
[0035] The feature channel group of the i-th category is composed of (i×3-2, i×3) feature channels, and the feature channel group of the i-th category is converted into a tensor F i :
[0036]
[0037] in: H and W represent the height and width of the image, respectively;
[0038] For feature group F i The maximum cross-channel pooling is used, and then the global average pooling is performed to obtain d(F i ):
[0039]
[0040] For d(F i )After processing with the softmax function, calculate the discriminative loss:
[0041] Among them, L ASB (·) represents the adaptive category loss calculation model, Indicates the d(F i ) is processed using the Softmax function.
[0042] Furthermore, the diversity loss L is determined by the following method: DIV :
[0043] For the tensor F i Each feature channel of is normalized with the Softmax function, and then the cross-channel maximum pooling is performed. Finally, the values of the feature channels after pooling are summed to obtain h(F i ):
[0044]
[0045] Calculate the average of C categories as the diversity loss:
[0046]
[0047] The beneficial effects of the present invention are as follows: through the present invention, the key features for soil type identification in soil images can be extracted, the discrimination of soil type identification features can be enhanced, the impact of unclear inter-class differences can be reduced, and the dynamic attention to a few soil category samples can be improved, as well as the ability of the recognition model to learn discriminative feature information, thereby effectively ensuring the final soil type identification accuracy without increasing the number of parameters and with high efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0049] Figure 1 It is a flow chart of the present invention.
[0050] Figure 2 It is a schematic diagram of the MAFL-SoilMobileNet model structure of the present invention.
[0051] Figure 3 Schematic diagram of loss function calculation of the present invention. DETAILED DESCRIPTION
[0052] The present invention is further described in detail below:
[0053] The present invention provides a soil image soil type identification method based on multi-scale feature fusion, comprising the following steps:
[0054] S1. Obtaining a sample soil image and preprocessing the sample soil image;
[0055] S2. Build a MAFL-SoilMobileNet model based on multi-scale feature fusion and multi-scale dilation attention mechanism, and input sample images into the MAFL-SoilMobileNet model for training;
[0056] S3. Obtain the soil image to be identified, and input the soil image to be identified into the trained MAFL-SoilMobileNet model after preprocessing to obtain the soil type identification result. Through the present invention, the key features of soil type identification in the soil image can be extracted, the discrimination of soil type identification features can be enhanced, the impact of unclear inter-class differences can be reduced, and the dynamic attention to a few soil category samples can be improved, and the recognition model's ability to learn discriminative feature information can be improved, so as to effectively ensure the final soil type identification accuracy, and the number of parameters will not be increased, and the efficiency is high. In the above, the preprocessing of the sample image includes denoising, and then the sample image is subjected to background removal processing, and then cut with a window size of 224×224 and a step size of 200 pixels to form multiple sub-images; the preprocessing of the soil image to be identified includes denoising and background removal processing, and background removal refers to removing the background image in the soil image and retaining only the soil part.
[0057] In this embodiment, Figure 2 As shown, in step S2, the MAFL-SoilMobileNet model specifically includes a first convolution module, a multi-scale feature fusion module, a multi-scale dilation attention module, a second convolution module, a pooling module, and a fully connected module;
[0058] The input end of the first convolution module inputs the preprocessed soil image, the first convolution module is used to extract the primary features of the soil image and output them to the multi-scale feature fusion module, the multi-scale feature fusion module extracts the primary features again and performs fusion processing; the output end of the multi-scale feature fusion module is connected to the multi-scale dilated attention module, the output end of the multi-scale dilated attention module is connected to the input end of the second convolution module, the output end of the second convolution module is connected to the input end of the pooling module, the output end of the pooling module is connected to the input end of the fully connected module, and the fully connected module outputs the soil type.
[0059] Specifically: the multi-scale feature fusion module includes 8 Bottleneck modules, and the 8 Bottleneck modules are connected in sequence, the Bottleneck module whose input end is connected to the output end of the first convolution module is numbered 1, and the Bottleneck module whose output end is connected to the input end of the multi-scale dilated attention module is numbered 8, wherein the output channel numbers of the Bottleneck modules numbered 1, 2, 4 and 8 are 16, 24, 40 and 48 respectively; wherein:
[0060] The output information of the Bottleneck modules numbered 1, 2, 4 and 8 are output results I, output result II, output result III and output result IV respectively. Output result IV and output result III are added to form output result V, output result V and output result II are added to form output result VI, output result VI is added to output result I to form output result VII, output result VII, output result VI, output result V and I are added to obtain the final output result and output it to the multi-scale dilated attention module.
[0061] The multi-scale attention module includes three dilated convolutional layers and three SE attention modules, each of which inputs the final output result of the multi-scale feature fusion module, each dilated convolutional layer corresponds to an SE attention module, and the output result of the three SE attention modules is added together and multiplied by the final output result of the multi-scale feature fusion module to form the output result of the multi-scale attention module, and the dilation rates of the three dilated convolutional layers are 1, 2 and 4 respectively. Through the above, the multi-scale features and the multi-scale dilated attention mechanism are integrated through the Bottleneck module to strengthen the extraction of key features for soil type identification and enhance the discrimination of soil type identification features.
[0062] In this embodiment, the MAFL-SoilMobileNet model uses the following loss function for training and parameter update:
[0063] L ASBCC =L ASB +λL CC
[0064] Where: L ASBCC is the training loss function of the MAFL-SoilMobileNet model, L ASB is the adaptive category loss, L CC is the cross-channel loss;
[0065] L CC =L DIS +μL DIV ;
[0066] Where: L DIV is the diversity loss, L DIS is the discriminative loss of each soil category, and λ and μ are hyperparameters.
[0067] The above losses are calculated as follows: Figure 3 As shown, specifically: the adaptive category loss L is determined by the following method ASB :
[0068]
[0069] Where: ω is the adaptive factor, M is the number of samples, y i,j Represents sample x i The true label belonging to the jth soil category, p i,j Represents sample x i The predicted probability of belonging to the jth class of the true label, C is the number of soil categories; where:
[0070]
[0071] The adaptive factor ω is determined as follows:
[0072] Construct the one-hot encoding matrix Y of the soil image dataset:
[0073]
[0074] The soil image dataset is input into the MAFL-SoilMobileNet model, and the prediction probability matrix generated is P:
[0075]
[0076] Construct the probability matrix E of sample prediction error:
[0077] E=YY⊙P; where ⊙ represents the Hadamard product;
[0078] Determine the Frobenius norm of the matrix E and use it as the adaptation factor ω:
[0079] Among them, E i,j Represents the element in the i-th row and j-th column of the probability matrix E.
[0080] The discriminative loss L for each soil type was determined by the following method: DIS :
[0081] Each soil category is assigned 3 characteristic channels, and the number of characteristic channels for all soil categories is 3C;
[0082] The feature channel group of the i-th category is composed of (i×3-2, i×3) feature channels, and the feature channel group of the i-th category is converted into a tensor F i :
[0083]
[0084] in: H and W represent the height and width of the image, respectively;
[0085] For feature group F i The cross-channel maximum pooling (CCMP in the figure represents the cross-channel maximum pooling process) is used to obtain Then global average pooling (GAP in the figure represents global average pooling) is performed to obtain d(F i ):
[0086] This formula can be expressed as follows to clarify the cross-channel maximum pooling process and the global average pooling process:
[0087]
[0088] For d(F i )After processing with the softmax function, calculate the discriminative loss:
[0089] Among them, L ASB (·) represents the adaptive category loss calculation model, that is, substituting each value into L ASB (·) Calculation is performed in the model. Indicates the relationship between d(F i ) is processed by the Softmax function, then C values are obtained.
[0090] The diversity loss L is determined by DIV :
[0091] For the tensor F i Each feature channel of is normalized with the Softmax function, and then the cross-channel maximum pooling is performed. Finally, the values of the feature channels after pooling are summed to obtain h(F i ):
[0092]
[0093] Calculate the average of C categories as the diversity loss:
[0094] Through the above method, an adaptive category balance loss function and an adaptive penalty weight factor ω are designed to improve the network's dynamic attention to minority samples while maintaining the model's ability to tune a single sample. Finally, L ASB With L CC Combined with the training loss L that constitutes the MAFL-SoilMobileNet model ASBCC , so that the model can take into account the feature learning of samples with unbalanced categories and unclear differences between sample classes; at the same time, there is no need to increase the number of model parameters, so that the model can learn the fine-grained features of soil images and improve the network soil type recognition performance.
[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.
Claims
1. A soil image soil type recognition method based on multi-scale feature fusion, characterized by: The following steps are involved: S1. Obtaining a sample soil image and preprocessing the sample soil image; S2. Build a MAFL-SoilMobileNet model based on multi-scale feature fusion and multi-scale dilation attention mechanism, and input sample images into the MAFL-SoilMobileNet model for training; S3. Obtain the soil image to be identified, and input the soil image to be identified into the trained MAFL-SoilMobileNet model after preprocessing to obtain the soil type identification result.
2. The soil image soil type identification method based on multi-scale feature fusion according to claim 1 is characterized by: In step S2, the MAFL-SoilMobileNet model specifically includes a first convolution module, a multi-scale feature fusion module, a multi-scale dilated attention module, a second convolution module, a pooling module, and a fully connected module; The input end of the first convolution module inputs the preprocessed soil image, the first convolution module is used to extract the primary features of the soil image and output them to the multi-scale feature fusion module, the multi-scale feature fusion module extracts the primary features again and performs fusion processing; the output end of the multi-scale feature fusion module is connected to the multi-scale dilated attention module, the output end of the multi-scale dilated attention module is connected to the input end of the second convolution module, the output end of the second convolution module is connected to the input end of the pooling module, the output end of the pooling module is connected to the input end of the fully connected module, and the fully connected module outputs the soil type.
3. The soil image soil type identification method based on multi-scale feature fusion according to claim 2 is characterized by: The multi-scale feature fusion module includes 8 Bottleneck modules, and the 8 Bottleneck modules are connected in sequence, the Bottleneck module whose input end is connected to the output end of the first convolution module is numbered 1, and the Bottleneck module whose output end is connected to the input end of the multi-scale dilated attention module is numbered 8, wherein the output channel numbers of the Bottleneck modules numbered 1, 2, 4 and 8 are 16, 24, 40 and 48 respectively; wherein: The output information of the Bottleneck modules numbered 1, 2, 4 and 8 are output results I, output result II, output result III and output result IV respectively. Output result IV and output result III are added to form output result V, output result V and output result II are added to form output result VI, output result VI is added to output result I to form output result VII, output result VII, output result VI, output result V and I are added to obtain the final output result and output it to the multi-scale dilated attention module.
4. The soil image soil type identification method based on multi-scale feature fusion according to claim 2 or 3 is characterized in that: The multi-scale attention module includes three dilated convolutional layers and three SE attention modules. Each dilated convolutional layer inputs the final output result of the multi-scale feature fusion module. Each dilated convolutional layer corresponds to an SE attention module. The output results of the three SE attention modules are added together and multiplied by the final output result of the multi-scale feature fusion module to form the output result of the multi-scale attention module. The dilation rates of the three dilated convolutional layers are 1, 2 and 4 respectively.
5. The soil image soil type identification method based on multi-scale feature fusion according to claim 4 is characterized by: The MAFL-SoilMobileNet model uses the following loss function for training and parameter update: THE ASBCC =L ASB +λL CC Where: L ASBCC is the training loss function of the MAFL-SoilMobileNet model, L ASB is the adaptive category loss, L CC is the cross-channel loss; L CC =L DIS +μL DIV ; Where: L DIV is the diversity loss, L DIS is the discriminative loss of each soil category, and λ and μ are hyperparameters.
6. The soil image soil type identification method based on multi-scale feature fusion according to claim 5 is characterized by: The adaptive category loss L is determined by the following method ASB : Where: ω is the adaptive factor, M is the number of samples, y i,j Represents sample x i The true label belonging to the jth soil category, p i,j Represents sample x i The predicted probability of belonging to the jth class of the true label, C is the number of soil categories; where:
7. The soil image soil type identification method based on multi-scale feature fusion according to claim 6 is characterized by: The adaptive factor ω is determined by the following method: Construct the one-hot encoding matrix Y of the soil image dataset: The soil image dataset is input into the MAFL-SoilMobileNet model, and the prediction probability matrix generated is P: Construct the probability matrix E of sample prediction error: E=YY⊙P; where ⊙ represents the Hadamard product; Determine the Frobenius norm of the matrix E and use it as the adaptation factor ω: Among them, E i,j Represents the element in the i-th row and j-th column of the probability matrix E.
8. The soil image soil type identification method based on multi-scale feature fusion according to claim 7 is characterized by: The discriminative loss L for each soil type was determined by the following method: DIS : Each soil category is assigned 3 characteristic channels, and the number of characteristic channels for all soil categories is 3C; The feature channel group of the i-th category is composed of (i×3-2, i×3) feature channels, and the feature channel group of the i-th category is converted into a tensor F i : in: H and W represent the height and width of the image, respectively; For feature group F i The maximum cross-channel pooling is used, and then the global average pooling is performed to obtain d(F i ): For d(F i )After processing with the softmax function, calculate the discriminative loss: Among them, L ASB (·) represents the adaptive category loss calculation model, Indicates the relationship between d(F i ) is processed using the Softmax function.
9. The soil image soil type identification method based on multi-scale feature fusion according to claim 8 is characterized by: The diversity loss L is determined by DIV : For the tensor F i Each feature channel of is normalized with the Softmax function, and then the cross-channel maximum pooling is performed. Finally, the values of the feature channels after pooling are summed to obtain h(F i ): Calculate the average of C categories as the diversity loss:
Citation Information
Cited By
Intelligent automatic soil sample warehousing method and system
CN120717101A
Intelligent and automated soil sample warehousing method and system
CN120717101B