Multi-mode soil nutrient detection method

By using a multimodal soil nutrient detection model that combines visual and electrochemical information to dynamically adjust parameters to adapt to different soil types, the problem of insufficient detection accuracy and generalization ability in existing technologies has been solved, and real-time, portable, and high-precision nutrient detection has been achieved.

CN121783866APending Publication Date: 2026-04-03济南市济阳区综合检验检测中心
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-30
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing soil nutrient detection methods have weak generalization ability across different soil types, and electrochemical sensors have poor specificity, making it difficult to achieve real-time and accurate nutrient detection.

Method used

A multimodal soil nutrient detection model was constructed. By combining a visual condition extraction unit and a conditional gating network with a nutrient regression network, parameters were dynamically adjusted to adapt to different soil types. Nutrient prediction was performed by combining soil images and physicochemical properties, and physical constraints were embedded to prevent violations of physicochemical laws.

Benefits of technology

It improves the accuracy and generalization ability of nutrient detection, supports real-time and portable nutrient detection, and enhances the physical consistency and agronomic interpretability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121783866A_ABST
    Figure CN121783866A_ABST
Patent Text Reader

Abstract

The invention relates to a multi-mode soil nutrient detection method. The method comprises the following steps: establishing a first data set containing physicochemical properties and nutrient content data by utilizing a soil nutrient simulation solution, and constructing a second data set containing soil images, physicochemical properties and nutrient content; a nutrient regression network of a soil nutrient detection model performs preliminary modeling of a relationship between physicochemical properties and nutrient content by using a large-scale first data set, and then a visual condition extraction unit extracts a condition related to a soil type based on a soil image of a second data set. A conditional gating network of the soil nutrient detection model corrects nutrient regression network parameters based on a scaling factor, a translation factor and a final bias which are output and generated by a visual condition extraction unit, and personalized modeling of one type of soil and one set of parameters is realized through conditional affine transformation. Through multi-task joint training, the prediction precision and the cross-regional generalization ability of the soil nutrient detection model are significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of smart agriculture detection technology, and in particular to a multimodal soil nutrient detection method driven by deep learning, which dynamically corrects the parameters of a nutrient regression model using soil type as a conditional variable. Background Technology

[0002] The statements in this section are merely background information relating to this disclosure and do not necessarily constitute prior art.

[0003] Macronutrients such as nitrogen (N), phosphorus (P), potassium (K), calcium (Ca), magnesium (Mg), and sulfur (S) are key elements required for plant growth, and are needed in large quantities. They play important roles in many processes, including photosynthesis, respiration, and the synthesis of proteins and amino acids. For plants, different macronutrients perform different functions. For example, nitrogen is a component of amino acids, nucleic acids, and chlorophyll, and is crucial for plant tissue formation. Phosphorus is indispensable in key processes such as adenosine triphosphate (ATP)-mediated energy transfer, photosynthesis, and respiration; it also participates in the formation of phospholipids and nucleic acids, and is essential for maintaining cell membrane integrity. Precise monitoring of macronutrient levels in soil is necessary because their availability is dynamically regulated by various factors such as soil composition, climatic conditions, and historical land use patterns.

[0004] Current methods for soil nutrient detection include colorimetry, atomic absorption spectrometry, X-ray fluorescence spectrometry, and inductively coupled plasma atomic emission spectrometry (ICP-AES) to achieve precise quantification of soil nutrients. While these technologies are sophisticated and advanced, they are often too costly and time-consuming, making them unsuitable for real-time monitoring. Electrochemical sensing methods have attracted considerable attention due to their portability, ease of operation, and ability to support rapid soil testing. However, electrochemical sensors suffer from poor specificity; real soil solutions are multi-ion systems, leading to significant cross-sensitivity; detection is highly dependent on matrix background, with the same ion concentration exhibiting drastically different electrical signal responses in soils with different textures, organic matter contents, or cation exchange capacities; and most devices only output raw voltage / current values, lacking semantic correlation with plant nutrient requirements, necessitating secondary interpretation by professionals.

