Spectral water quality online monitoring method, system and equipment based on edge calculation, medium and product

By deploying a lightweight one-dimensional convolutional neural network model and LoRa communication on a microcontroller, the problems of weak anti-interference ability and high computational requirements in water quality monitoring are solved, and high-precision, low-power real-time monitoring of water quality parameters is achieved.

CN120831332APending Publication Date: 2025-10-24SHANDONG MARINE RESOURCE AND ENVIRONMENT RESEARCH INSTITUTE (SHANDONG MARINE ENVIRONMENTAL MONITORING CENTER SHANDONG AQUATIC PRODUCTS QUALITY INSPECTION CENTER) +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510961378.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-11
Publication Date
2025-10-24

AI Technical Summary

Technical Problem

Existing optical sensors have weak anti-interference capabilities and poor generalization in water quality monitoring, and deep learning models have high computational requirements, making it difficult to achieve high-precision monitoring on microcontrollers.

Method used

A lightweight AI inference model is generated by using a one-dimensional convolutional neural network model, combined with random forest algorithm and model pruning technology. This model is deployed on a microcontroller for localized analysis of spectral data and uploaded to a cloud management platform via LoRa communication unit.

Benefits of technology

It enables real-time monitoring of high-precision water quality parameters on edge devices, reduces data transmission volume, and improves the system's anti-interference capability and monitoring efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120831332A_ABST
    Figure CN120831332A_ABST
Patent Text Reader

Abstract

The invention discloses a spectrum method water quality on-line monitoring method, system and device based on edge calculation, a medium and a product, and relates to the field of water quality monitoring, the method comprises the following steps: training a one-dimensional convolutional neural network model according to a spectrum data set and a corresponding water quality parameter label, and generating a lightweight AI reasoning model adapted to an edge device; the spectral data set comprises an ultraviolet-visible absorption spectrum of the water body; the edge device comprises a microcontroller, an ultraviolet-visible full spectrum sensor and a LoRa communication unit; burning a weight file of the lightweight AI inference model to the microcontroller, and locally analyzing water quality parameters in real time according to the lightweight AI inference model to determine a water quality monitoring result; the water quality monitoring result is uploaded to a cloud management platform through the LoRa communication unit, so that visual monitoring is achieved, the monitoring precision is ensured, meanwhile, the data transmission amount is greatly reduced, and then real-time monitoring in a low-power-consumption environment is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of water quality monitoring, in particular to a spectrum-based water quality online monitoring method, system, device, medium and product based on edge computing. BACKGROUND

[0002] With the advantages of non-destructive, fast response, low energy consumption, etc., optical detection technology has become an important method in the field of water quality monitoring, and has promoted the wide application of ultraviolet absorption spectrum, fluorescence spectrum and other sensors.

[0003] However, limited by hardware cost and power consumption requirements, existing optical sensors usually only collect specific wavelength data and use linear regression models for prediction, which is prone to problems such as weak anti-interference ability and poor generalization.

[0004] In contrast, deep learning can effectively mine the nonlinear features of spectral data, but its huge computing demand is difficult to match the limited resources of microcontrollers. Traditional linear models cannot adapt to the detection needs of complex water bodies, and neural network models are limited by the memory and computing power of micro control units. Therefore, the existing water quality monitoring method cannot meet the requirements of ensuring water quality monitoring accuracy while reducing data transmission. SUMMARY

[0005] The purpose of the present application is to provide a spectrum-based water quality online monitoring method, system, device, medium and product based on edge computing, to solve the problem that it is difficult to meet the requirements of ensuring water quality monitoring accuracy while reducing data transmission.

[0006] To achieve the above purpose, the present application provides the following solutions:

[0007] In a first aspect, the present application provides a spectrum-based water quality online monitoring method based on edge computing, comprising:

[0008] training a one-dimensional convolutional neural network model according to a spectral data set and corresponding water quality parameter labels to generate a lightweight AI inference model adapted to an edge device; the spectral data set includes the ultraviolet-visible absorption spectrum of water; the edge device includes a microcontroller, an ultraviolet-visible full-spectrum sensor and a LoRa communication unit;