[0005] In recent years, machine learning has provided new insights into soil testing. By collecting easily measurable physical quantities such as pH, conductivity, dielectric constant, and redox potential (ORP) of soil suspensions, and combining them with regression algorithms (such as support vector machines and random forests), the contents of N, P, and K can be indirectly predicted. For example, convolutional neural networks can be used to process soil spectral-conductivity time-series data to achieve dynamic nitrogen tracking. However, the above work still has fundamental limitations: the models have weak generalization ability, the training data mostly comes from specific regions and single soil types (such as only black soil or red soil), and the performance deteriorates sharply when migrated to heterogeneous environments; the regulatory role of soil intrinsic properties on ion behavior is not considered, and soil type itself is the core regulatory factor governing nutrient ion migration, transformation, and bioavailability. Taking potassium as an example: In black soil dominated by 2:1 type clay minerals (such as montmorillonite and illite), approximately 60–80% of potassium ions are fixed between crystal layers, with only a small portion existing in exchangeable and water-soluble states. However, in red soil dominated by 1:1 type kaolinite, the lattice fixation ability is weak, but the specific adsorption of phosphate by iron and aluminum oxides is extremely strong, resulting in very low water-soluble potassium. In other words, the same ion concentration exhibits drastically different bioavailability and electrochemical characterization responses in different soil types. Summary of the Invention

[0006] To solve the above-mentioned technical problems, or at least partially solve them, the present invention provides a multimodal soil nutrient detection method.

[0007] This invention provides a multimodal method for soil nutrient detection, comprising: A soil nutrient simulation solution was prepared, which was a ternary mixture of potassium hydroxide, phosphoric acid, and nitric acid, with a concentration range covering the set soil nutrient classification standards. The physicochemical properties and corresponding nutrient concentrations of each soil nutrient simulation solution were obtained to construct the first dataset, wherein the physicochemical properties included pH, conductivity, volt-ampere characteristic curve, volt-ampere characteristic curve integral, volt-ampere characteristic curve inflection point, volt-ampere characteristic curve initial slope, and impedance phase angle at a set frequency. Soil images, soil physicochemical properties, and nutrient content of different soil types were collected to construct a second dataset; the size of the second dataset is much smaller than that of the first dataset. The soil nutrient detection model is trained using the first and second datasets in a multi-task training manner, so that the soil nutrient detection model can predict nutrient content based on soil images and soil physicochemical properties. The soil nutrient detection model includes a visual condition extraction unit, a conditional gating network, and a nutrient regression network. The visual condition extraction unit extracts conditional embedding vectors based on soil images. The conditional gating network receives the conditional embedding vectors and generates soil type-specific scaling factors, translation factors, and final biases. The nutrient regression network receives physicochemical characteristic feature vectors and dynamically adjusts parameters based on scaling factors, translation factors, and final bias conditional affine transformations to predict nutrient content. During inference, the soil nutrient detection model uses the collected soil images and the physicochemical properties of soil suspensions with a set weight-to-volume ratio to predict nutrients.

[0008] Furthermore, a soil nutrient simulation solution is prepared, wherein the soil nutrient simulation solution is a ternary mixture of potassium hydroxide, phosphoric acid and nitric acid, and the concentration range covers the set soil nutrient classification standards; the physicochemical properties and corresponding nutrient concentrations of each soil nutrient simulation solution are obtained to construct the first dataset, including: diluting concentrated nitric acid to a 0.5 mol / L nitric acid stock solution, diluting phosphoric acid to a 0.1 mol / L phosphoric acid stock solution, and preparing potassium hydroxide tablets to a 1 mol / L potassium hydroxide stock solution; Potassium hydroxide, phosphoric acid and nitric acid mother liquors were divided into M grades within their respective concentration ranges. Samples of the three mother liquors were taken evenly according to their concentration levels, and all possible combinations were taken for ternary mixing. After removing the ternary mixture results that resulted in precipitation, the remaining mixture was used as a soil nutrient simulation solution. Based on the physicochemical properties of the simulated soil nutrient solution obtained by hydrogen ion hydrolysis, and after pretreatment.

[0009] Furthermore, the preprocessing of the current-voltage characteristic curve includes: performing baseline correction and subtracting the dark current at 0V; Savitzky-Golay filters were used to filter and suppress measurement noise.

[0010] Furthermore, a second dataset was constructed by collecting soil images, soil physicochemical properties, and nutrient content data for different soil types, including: Images of the surface layer of different soil types under uniform lighting conditions were taken. The dimensions of the soil image are normalized to a set number of pixels; white balance and chromaticity calibration are performed based on the Macbeth color chart; and unsharpened masking is applied to highlight the boundaries of the aggregates. Data augmentation of soil images includes: implementing geometric transformations such as rotation, scaling, and horizontal flipping; implementing photometric perturbations including brightness perturbation, contrast perturbation, and saturation perturbation; and implementing noise injection including Gaussian noise and motion blur. The nutrient content of the soil was tested experimentally, and the physicochemical properties of the soil suspension were collected. The corresponding soil images, soil physicochemical properties, and soil nutrient content are used as a set of matching data to form a second dataset.

[0011] Furthermore, the visual condition extraction unit uses a lightweight convolutional neural network as its backbone. The output of its global average pooling layer is compressed into a conditional embedding vector related to soil type by a two-layer perceptron, and then mapped to soil category probability using a softmax function. The soil types include alluvial soil, black soil, clay, red soil, lateritic red soil, peat soil, and loess.

[0012] Furthermore, the conditional gating network employs hierarchical condition generation, which includes: Type-specific bias module: The type-specific bias module defines a learnable matrix B, where the learnable matrix B is the bias vector corresponding to the soil type, and the final bias... p represents the probability distribution of soil type provided by the visual condition extraction unit; The affine transformation gating module, composed of a multilayer perceptron, takes a conditional embedding vector as input and outputs a dimension-matched scaling factor and translation factor. ; Where e is the conditional embedding vector, For affine transformation gating module, These represent the first-layer weights, first-layer biases, second-layer weights, and second-layer biases of the affine transformation gating module, respectively; γ is the scaling factor matrix, β is the translation factor matrix, and the dimensions match the hidden layers of the nutrient regression network.

[0013] Furthermore, the nutrient regression network consists of multiple fully connected layers, and the scaling factor, translation factor, and final bias output from the conditional gating network are dynamically injected into each layer of the nutrient regression network: The first hidden layer of the nutrient return network: ; in, The scaling factor for the first hidden layer of the nutrient-injecting regression network; The translation factor for the first hidden layer of the nutrient-injecting regression network; Characteristics of physical and chemical properties; The weights and biases of the first hidden layer of the nutrient regression network itself; Second hidden layer: ; in, The scaling factor for the first hidden layer of the nutrient-injecting regression network; The translation factor for the first hidden layer of the nutrient-injecting regression network; The weights and biases of the second hidden layer of the nutrient regression network itself; Output layer: ; in, The weights and biases of the output layer of the nutrient regression network itself; This is the final bias generated by the conditional gating network.

[0014] Furthermore, the soil nutrient detection model undergoes two-stage training, including: Phase 1: Pre-training on the first dataset; The nutrient regression network was trained on the first dataset to learn the basic mapping from physicochemical properties to nutrient concentration. Phase Two: Fine-tuning Training on the Second Dataset The second dataset incorporates labeled real soil data, and all parameters of the soil nutrient detection model are fine-tuned end-to-end; low-noise samples with pH 5.5–7.5 are trained first, and samples with pH < 4.5 or > 8.5 are gradually included. The training employs the following multi-task joint loss: ; in, The weights for the joint loss of multiple tasks, This represents the standard mean absolute error loss between the predicted nutrient concentration and the actual nutrient concentration. The KL divergence between the predicted type probability distribution of the visual condition extraction unit and the one-hot encoded label of the actual soil type is used to supervise the classification accuracy of the visual condition extraction unit. The constraints are physical, and the predictions based on these constraints conform to physical laws. This is a regularization term for model weights, used to prevent overfitting.

[0015] Furthermore, physical constraints include: the total charge of cations cannot exceed the soil's cation exchange capacity, and the difference between the ion product and solubility product of sparingly soluble salt anions and cations must not exceed zero. ; in, This refers to the cation exchange capacity of the soil. To predict the total charge of cations; The ion product of sparingly soluble salt cations and anions. This is the solubility product of the corresponding sparingly soluble salt.