[0009] burning the weight file of the lightweight AI inference model to the microcontroller, and real-time localizing and analyzing water quality parameters according to the lightweight AI inference model to determine water quality monitoring results; the water quality parameters include TOC, BOD, COD and nitrate concentration;

[0010] uploading the water quality monitoring results to a cloud management platform through the LoRa communication unit to realize visual monitoring.

[0011] In a second aspect, the present application provides an edge computing-based spectroscopy water quality online monitoring system, comprising:

[0012] The spectral water quality online monitoring system based on edge computing is characterized by including:

[0013] A PC is used to train a one-dimensional convolutional neural network model based on a spectral dataset and corresponding water quality parameter labels to generate a lightweight AI inference model adapted for edge devices; the spectral dataset includes the UV-visible absorption spectrum of water; the edge device includes a microcontroller, a UV-visible full-spectrum sensor, and a LoRa communication unit;

[0014] The system side is used to burn the weight file of the lightweight AI inference model to the microcontroller, and to locally analyze water quality parameters in real time based on the lightweight AI inference model to determine water quality monitoring results; the water quality parameters include TOC, BOD, COD, and nitrate concentration;

[0015] The cloud is used to upload the water quality monitoring results to the cloud management platform through the LoRa communication unit to achieve visual monitoring.

[0016] In a third aspect, the present application provides a computer device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-mentioned edge computing-based spectroscopy-based online water quality monitoring method.

[0017] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned edge computing-based spectroscopy-based online water quality monitoring method.

[0018] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above-mentioned edge computing-based spectroscopy-based online water quality monitoring method.

[0019] According to the specific embodiments provided in this application, this application has the following technical effects:

[0020] The application constructs a lightweight AI inference model suitable for an edge device through a spectral data set and a water quality parameter label, and the weight file, i.e., the parameter file, of the model is burned into a microcontroller of the edge device, so as to realize local analysis of water quality parameters, and based on an ultraviolet-visible full-spectrum sensor of the edge device, the whole process of in-situ acquisition, real-time preprocessing and rapid monitoring of spectral data can be realized on the edge device, and the analyzed water quality monitoring result is uploaded to a cloud management platform through a LoRa communication unit to realize visual monitoring, so as to construct a collaborative monitoring mechanism and form an integrated intelligent monitoring system of 'edge real-time analysis-cloud coordinated management'. Since the LoRa communication unit is a low-power wide-area network, the application can ensure monitoring accuracy while greatly reducing data transmission volume. Since the data transmission volume is reduced, real-time monitoring in a low-power environment is realized. BRIEF DESCRIPTION OF DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0022] Figure 1 A flow chart of a spectral method water quality online monitoring method based on edge computing provided by an embodiment of the present application is provided.

[0023] Figure 2 A PC end, a system end and a cloud data interaction schematic diagram provided by an embodiment of the present application is provided.

[0024] Figure 3 A one-dimensional convolutional neural network model structure schematic diagram provided by an embodiment of the present application is provided.

[0025] Figure 4 A system end and cloud data transmission schematic diagram provided by an embodiment of the present application is provided.

[0026] Figure 5 A structure schematic diagram of a computer device provided by an embodiment of the present application is provided. DETAILED DESCRIPTION

[0027] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0028] In order to make the purposes, characteristics and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in combination with the drawings and specific embodiments.

[0029] As shown in Figure 1 The embodiment of the present application provides a spectrum-based water quality online monitoring method based on edge computing, which comprises the following steps:

[0030] S1: training a one-dimensional convolutional neural network model according to a spectrum data set and a corresponding water quality parameter label, and generating a lightweight artificial intelligence (AI) inference model suitable for an edge device; the spectrum data set comprises ultraviolet-visible absorption spectrum of water body; the edge device comprises a microcontroller, an ultraviolet-visible full spectrum sensor and a long range radio (LoRa) communication unit.

[0031] S2: burning a weight file of the lightweight AI inference model to the microcontroller, and locally resolving water quality parameters in real time according to the lightweight AI inference model to determine a water quality monitoring result; the water quality parameters comprise total organic carbon (TOC), biochemical oxygen demand (BOD), chemical oxygen demand (COD) and nitrate concentration.

[0032] S3: uploading the water quality monitoring result to a cloud management platform through the LoRa communication unit to realize visual monitoring.