[0016] Furthermore, the soil nutrient detection model uses collected soil images and the physicochemical properties of soil suspensions at a set weight-to-volume ratio to predict nutrient levels, including: Soil samples were collected, soil images were taken and preprocessed, and a soil-water suspension with a set mass-to-volume ratio was prepared. Electrochemical measurements were performed on the supernatant of the suspension to obtain its physicochemical characteristics. The soil image is processed by the visual condition extraction unit to obtain the soil type distribution probability and conditional embedding vector; The soil type distribution probability and conditional embedding vector are input into a conditional gating network to generate a scaling factor matrix, a translation factor matrix, and a final bias. Physicochemical properties are input into the nutrient regression network, and the predicted nutrient values ​​are output after modulation by a conditional gating network. .

[0017] The technical solutions provided in the embodiments of the present invention have the following advantages compared with the prior art: The soil nutrient detection model of this invention treats soil type as a higher-order context variable. Through a learnable conditional gating mechanism, it dynamically modulates the neural network parameters of the nutrient regression network, enabling dynamic correction of model parameters and giving the model soil type-aware reasoning capabilities. The detection and sampling process is simple, the equipment is portable, and it supports real-time measurement. Furthermore, it embeds prior physical constraints of soil chemistry into the loss function to prevent the model from outputting absurd predictions that violate basic physicochemical laws, thus enhancing physical consistency. In summary, this application improves the prediction accuracy and generalization ability of the soil nutrient detection model, supporting real-time nutrient detection. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and constitute this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A flowchart illustrating a multimodal soil nutrient detection method provided in an embodiment of the present invention; Figure 2 This is a diagram illustrating the architecture of the soil nutrient detection model provided in an embodiment of the present invention. Figure 3 A flowchart for constructing a second dataset provided in an embodiment of the present invention; Figure 4 This is a flowchart illustrating the prediction of a soil nutrient detection model provided in an embodiment of the present invention. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0022] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0023] Example 1 like Figure 1 and Figure 2 As shown, the present invention provides a multimodal soil nutrient detection method that, by jointly analyzing the visual representation and electrochemical response of soil, constructs a condition-aware deep regression model, significantly improving the prediction accuracy, generalization ability, and agronomic interpretability of nutrients such as N, P, and K, including: S100 utilizes the method of configuring soil nutrient simulation solutions to construct a large-scale, low-cost first dataset; The soil nutrient simulation solution uses a ternary mixture of potassium hydroxide, phosphoric acid, and nitric acid, with a concentration range covering the established soil nutrient classification standards. The specific preparation process includes: diluting concentrated nitric acid to a 0.5 mol / L nitric acid stock solution, diluting phosphoric acid to a 0.1 mol / L phosphoric acid stock solution, and preparing a 1 mol / L potassium hydroxide stock solution from potassium hydroxide tablets; dividing the potassium hydroxide, phosphoric acid, and nitric acid stock solutions into M grades within their respective concentration ranges; uniformly sampling the three stock solutions according to their concentration grades; and mixing all possible combinations, with the total number of possible combinations being M. 3 Not all ternary mixture results are feasible. After discarding the ternary mixtures that resulted in precipitation, the remaining mixtures were used as soil nutrient simulation solutions. Since the concentration of the mother liquor and the mixing ratio are known, the nutrient content of the prepared soil nutrient simulation solutions can be obtained without nutrient measurement. In other words, the process of constructing the first dataset using soil nutrient simulation solutions saves a significant amount of nutrient detection work.

[0024] The first dataset was constructed by acquiring the physicochemical properties and corresponding nutrient concentrations of each soil nutrient simulation solution. The physicochemical properties included pH, conductivity, voltammetric characteristic curves, integrals of the voltammetric characteristic curves, inflection points of the voltammetric characteristic curves, initial slopes of the voltammetric characteristic curves, and impedance phase angles at a set frequency. Since the ion concentrations of the soil nutrient simulation solutions were known, pH and conductivity could be theoretically calculated and did not require measurement. For example, the ion mobility of the soil nutrient simulation solution determined its conductivity, which was positively correlated with the sum of the concentrations and molar conductivities of various ions. The molar conductivity of potassium ions was 73.5 S·cm² / mol; that of nitrate ions was 71.5 S·cm² / mol; that of dihydrogen phosphate ions was 33.0 S·cm² / mol; that of hydrogen phosphate ions was 57.0 S·cm² / mol; and that of phosphate ions was 69.0 S·cm² / mol. Only the voltammetric characteristics needed to be measured. The voltammetric characteristic measurement was performed using a dual platinum electrode system with an electrode spacing of 4.0-5.0 cm, an effective area of ​​1.0-1.5 cm², a voltage scan range of 0-5 V, and a step size of 20-100 mV. The inflection point voltage of the voltammetric characteristic curve was obtained by locating the extreme point of the second derivative of the voltammetric curve, which characterizes the adsorption behavior of phosphate ions on the surface of soil colloids.

[0025] The initial slope of the volt-ampere characteristic curve characterizes the low-field mobility, and the integral of the volt-ampere characteristic curve reflects the total charge transfer. The inflection point of the volt-ampere characteristic curve is located by the extreme value of the second derivative, corresponding to water oxidation or phosphate adsorption / desorption, and the inflection point voltage is positively correlated with the phosphate ion concentration. Conductivity and impedance phase angle work together: conductivity reflects the total amount of ions, and impedance phase angle reflects the interfacial process and ion specificity.

[0026] After measuring the current-voltage characteristic curve, the preprocessing of the current-voltage characteristic curve is required, including: baseline correction to subtract the dark current at 0V; and filtering with a Savitzky-Golay filter to suppress measurement noise.

[0027] S200: Collect soil images, soil physicochemical properties, and nutrient content of different types of soil to construct the second dataset. The second dataset requires tedious physicochemical property detection and nutrient content detection, but the purpose is to fine-tune the model. The dataset size requirement is small. Therefore, the size of the second dataset is much smaller than that of the first dataset.

[0028] like Figure 3 As shown, the process of constructing the second dataset includes: Soil surface images of different soil types under uniform lighting conditions were captured; the length and width of the soil images were normalized to a set pixel size; white balance and color calibration were performed based on the Macbeth color chart; and unsharpened masking was applied to highlight the boundaries of aggregates. Data augmentation of soil images includes: implementing geometric transformations such as rotation, scaling, and horizontal flipping; implementing photometric perturbations including brightness, contrast, and saturation perturbations; and injecting noise including Gaussian noise and motion blur. Augmentation provides multiple different forms of soil images for the same soil scene, combining corresponding physicochemical properties and nutrient content to generate more data. It also improves the model's robustness to changes in field light, humidity, and shooting angle.

[0029] The soil nutrient content is tested experimentally. A soil-water suspension is prepared according to a set mass-volume ratio, and the supernatant of the suspension is used to measure the physicochemical properties of the soil. Examples of experimental testing of soil nutrient content include: nitrogen content is determined by the Kjeldahl method, phosphorus content is determined by the sodium hydroxide fusion-molybdenum antimony colorimetric method, and potassium content is determined by the sodium hydroxide fusion-flame photometry or atomic absorption spectrometry.

[0030] The corresponding soil images, soil physicochemical properties, and soil nutrient content are used as a set of matching data to form a second dataset.

[0031] S300, construct a soil nutrient detection model, and train the soil nutrient detection model using the first dataset and the second dataset in a multi-task training manner, so that the soil nutrient detection model can predict nutrient content based on soil images and soil physicochemical properties.

[0032] Among them, such as Figure 2 As shown, the soil nutrient detection model includes: a visual condition extraction unit, a conditional gating network, and a nutrient regression network. The visual condition extraction unit extracts conditional embedding vectors based on soil images. The conditional gating network receives the conditional embedding vectors and generates soil type-specific scaling factors, translation factors, and final biases. The nutrient regression network receives physicochemical characteristic feature vectors and dynamically adjusts parameters through conditional affine transformations based on scaling factors, translation factors, and final biases to predict nutrient content. In the specific implementation process, the visual condition extraction unit uses a lightweight convolutional neural network as the backbone, such as MobileNetV3, to balance accuracy and mobile deployment. Its global average pooling layer outputs a feature vector of 512, which is compressed into a conditional embedding vector related to soil type by a two-layer perceptron, and then mapped to a soil category probability distribution using the softmax function. The soil types include alluvial soil, black soil, clay, red soil, lateritic red soil, peat soil, and loess.