[0033] In an exemplary embodiment, an ultraviolet-visible full spectrum sensor (wavelength range 200-800 nm) is used to obtain the absorption spectrum of water body in situ, and water quality parameters such as TOC, BOD, COD and nitrate are determined synchronously as supervised learning labels. The spectrum data and water quality parameter labels are subjected to INT8 integer standardization processing, and S1 can be replaced by the following steps.

[0034] S11: standardizing the spectrum data in the spectrum data set and the water quality parameter label.

[0035] S12: calculating the importance score of the wavelength feature of each standardized spectrum data by using a random forest algorithm, and sorting the importance scores in descending order to generate a wavelength feature sequence.

[0036] S13: optimizing the wavelength feature sequence to determine an optimized feature subset.

[0037] S14: training a one-dimensional convolutional neural network model according to the optimized feature subset and the standardized water quality parameter label, and saving a model weight file after training.

[0038] S15: adjusting the trained model based on a pruning algorithm to determine an adjusted model.

[0039] S16: converting the adjusted model into a lightweight AI inference model suitable for an edge device by using a Neural Network on Microcontroller (NNoM) model conversion tool.

[0040] In an exemplary embodiment, S11 specifically comprises:

[0041] S111: performing standardization processing on the spectral data and the water quality parameter, the absorbance value is usually between 0 and 1, the absorbance needs to be converted from a floating-point number to an integer type in the range of -128-127, specifically, the absorbance of the spectral data is standardized by using Ab' = Round(255*Ab)-128; wherein Ab represents the original absorbance, Ab' represents the standardized absorbance, and the Round() function represents rounding up.

[0042] S112: performing standardization processing on the water quality parameter label by using

[0043] Assuming that the concentration label range is 0-100, when n = 100, the water quality parameter label is standardized by using

[0044] In an exemplary embodiment, S12 specifically comprises:

[0045] S121: constructing a random forest module; the random forest model comprises multiple decision trees.

[0046] S122: calculating the initial performance index of the random forest model based on Bootstrap resampling operation and random selection of feature subset operation.

[0047] S123: re-predicting the performance index of the random forest model according to the wavelength characteristics of each standardized spectral data.

[0048] ​​S124: Calculate the importance score of each standardized spectral data wavelength feature for water quality parameter prediction according to the initial performance indicator and the re-predicted performance indicator, and sort the importance scores in descending order to generate a wavelength feature sequence.

[0049] In practical applications, the recursive feature elimination algorithm based on random forest is used for band optimization, a random forest model composed of multiple decision trees is constructed, the model generalization ability is ensured through Bootstrap resampling and random selection of feature subsets, and the initial performance indicator (such as R 2 or RMSE) of the model is calculated on the validation set. The importance score of each wavelength feature is calculated using the Permutation Importance method: the values of feature F are randomly shuffled (other features remain unchanged), the model performance (such as ) is re-predicted and calculated, and the importance score of the feature F is the difference between the baseline performance and the performance after shuffling. Then enter the iterative optimization phase, in each iteration, first sort all feature bands in descending order of importance score, remove the last 5% (which can be adjusted according to requirements) of low importance bands to form a reduced subset, retrain the random forest model based on the subset and update the feature importance evaluation; the above process is executed in a loop until any of the following termination conditions is met: 1) the number of remaining bands reaches the preset target value; 2) the importance scores of all retained bands exceed the set threshold, and the final output is the feature wavelength combination with the best prediction performance, which significantly improves the operation efficiency while ensuring the model accuracy.

[0050] In practical applications, the importance score of each wavelength feature is calculated using the random forest algorithm, and the features with importance scores lower than the threshold are removed after sorting in descending order, removing redundant and noisy bands, and obtaining the optimized feature subset.

[0051] In an exemplary embodiment, a one-dimensional convolutional neural network is constructed, the number of input layer nodes matches the number of optimized feature wavelengths, and the output layer has 4 nodes corresponding to TOC, BOD, COD, and nitrate concentration. The activation function uses ReLU, and the loss function is weighted mean squared error. After training, the model weight file model.h5 is saved, and S14 specifically includes:

[0052] S141: Based on the TensorFlow-Keras framework, match the number of input layer nodes of the one-dimensional convolutional neural network model with the number of feature wavelengths in the optimized feature subset, match the number of output layer nodes with the standardized water quality parameter labels, and use ReLU activation function and weighted mean squared error loss function to construct and train a one-dimensional convolutional neural network model.

[0053] In practical applications, TensorFlow-Keras framework is adopted to ensure that the model weight file is of the model.h5 type.

[0054] In an exemplary embodiment, based on the pruning algorithm, the removable redundant parts (such as weights) in the network model are identified, and the model fine-tuning parameters are retrained with a small learning rate, S15 specifically comprising:

[0055] S151: Calculate the weight tensor for the output channel of each convolutional layer in the trained model, and take the L1 norm of the weight tensor as the channel importance score.

[0056] S152: According to the channel importance score, arrange all channels in descending order to generate a channel sequence.

[0057] S153: According to the pruning ratio or importance threshold, optimize the channels in the channel sequence to determine the adjusted model.

[0058] In practical applications, the model compression range is adjusted according to the microcontroller memory. The specific implementation process is as follows: first, fully train the original model on the target dataset until convergence; then, based on the L1 norm criterion (calculate the sum of the absolute values of the channel weights of each convolutional layer), evaluate the channel importance and sort it; according to the pre-set pruning ratio or importance threshold, remove the channels with lower contribution; after completing the pruning operation, maintain the dimension matching between network layers, and use a significantly reduced learning rate (such as 10 times reduction) to fine-tune the optimized model, only update the parameters of the newly constructed layers, and freeze other layers to prevent overfitting.

[0059] In practical applications, the NNoM model conversion tool is used to complete the integer quantization from FP32 format to INT8 format, and the Python deep learning model model.h5 file is converted to a C language callable model.h file.

[0060] Design an ultraviolet-visible full-spectrum sensor (resolution 1 nm, integration time 10-100 ms adjustable), namely Figure 4 The edge terminal shown is controlled by an STM32 series microcontroller and has the function of in-situ acquisition of spectral data, and carries a LoRa communication unit (transmission rate 100 kbps). The lightweight AI inference model weight file model.h is burned into the microcontroller storage area, which can realize in-situ acquisition and preprocessing of ultraviolet-visible spectrum.

[0061] The optical sensor is put into the target water body, and the microcontroller performs real-time spectrum acquisition → preprocessing (baseline correction, noise filtering, standardization) → in-situ AI inference → result synchronization to the cloud monitoring platform.

[0062] In practical applications, the optical sensor is mainly composed of a xenon lamp light source module, a flow cell, and a spectrometer, etc. The STM32 microcontroller is used to control the spectrum collection, spectrum preprocessing, and water quality parameter prediction, etc. The microcontroller can be an STM32F103 series, which has low power consumption, low price, and can run efficiently in a resource-limited environment. Before writing the C language weight file model.h, it is necessary to ensure that the microcontroller has enough memory, and to verify the memory compatibility of the converted model in the microcontroller.

[0063] The optical sensor can not only transmit the water quality prediction parameters to the cloud through the LoRa protocol, but also support remote configuration of cloud parameters, such as setting the collection frequency and collection parameters.

[0064] The present application establishes a standardized spectrum-water quality parameter database, uses a deep neural network to realize nonlinear modeling and feature mining of full-spectrum data, and significantly improves the utilization rate of spectral information. The system innovatively combines a random forest feature selection algorithm and a deep model compression technology: first, the random forest is used to optimize the absorption spectrum feature wavelength, and the redundant information is eliminated; then, the network architecture is optimized by channel pruning, and the model parameter amount is compressed. The model is converted into a C language callable header file, and the model parameters are converted from FP32 to INT8 format, and finally the model volume is greatly compressed. The optimized lightweight model can be deployed on an embedded microcontroller after conversion, realizing in-situ collection, real-time preprocessing, and rapid prediction of spectral data. The system builds a collaborative monitoring mechanism through the LoRa low-power wide-area network and the cloud platform, forming an integrated intelligent monitoring system of "edge real-time analysis-cloud collaborative management", which greatly reduces the data transmission amount while ensuring the monitoring accuracy, and provides a high-precision, strong anti-interference intelligent technical solution for water quality monitoring.