[0033] The conditional gating network uses hierarchical condition generation, which includes: Type-specific bias module: The type-specific bias module defines a learnable matrix B, where the learnable matrix B is the bias vector corresponding to the soil type, and the final bias... p represents the probability distribution of soil type provided by the visual condition extraction unit; The affine transformation gating module, composed of a multilayer perceptron, takes a conditional embedding vector as input and outputs a dimension-matched scaling factor and translation factor. ; Where e is the conditional embedding vector, For affine transformation gating module, These represent the first-layer weights, first-layer biases, second-layer weights, and second-layer biases of the affine transformation gating module, respectively; γ is the scaling factor matrix, β is the translation factor matrix, and the dimensions match the hidden layers of the nutrient regression network.

[0034] The nutrient regression network consists of multiple fully connected layers. The scaling factor, translation factor, and final bias output from the conditional gating network are dynamically injected into each layer of the nutrient regression network. The first hidden layer of the nutrient return network: ; in, The scaling factor for the first hidden layer of the nutrient-injecting regression network; The translation factor for the first hidden layer of the nutrient-injecting regression network; Characteristics of physical and chemical properties; The weights and biases of the first hidden layer of the nutrient regression network itself; Second hidden layer: ; in, The scaling factor for the first hidden layer of the nutrient-injecting regression network; The translation factor for the first hidden layer of the nutrient-injecting regression network; The weights and biases of the second hidden layer of the nutrient regression network itself; Output layer: ; in, The weights and biases of the output layer of the nutrient regression network itself; This is the final bias generated by the conditional gating network. The conditional affine transformation essentially allows the nutrient regression network to perform nutrient prediction in a context-specific manner.

[0035] The soil nutrient detection model undergoes two-stage training, including: Phase 1: Pre-training on the first dataset; The nutrient regression network was trained on the first dataset to learn the basic mapping from physicochemical properties to nutrient concentration. Phase Two: Fine-tuning Training on the Second Dataset Soil images and soil types from the second dataset were used to train a visual condition extraction unit for soil image classification. The parameters of the visual condition extraction unit were frozen, and a conditional gating network and a nutrient regression network were trained using soil images, physicochemical properties, and nutrient concentrations from the second dataset.

[0036] Alternatively, a second dataset can be used to incorporate labeled real soil data, allowing for end-to-end fine-tuning of all parameters in the soil nutrient detection model.

[0037] First, train low-noise samples with pH 5.5–7.5, and then gradually include samples with pH < 4.5 or > 8.5; The training employs the following multi-task joint loss: ; in, The weights for the joint loss of multiple tasks, This represents the standard mean absolute error loss between the predicted nutrient concentration and the actual nutrient concentration. The KL divergence between the predicted type probability distribution of the visual condition extraction unit and the one-hot encoded label of the actual soil type is used to supervise the classification accuracy of the visual condition extraction unit. The constraints are physical, and the predictions based on these constraints conform to physical laws. This is a regularization term for model weights, used to prevent overfitting.

[0038] Among these physical constraints are: the total charge of cations cannot exceed the cation exchange capacity of the soil, and the difference between the ion product and the solubility product of sparingly soluble salt anions and cations cannot exceed zero. ; in, This refers to the cation exchange capacity of the soil. To predict the total charge of cations; The ion product of sparingly soluble salt cations and anions. This is the solubility product of the corresponding sparingly soluble salt.

[0039] S400, during inference, the soil nutrient detection model uses the collected soil images and the physicochemical properties of soil suspensions with a set weight-to-volume ratio to predict nutrients, such as... Figure 4 As shown, it includes: Soil samples were collected, soil images were taken, and preprocessing was performed in the same manner as the second dataset to prepare a soil-water suspension with a set mass-to-volume ratio. Electrochemical measurements were performed on the supernatant of the suspension to obtain its physicochemical characteristics. The soil image is processed by the visual condition extraction unit to obtain the soil type distribution probability and conditional embedding vector; The soil type distribution probability and conditional embedding vector are input into a conditional gating network to generate a scaling factor matrix, a translation factor matrix, and a final bias. Physicochemical properties are input into the nutrient regression network, and the predicted nutrient values ​​are output after modulation by a conditional gating network. .