[0065] The present application uses ultraviolet-visible full-spectrum sensing technology combined with a multi-task one-dimensional convolutional neural network, which breaks through the limitations of traditional water quality monitoring methods that rely only on specific wavelength detection and linear regression analysis. Through deep nonlinear feature extraction and modeling of full-band (200-800nm) spectral data, high-precision synchronous prediction of TOC, BOD, COD, and nitrate and other key water quality parameters is realized, which significantly improves the anti-interference performance and detection reliability of the system in complex water environments such as high turbidity and coexistence of multiple pollutants.

[0066] The application compresses the deep learning model to a size that can be borne by a microcontroller through feature wavelength selection, model pruning and parameter integer quantization technology, and deploys it in an STM32F103 series microcontroller to realize the localization of real-time inference of water quality parameters in a resource-limited edge computing environment. The technical solution directly completes intelligent analysis and prediction of water quality parameters at the end of the spectral sensor, greatly reducing data transmission delay and dependence on cloud computing. At the same time, with the help of the bidirectional data transmission capability of the LoRa protocol, it has the functions of remote parameter configuration and dynamic model updating, balancing the real-time advantage of edge computing and the scalability requirement of cloud management, providing an innovative solution for long-term unattended monitoring of distributed water bodies such as rivers and lakes.

[0067] Based on the same inventive concept, the embodiments of the application also provide a spectral water quality online monitoring system based on edge computing. The implementation scheme for solving the problem provided by the system is similar to the implementation scheme described in the above method, so the specific limitations in one or more spectral water quality online monitoring system embodiments based on edge computing provided below can refer to the limitations of the spectral water quality online monitoring method based on edge computing in the above, which will not be repeated here.

[0068] In one exemplary embodiment, a spectral water quality online monitoring system based on edge computing is provided, comprising:

[0069] A PC end is configured to train a one-dimensional convolutional neural network model according to a spectral data set and corresponding water quality parameter labels, and generate a lightweight AI inference model adapted to an edge device; the spectral data set includes ultraviolet-visible absorption spectra of a water body; the edge device includes a microcontroller, an ultraviolet-visible full-spectrum sensor, and a LoRa communication unit;

[0070] A system end is configured to burn a weight file of the lightweight AI inference model to the microcontroller, and locally analyze water quality parameters in real time according to the lightweight AI inference model to determine a water quality monitoring result; the water quality parameters include TOC, BOD, COD, and nitrate concentration;

[0071] A cloud end is configured to upload the water quality monitoring result to a cloud management platform through the LoRa communication unit to realize visual monitoring.

[0072] The PC end, the system end, and the cloud end data interaction process is as follows Figure 2As shown, the PC end: standardize the ultraviolet-visible absorption spectrum and the corresponding water quality parameter label, apply the random forest algorithm for feature wavelength screening, train a one-dimensional convolutional neural network model based on the spectral data set and the water quality parameter label, optimize the network structure through channel pruning algorithm, convert the model parameters from FP32 to INT8 format based on the NNoM tool chain, and finally generate a lightweight AI inference model suitable for edge devices;

[0073] The PC end specifically includes:

[0074] The data standardization unit: standardizes the original spectral data and water quality parameters, and linearly maps the data to 8-bit integer data format in the interval [-128, 127] to adapt to the microcontroller fixed-point operation architecture.

[0075] The feature selection unit: uses the recursive feature elimination (RFE) method based on random forest for feature optimization. First, a random forest regression model is constructed, and Bootstrap sampling and random feature subset selection are used to ensure model diversity. The feature importance evaluation uses the permutation importance method: after calculating the benchmark performance (R 2 or RMSE) on the validation set, the order of the value of feature F is randomly shuffled (other features remain unchanged), the performance is recalculated, and the difference between the benchmark performance and the performance after shuffling is used as the importance score of feature F. Then, iterative feature selection is performed: in each round, the last 5% of low-contribution features are removed according to the importance ranking, the model is retrained with the remaining features, and the evaluation process is repeated. This iteration continues until the number of remaining features reaches the preset threshold or all feature importance exceeds the set standard, and the optimal feature subset is finally obtained.

[0076] The structured channel pruning method is used to compress and optimize the convolutional neural network model: the specific implementation process is as follows: first, train the original model on the target data set until convergence; then, based on the L1 norm criterion (calculate the sum of the absolute values of the convolution layer channel weights), evaluate the channel importance and sort them; remove the channels with lower contribution according to the preset pruning ratio or importance threshold; after pruning, fine-tune the optimized model with a significantly reduced learning rate.

[0077] The model conversion unit: converts the neural network model file in model.h5 format trained by the TensorFlow framework into a C language callable header file model.h, and converts the model parameters from FP32 to INT8 format, which is compatible with the ARM CMSIS-NN acceleration library for deployment.

[0078] System end, i.e. edge terminal: including microcontroller, ultraviolet-visible full-spectrum sensor and LoRa communication unit, realizing functions of real-time spectrum data acquisition, preprocessing, local AI inference and multi-parameter synchronous analysis;

[0079] The system end specifically includes:

[0080] Hardware configuration unit: using STM32F103 series microcontroller as core processor, responsible for control of optical sensor and communication module.

[0081] Multi-parameter prediction unit: realizing synchronous prediction of TOC, BOD, COD and nitrate concentration through optimized lightweight model.

[0082] Low-power transmission unit: uploading abnormal monitoring data to cloud through LoRa protocol, and transmitting basic data package once an hour under normal condition.

[0083] Cloud: receiving and storing water quality monitoring data uploaded by each edge terminal, and providing visual monitoring interface and remote device management service.

[0084] It can be seen that the spectrum-based water quality online monitoring system based on edge computing provided by the application mainly includes PC end, system end and cloud end, wherein the PC end performs data set construction, Python neural network model training, model compression, transformation and system deployment tasks. After deployment, the optical sensor system end can perform in-situ real-time prediction of water quality multi-parameters in complex water environment, and the results can be transmitted to the cloud management platform. The main steps are as follows:

[0085] 1) Collecting actual water sample, using optical sensor with spectrum data acquisition and storage function to obtain water absorption spectrum information, synchronously measuring water quality parameters such as TOC, BOD, COD and nitrate, and determining the distribution range of spectrum data and water quality parameters, and standardizing these data to convert them into integer values in the interval [-258, -257]. For example, the TOC solution concentration label range is 0-100 mg / L, and the conversion format is as follows:

[0086]

[0087] Among them, TOC represents solution concentration, TOC' represents concentration standardized value, and Round() function represents rounding up.

[0088] 2) Using recursive feature elimination algorithm based on random forest for spectrum band optimization: first, a random forest model composed of multiple decision trees is constructed, and Bootstrap resampling and random selection of feature subsets are used to ensure model generalization ability, and initial performance indicators (such as or RMSE base). The importance score of each feature wavelength is calculated using the Permutation Importance method: randomly shuffle the values of feature F (while keeping other features unchanged), re-predict and calculate the model performance (such as ), and the importance score of feature F is calculated as follows.

[0089]

[0090] The feature importance score of each absorption wavelength for water quality parameter prediction is calculated. The greater the influence of the feature wavelength on the prediction effect, the higher the feature importance score. Then, enter the iterative optimization phase. In each iteration, first sort all wavebands in descending order of importance score, and perform feature selection according to the pre-set model compression requirements (such as removing the last 5% of low importance wavebands). Re-train the model based on the remaining waveband subset and update the importance evaluation. This process is repeated until the termination condition is met (the number of remaining wavebands meets the standard or the importance of all wavebands exceeds the threshold), and the optimal feature wavelength combination is finally output.

[0091] 3) Use the absorption spectrum data and water quality parameters as training samples and labels, respectively, to construct the dataset. Based on the TensorFlow-Keras framework, a one-dimensional convolutional neural network model is built, with the number of input layer nodes matching the number of optimized feature wavelengths, and the output layer having 4 nodes corresponding to the standardized TOC, BOD, COD, and nitrate concentrations. The ReLU activation function and weighted mean square error loss function are used. The model structure is as shown in Figure 3 After training, the model weight file is saved in the model.h5 format.

[0092] 4) Based on the pruning algorithm, identify the removable redundant parts (such as weights) in the one-dimensional convolutional neural network model: first, fully train the original model on the target dataset until convergence; calculate the L1 norm of the weight tensor for each output channel of the convolutional layer as the channel importance score, as follows.