[0040] Using conditional embedding vectors related to soil image classification as conditional variables, the weights and biases of the nutrient regression network are adaptively adjusted to achieve dynamic correction of model parameters, enabling the model to have soil type perception reasoning ability; the detection and sampling process is simple, the equipment is portable, and real-time measurement is supported; physical constraints of soil chemical priors are embedded in the loss function to prevent the model output from absurd predictions that violate basic physicochemical laws, thereby enhancing physical consistency.

[0041] In the embodiments provided by this invention, it should be understood that the disclosed structures and methods can be implemented in other ways. For example, the structural embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, structures, or units, and may be electrical, mechanical, or other forms.

[0042] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0043] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0044] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A multimodal method for detecting soil nutrients, characterized in that, include: A soil nutrient simulation solution is prepared, which is a ternary mixture of potassium hydroxide, phosphoric acid and nitric acid, with a concentration range covering the set soil nutrient classification standards. The physicochemical properties and corresponding nutrient concentrations of each soil nutrient simulation solution are obtained to construct the first dataset, wherein the physicochemical properties include pH, conductivity, current-voltage characteristic curve, current-voltage characteristic curve integral, current-voltage characteristic curve inflection point, current-voltage characteristic curve initial slope, and impedance phase angle at a set frequency. A second dataset was constructed by collecting soil images, soil physicochemical properties, and nutrient content of different soil types. The second dataset is much smaller than the first dataset. The soil nutrient detection model is trained using the first and second datasets in a multi-task training manner, so that the soil nutrient detection model can predict nutrient content based on soil images and soil physicochemical properties. The soil nutrient detection model includes a visual condition extraction unit, a conditional gating network, and a nutrient regression network. The visual condition extraction unit extracts conditional embedding vectors based on soil images. The conditional gating network receives the conditional embedding vectors and generates soil type-specific scaling factors, translation factors, and final biases. The nutrient regression network receives physicochemical characteristic feature vectors and dynamically adjusts parameters based on scaling factors, translation factors, and final bias conditional affine transformations to predict nutrient content. During inference, the soil nutrient detection model uses the collected soil images and the physicochemical properties of soil suspensions with a set weight-to-volume ratio to predict nutrients.

2. The multimodal soil nutrient detection method according to claim 1, characterized in that, Prepare a soil nutrient simulation solution by: diluting concentrated nitric acid to a 0.5 mol / L nitric acid stock solution, diluting phosphoric acid to a 0.1 mol / L phosphoric acid stock solution, and preparing potassium hydroxide tablets to a 1 mol / L potassium hydroxide stock solution; The mother liquors of potassium hydroxide, phosphoric acid, and nitric acid were divided into M grades within their respective concentration ranges. Samples of the three mother liquors were taken uniformly according to their concentration levels, and all possible combinations were taken for ternary mixing. After removing the ternary mixtures that resulted in precipitation, the remaining mixture was used as a soil nutrient simulation solution.

3. The multimodal soil nutrient detection method according to claim 1, characterized in that, The preprocessing of the current-voltage characteristic curve includes: baseline correction and subtracting the dark current at 0V; Savitzky-Golay filters were used to filter and suppress measurement noise.

4. The multimodal soil nutrient detection method according to claim 1, characterized in that, The second dataset was constructed by collecting soil images, soil physicochemical properties, and nutrient content data for different soil types. Images of the surface layer of different soil types under uniform lighting conditions were taken. The dimensions of the soil image are normalized to a set number of pixels; white balance and chromaticity calibration are performed based on the Macbeth color chart; and unsharpened masking is applied to highlight the boundaries of the aggregates. Data augmentation of soil images includes: implementing geometric transformations such as rotation, scaling, and horizontal flipping; implementing photometric perturbations including brightness perturbation, contrast perturbation, and saturation perturbation; and implementing noise injection including Gaussian noise and motion blur. The soil nutrient content was tested by experiment, and a soil-water suspension was prepared according to the set mass-volume ratio. The supernatant of the suspension was taken to measure the physicochemical properties of the soil. The corresponding soil images, soil physicochemical properties, and soil nutrient content are used as a set of matching data to form a second dataset.

5. The multimodal soil nutrient detection method according to claim 1, characterized in that, The visual condition extraction unit uses a lightweight convolutional neural network as its backbone. Its global average pooling layer output is compressed into a conditional embedding vector related to soil type by a two-layer perceptron, and then mapped to soil category probability using a softmax function. The soil types include alluvial soil, black soil, clay, red soil, lateritic red soil, peat soil, and loess.