[0093]

[0094] where W c,k,i represents the convolution kernel weight of the cth output channel to the kth input channel, and i is the spatial dimension index (one-dimensional convolution kernel); sort all channels in descending order of importance, and remove channels with low contribution according to the pre-set pruning ratio or importance threshold; after pruning, maintain the dimension matching between network layers, and fine-tune the simplified model using a significantly reduced learning rate (such as 10 times reduction), only updating the parameters of the newly constructed layers, and freezing other layers to prevent overfitting.

[0095] 5) Using the NNoM tool chain, the model.h5 model is converted into a C language callable model.h file, and FP32 to INT8 integer quantization is implemented. The converted weight file describes the parameters of each layer of the network through macro definition.

[0096] 6) Design a customized ultraviolet-visible spectrometer (resolution 1 nm, integration time 10-100 ms adjustable), integrating a xenon lamp light source, a quartz flow cell, a small spectrometer, and an STM32F103 main control module, which can perform in-situ spectral acquisition, preprocessing, and storage functions. The lightweight model model.h is burned into the Flash storage area of the STM32F103 microcontroller. The microcontroller connects the LoRa communication module (transmission rate 100 kbps) through the SPI interface, supporting duplex communication of data reporting and instruction receiving. Figure 4 The structure of the optical sensor (i.e., the edge terminal shown in the system end) and the cloud interaction process are shown.

[0097] The deployed optical sensor is put into the target water body, and the microcontroller performs spectral acquisition, spectral preprocessing, and localized AI inference at a predetermined period. The embedded model synchronously outputs four water quality parameters, and the prediction results are uploaded to the cloud monitoring platform through the LoRa module to realize visual monitoring and remote parameter configuration.

[0098] The present application solves the problems of low spectral feature utilization and weak environmental anti-interference ability in traditional in-situ monitoring methods through the cooperative optimization of lightweight AI inference model and embedded device.

[0099] In one exemplary embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method embodiments when executing the computer program. The computer device can be a server or a terminal, and its internal structure diagram can be as follows Figure 5As shown in the figure. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through the system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data to be processed. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with the terminal outside through the network connection. The computer program is executed by the processor to realize a spectrum method water quality online monitoring method based on edge computing.

[0100] Those skilled in the art can understand that, Figure 5 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement. In one exemplary embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to realize the steps in each of the method embodiments described above.

[0101] In one exemplary embodiment, a computer readable storage medium is provided, storing a computer program, which is executed by a processor to realize the steps in each of the method embodiments described above.

[0102] In one exemplary embodiment, a computer program product is provided, including a computer program, which is executed by a processor to realize the steps in each of the method embodiments described above.

[0103] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant regulations.

[0104] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, databases or other media used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0105] The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a blockchain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.

[0106] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described, but as long as the combinations of the technical features do not exist, they should be considered as the scope of the present application.

[0107] The principles and implementation modes of the present application are described by applying specific examples herein. The above description of the embodiments is only used to help understand the method and its core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range can be changed. In conclusion, the content of the present application should not be understood as a limitation.

Claims

1. An edge-computing-based online monitoring method for water quality by spectroscopy, characterized in that, The application relates to a water quality monitoring method based on light spectrum data, and belongs to the technical field of water quality monitoring. The application comprises the following steps: training a one-dimensional convolutional neural network model according to a spectrum data set and corresponding water quality parameter labels to generate a lightweight AI inference model suitable for an edge device; the spectrum data set comprises ultraviolet-visible absorption spectra of a water body; the edge device comprises a microcontroller, an ultraviolet-visible full-spectrum sensor and a LoRa communication unit; burning a weight file of the lightweight AI inference model to the microcontroller and locally analyzing water quality parameters in real time according to the lightweight AI inference model to determine a water quality monitoring result; the water quality parameters comprise TOC, BOD, COD and nitrate concentration; 2.The edge computing based online monitoring method of water quality by spectrometry according to claim 1, characterized in that, uploading the water quality monitoring result to a cloud management platform through the LoRa communication unit to realize visual monitoring. The application comprises the following steps: standardizing spectrum data in the spectrum data set and the water quality parameter labels; calculating importance scores of wavelength features of each standardized spectrum data by using a random forest algorithm, and sorting the importance scores in descending order to generate a wavelength feature sequence; optimizing the wavelength feature sequence to determine an optimized feature subset; training a one-dimensional convolutional neural network model according to the optimized feature subset and the standardized water quality parameter labels, and saving a model weight file after training; adjusting the trained model based on a pruning algorithm to determine an adjusted model; 3. The method for online water quality monitoring based on spectroscopy using edge computing according to claim 2, characterized in that: converting the adjusted model into a lightweight AI inference model suitable for the edge device by using an NNoM model conversion tool. The application comprises the following steps: Utilizing standardizing the water quality parameter label; wherein, SZ' represents the standardized water quality parameter label, SZ represents the original water quality parameter label, and n is the concentration label range. 4.The edge computing based online monitoring method of water quality by spectrometry according to claim 2, characterized in that, standardizing absorbance of the spectrum data by using Ab'=Round(255*Ab)-128; wherein Ab represents original absorbance, Ab' represents standardized absorbance, and the Round() function represents rounding up; calculating importance scores of wavelength features of each standardized spectrum data by using a random forest algorithm, and sorting the importance scores in descending order to generate a wavelength feature sequence, which comprises the following steps: constructing a random forest module; the random forest model comprises multiple decision trees; calculating initial performance indexes of the random forest model based on Bootstrap resampling operation and random selection of a feature subset operation; re-predicting the performance indexes of the random forest model according to wavelength features of each standardized spectrum data; 5.The edge computing based online monitoring method of water quality by spectrometry according to claim 2, characterized in that, calculating importance scores of wavelength features of each standardized spectrum data for water quality parameter prediction according to the initial performance indexes and the re-predicted performance indexes, and sorting the importance scores in descending order to generate a wavelength feature sequence. training a one-dimensional convolutional neural network model according to the optimized feature subset and the standardized water quality parameter labels, which comprises the following steps: Based on the TensorFlow-Keras framework, the number of input layer nodes of the one-dimensional convolutional neural network model is matched with the number of characteristic wavelengths in the optimized feature subset, the output layer nodes are corresponded to the standardized water quality parameter labels, and the ReLU activation function and weighted mean square error loss function are used to construct and train the one-dimensional convolutional neural network model. 6.The edge computing based online monitoring method of water quality by spectrometry according to claim 2, characterized in that, Adjusting the trained model based on the pruning algorithm to determine the adjusted model specifically includes: Calculating a weight tensor for the output channel of each convolutional layer in the trained model, and using the L1 norm of the weight tensor as a channel importance score; Arrange all channels in descending order according to the channel importance scores to generate a channel sequence; The channels in the channel sequence are optimized according to the pruning ratio or the importance threshold, and an adjusted model is determined.

7. An edge computing based online monitoring system for water quality by spectroscopy, characterized in that, include: A PC is used to train a one-dimensional convolutional neural network model based on a spectral dataset and corresponding water quality parameter labels to generate a lightweight AI inference model adapted for edge devices; the spectral dataset includes the UV-visible absorption spectrum of water; the edge device includes a microcontroller, a UV-visible full-spectrum sensor, and a LoRa communication unit; The system side is used to burn the weight file of the lightweight AI inference model to the microcontroller, and to locally analyze water quality parameters in real time based on the lightweight AI inference model to determine water quality monitoring results; the water quality parameters include TOC, BOD, COD, and nitrate concentration; The cloud is used to upload the water quality monitoring results to the cloud management platform through the LoRa communication unit to achieve visual monitoring.

8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the edge computing-based spectroscopy online water quality monitoring method according to any one of claims 1 to 6.

9. A computer-readable storage medium having stored thereon a computer program, characterized in that, When the computer program is executed by a processor, the method for online water quality monitoring based on spectroscopy using edge computing according to any one of claims 1 to 6 is implemented.

10. A computer program product comprising a computer program, characterized in that, When the computer program is executed by a processor, the method for online water quality monitoring based on spectroscopy using edge computing according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Emergency position indicating transmitter false triggering prevention method and system based on multi-sensor fusion

    CN121999588A