6. The multimodal soil nutrient detection method according to claim 1, characterized in that, The conditional gating network uses hierarchical condition generation, which includes: Type-specific bias module: The type-specific bias module defines a learnable matrix B, where the learnable matrix B is the bias vector corresponding to the soil type, and the final bias... p represents the probability distribution of soil type provided by the visual condition extraction unit; The affine transformation gating module, composed of a multilayer perceptron, takes a conditional embedding vector as input and outputs a dimension-matched scaling factor and translation factor. ; Where e is the conditional embedding vector, For affine transformation gating module, These represent the first-layer weights, first-layer biases, second-layer weights, and second-layer biases of the affine transformation gating module, respectively; γ is the scaling factor matrix, β is the translation factor matrix, and the dimensions match the hidden layers of the nutrient regression network.

7. The multimodal soil nutrient detection method according to claim 1, characterized in that, The nutrient regression network consists of multiple fully connected layers. The scaling factor, translation factor, and final bias output from the conditional gating network are dynamically injected into each layer of the nutrient regression network. The first hidden layer of the nutrient return network: ; in, The scaling factor for the first hidden layer of the nutrient-injecting regression network; The translation factor for the first hidden layer of the nutrient-injecting regression network; Characteristics of physical and chemical properties; The weights and biases of the first hidden layer of the nutrient regression network itself; Second hidden layer: ; in, The scaling factor for the first hidden layer of the nutrient-injecting regression network; The translation factor for the first hidden layer of the nutrient-injecting regression network; The weights and biases of the second hidden layer of the nutrient regression network itself; Output layer: ; in, The weights and biases of the output layer of the nutrient regression network itself; This is the final bias generated by the conditional gating network.

8. The multimodal soil nutrient detection method according to claim 1, characterized in that, The soil nutrient detection model undergoes two-stage training, including: Phase 1: Pre-training on the first dataset; The nutrient regression network is trained on the first dataset to learn the basic mapping from physicochemical properties to nutrient concentration. Phase Two: Fine-tuning Training on the Second Dataset The second dataset incorporates labeled real soil data, and all parameters of the soil nutrient detection model are fine-tuned end-to-end; low-noise samples with pH 5.5–7.5 are trained first, and samples with pH < 4.5 or > 8.5 are gradually included. The training employs the following multi-task joint loss: ; in, The weights for the joint loss of multiple tasks, This represents the standard mean absolute error loss between the predicted nutrient concentration and the actual nutrient concentration. The KL divergence between the predicted type probability distribution of the visual condition extraction unit and the one-hot encoded label of the actual soil type is used to supervise the classification accuracy of the visual condition extraction unit. The constraints are physical, and the predictions based on these constraints conform to physical laws. This is a regularization term for model weights, used to prevent overfitting.

9. The multimodal soil nutrient detection method according to claim 8, characterized in that, Physical constraints include: the total charge of cations cannot exceed the cation exchange capacity of the soil, and the difference between the ion product and solubility product of sparingly soluble salt anions and cations must not exceed zero. ; in, This refers to the cation exchange capacity of the soil. To predict the total charge of cations; The ion product of sparingly soluble salt cations and anions. This is the solubility product of the corresponding sparingly soluble salt.

10. The multimodal soil nutrient detection method according to claim 1, characterized in that, The soil nutrient detection model uses collected soil images and the physicochemical properties of soil suspensions with set weight-to-volume ratios to predict nutrient levels, including: Soil samples were collected, soil images were taken, and preprocessing was performed in the same manner as the second dataset to prepare a soil-water suspension with a set mass-to-volume ratio. Electrochemical measurements were performed on the supernatant of the suspension to obtain its physicochemical characteristics. The soil image is processed by the visual condition extraction unit to obtain the soil type distribution probability and conditional embedding vector; The soil type distribution probability and conditional embedding vector are input into a conditional gating network to generate a scaling factor matrix, a translation factor matrix, and a final bias. Physicochemical properties are input into the nutrient regression network, and the predicted nutrient values ​​are output after modulation by a conditional gating network. .