Deep neural network-based water quality detection method for edge equipment

By deploying deep neural networks on edge devices, combined with improved loss functions and data enhancement strategies, the problem of rapid and comprehensive water quality monitoring of freshwater resources is solved, and rapid screening of water sample quality and accurate prediction of water quality indicators are achieved.

CN118608916APending Publication Date: 2024-09-06ANHUI SURVEY & DESIGN INST OF WATER CONSERVANCY & HYDROPOWER
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410641231.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing technology cannot quickly and comprehensively monitor the water quality of freshwater resources that are scattered in spatial distribution.

Method used

A deep neural network-based water quality detection method for edge devices is adopted to detect water quality through pre-built neural network models, including backbone network, neck network, suspended matter detection network and water quality prediction network, using improved cosine similarity regression Loss functions and data enhancement strategies enable rapid screening of water sample images and prediction of water quality indicators.

Benefits of technology

It achieves rapid and comprehensive monitoring of the quality of freshwater resources, outputs the location of suspended solids and related information, water quality score evaluation and key indicators, helping experimenters quickly discover and locate quality problems in water samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118608916A
    Figure CN118608916A
Patent Text Reader

Abstract

The invention provides a deep neural network-based water quality detection method for edge equipment, and relates to the technical field of water quality detection.According to the water quality detection method, water quality is detected through a pre-constructed neural network model, and the neural network model comprises a backbone network, a neck network, a suspended matter detection network and a water quality prediction network; wherein the output of the backbone network is input into the neck network, the output of the neck network is respectively input into the suspended matter detection network and the water quality prediction network, and the computer vision technology is deployed on edge equipment to complete the rapid screening of the quality of a water sample. The predicted water sample suspended matter position and related information, water quality score evaluation, water quality key attention indexes and other information are output, an experimenter is helped to rapidly find and locate the quality problem of the water sample, and the technical problem that in the prior art, water quality monitoring cannot be rapidly and comprehensively conducted on fresh water resources in a scattered state in spatial distribution is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of water quality detection, and in particular to a water quality detection method based on a deep neural network for edge devices. Background Art

[0002] Water resources, especially fresh water resources, as the basis of life, have always been a necessary condition for the survival of all kinds of life, including human beings. The health of water quality also directly affects the life safety of all kinds of life.

[0003] With the rapid development of the global economy, various types of pollution, including water pollution and air pollution, are becoming increasingly serious, and water quality safety is also changing rapidly. Based on China's geographical features, freshwater resources are scattered in spatial distribution. In view of this, how to quickly and comprehensively monitor the water quality of these freshwater resources has become an urgent problem to be solved. Summary of the invention

[0004] 1. Technical issues to be resolved

[0005] In view of the shortcomings of the prior art, the present invention provides a water quality detection method based on deep neural network for edge devices, which solves the technical problem that the prior art cannot quickly and comprehensively realize water quality monitoring of freshwater resources that are scattered in spatial distribution.

[0006] (II) Technical solution

[0007] To achieve the above objectives, the present invention is implemented through the following technical solutions:

[0008] In a first aspect, the present invention provides a water quality detection method based on a deep neural network for edge devices, wherein the water quality detection method detects water quality through a pre-built neural network model, wherein the neural network model includes a backbone network, a neck network, a suspended matter detection network, and a water quality prediction network, wherein the output of the backbone network is input into the neck network, and the output of the neck network is respectively input into the suspended matter detection network and the water quality prediction network; the water quality detection method includes:

[0009] Acquire a water sample image to be detected;

[0010] The water sample image to be detected is processed based on a preset neural network model, and the suspended matter detection network outputs category information and location information of the suspended matter present in the water body image sample; the water quality prediction network outputs the water quality prediction score and the prediction value of the key indicators.

[0011] Preferably, the construction of the neural network model includes:

[0012] Obtain a certain amount of water sample images, and randomly annotate the obtained water sample images in proportion. All the unannotated images and 90% of the annotated images are used as training sets, and the remaining 10% of the annotated images are used as validation sets.

[0013] The training set is input into the neural network model for model training and model parameter tuning, and the trained neural network model is saved;

[0014] Among them, the water quality score regression loss and the regression loss of the key indicators in the water quality prediction network both adopt the improved cosine similarity regression loss measurement function:

[0015] Let G∈R N*1 represents the original true annotation, let P∈R N*1 Represents the predicted value of the indicator directly output by the model, then the cosine similarity loss is L cs_reg =1-CosSim(G*G T ,P*P T );

[0016] Where N represents the number of indicators to be detected, CosSim represents the cosine similarity function, * represents matrix multiplication, and T represents matrix transposition.

[0017] Preferably, before inputting the training set into the neural network model, the water quality detection method further comprises:

[0018] For any labeled image in the training set, the enhanced sample set x is obtained by using the strong data enhancement strategy A l ;

[0019] Preferably, any annotated image in the training set is input into the neural network model for model training and model parameter tuning, including: the enhanced sample set x l Extract multi-scale image features of water images through backbone network

[0020] Among them, I represents the number of multi-scale features;

[0021] The F l The mixed feature f is obtained by fusing multi-scale features through the neck network l ;

[0022] The suspended matter detection network and the water quality prediction network receive the mixed feature f l ;

[0023] The suspended matter detection network outputs the category information and location information of the suspended matter in the water image sample, and calculates the classification loss L with the annotated true value information. cls and position regression loss Lreg ;

[0024] The water quality prediction network will output the water quality prediction score and the predicted value of the key indicators, and calculate the water quality score regression loss respectively with the annotated true value information Focus on the regression loss of the indicator

[0025]

[0026] Among them, j represents the jth water quality index;

[0027] After completing the calculation of each loss, the final loss L of the labeled data in the training set is obtained by summing up the loss functions. l ;

[0028]

[0029] And through the final loss L of the labeled data l The parameters of the annotated suspended matter detection network and water quality prediction network are updated respectively.

[0030] Preferably, before inputting the training set into the neural network model, the water quality detection method further comprises:

[0031] For any unlabeled image x in the training set u The strong data enhancement sample set is obtained by strong and weak data enhancement respectively. With weak data enhancement sample set

[0032] Among them, strong data enhancement adopts strong data enhancement strategy A.

[0033] Preferably, any unlabeled image x in the training set u Input into the neural network model for model training and model parameter tuning, including:

[0034] The weak data enhancement sample set The enhanced sample set is obtained through the backbone network and the neck network in turn. The corresponding mixed features are respectively input into the suspended matter detection branch to obtain the classification information and location information of the suspended matter, and the water quality prediction branch to obtain the water quality score and the predicted values ​​of each key indicator, and used as the strong data enhancement sample set Pseudo labels of

[0035] Among them, the strong data enhancement sample set The weak data enhancement sample set is obtained through the backbone network and the neck network in turn. The corresponding mixed features are further input into the suspended matter detection network and the water quality prediction network to obtain the corresponding prediction results. The prediction results are respectively combined with the category information and location information of the suspended matter to calculate the classification loss. With position regression loss Calculation of water quality scores and key indicator prediction values and

[0036]

[0037] Finally, we will get the final loss of unlabeled data And through the final loss L of the unlabeled data u Update the parameters of the unlabeled suspended matter detection network and water quality prediction network respectively;

[0038] Combining the two parts of the loss function, we get L = L l +λL u , the stochastic gradient descent method is used to tune the parameters of L;

[0039] Among them, λ is a constant term, which is used to control the intensity of unlabeled data on the overall training of the model.

[0040] Preferably, the ratio of the obtained annotated image to the unannotated image is 1:100.

[0041] Preferably, the strong data enhancement strategy A includes at least one of the following:

[0042] Sensor noise simulation based on OPENCV;

[0043] Motion blur simulation;

[0044] Simulation of lighting environment changes based on HSV color space;

[0045] Random cropping strategy, let {x1, y1, x2, y2} represent the upper left corner coordinates and lower right corner coordinates of the bounding box of the suspended object, let Δ∈[0,H] be a random value, then the cropping area is represented as: {x1-Δ, y1-Δ, x2+Δ, y2+Δ};

[0046] For image samples without suspended objects, random cropping is performed;

[0047] Where H is the length or width of the image.

[0048] In a second aspect, the present invention provides a computer-readable storage medium storing a computer program for water quality detection based on a deep neural network, wherein the computer program enables a computer to execute a water quality detection method based on a deep neural network.

[0049] In a third aspect, the present invention provides an electronic device, comprising:

[0050] One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the programs include a method for performing water quality detection based on a deep neural network.

[0051] (III) Beneficial effects

[0052] The present invention provides a water quality detection method based on deep neural network for edge devices. Compared with the prior art, it has the following beneficial effects:

[0053] The present invention deploys computer vision technology on edge devices to complete rapid screening of water sample quality, and outputs predicted water sample suspended matter locations and related information, water quality score evaluation, water quality key indicators and other information, to help experimenters quickly discover and locate water sample quality problems, and solve the technical problem that existing technologies cannot quickly and comprehensively realize water quality monitoring of freshwater resources that are scattered in spatial distribution. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0055] Figure 1 This is a flow chart of a water quality detection method based on a deep neural network for edge devices according to an embodiment of the present invention;

[0056] Figure 2 This is a flow chart of a water quality detection method based on a deep neural network for edge devices according to an embodiment of the present invention. DETAILED DESCRIPTION

[0057] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention are clearly and completely described. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0058] The embodiments of the present application provide a water quality detection method based on a deep neural network for edge devices, thereby solving the technical problem that the prior art cannot quickly and comprehensively monitor the water quality of freshwater resources that are scattered in spatial distribution, thereby achieving rapid and comprehensive monitoring of water quality.

[0059] The technical solution in the embodiment of the present application is to solve the above technical problems, and the overall idea is as follows:

[0060] By deploying computer vision technology on edge devices to quickly screen the quality of water samples, the system can output the predicted location of suspended matter in water samples and related information, water quality score evaluation, key water quality indicators, and other information. This helps experimenters quickly discover and locate quality problems in water samples, solving the technical problem that existing technologies cannot quickly and comprehensively monitor the water quality of freshwater resources that are scattered in spatial distribution.

[0061] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0062] The embodiment of the present invention provides a water quality detection method based on a deep neural network for edge devices, such as Figure 2 As shown, the water quality detection method detects water quality through a pre-built neural network model, and the neural network model includes a backbone network, a neck network, a suspended matter detection network and a water quality prediction network, wherein the output of the backbone network is input into the neck network, and the output of the neck network is respectively input into the suspended matter detection network and the water quality prediction network; the water quality detection method includes:

[0063] S1: Acquire the water sample image to be detected;

[0064] S2: The water sample image to be detected is processed based on a preset neural network model, and the suspended matter detection network outputs the category information and location information of the suspended matter in the water body image sample; the water quality prediction network outputs the water quality prediction score and the prediction value of the key indicators.

[0065] By deploying computer vision technology on edge devices to quickly screen the quality of water samples, the system can output the predicted location of suspended matter in water samples and related information, water quality score evaluation, key water quality indicators, and other information. This helps experimenters quickly discover and locate quality problems in water samples, solving the technical problem that existing technologies cannot quickly and comprehensively monitor the water quality of freshwater resources that are scattered in spatial distribution.

[0066] Specifically, the water sample image in step S1 can be directly captured from the water area to be detected or from the collected sample as needed. The water sample image can be acquired by any imaging device, which can be an ordinary RGB camera, a fisheye camera, etc.

[0067] Specifically, in step S2, the water sample image to be detected is processed based on a preset neural network model, and the suspended matter detection network outputs the category information and location information of the suspended matter in the water image sample; the water quality prediction network outputs the water quality prediction score and the prediction value of the key indicators. The specific implementation process is as follows:

[0068] Among them, the pre-built neural network model construction process is as follows Figure 1 As shown, including:

[0069] S21: obtaining a certain amount of water sample images, and randomly annotating the obtained water sample images in proportion, obtaining all unannotated images and 90% of the annotated images as a training set, and the remaining 10% of the annotated images as a verification set;

[0070] S22: inputting the training set into the neural network model to perform model training and model parameter tuning, and saving the trained neural network model;

[0071] Among them, the water quality score regression loss and the regression loss of the key indicators in the water quality prediction network both adopt the improved cosine similarity regression loss measurement function:

[0072] Let G∈R N*1 represents the original true annotation, let P∈R N*1 Represents the predicted value of the indicator directly output by the model, then the cosine similarity loss is L cs_reg =1-CosSim(G*G T , P*P T );

[0073] In the formula, N represents the number of indicators to be detected, CosSim represents the cosine similarity function, * represents matrix multiplication, and T represents matrix transposition;

[0074] The traditional regression loss directly measures the differences between single indicators and lacks the measurement of the correlation between water qualities. Secondly, the traditional regression loss will be normalized with the sigmoid activation function to avoid the influence of the measurement unit, but this forced normalization also causes the characteristics of each indicator itself to be smoothed to a certain extent.

[0075] The present invention takes into account the natural correlation between water quality indicators that is difficult to model. Therefore, the present invention sets an improved cosine similarity loss function, which firstly supplements the insensitivity of the traditional regression function based on measuring Euclidean distance in measurement, and secondly, expands the single water quality indicator to R N*N In the space, we fully consider the implicit relationship between different water qualities and improve the effect of water quality detection.

[0076] The classification loss of the suspended matter category information adopts the focal-loss loss measurement function;

[0077] Wherein, in step S21, the ratio of the obtained annotated image to the unannotated image is 1:100.

[0078] Specifically, in step S21, before inputting the training set into the neural network model, the water quality detection method further includes:

[0079] For any labeled image in the training set, the enhanced sample set x is obtained by using the strong data enhancement strategy A l ;

[0080] The strong data enhancement strategy A includes at least one of the following:

[0081] Sensor noise simulation based on OPENCV;

[0082] Motion blur simulation;

[0083] Simulation of lighting environment changes based on HSV color space;

[0084] Random cropping strategy, let {x1, y1, x2, y2} represent the upper left corner coordinates and lower right corner coordinates of the bounding box of the suspended object, let Δ∈[0,H] be a random value, then the cropping area is represented as: {x1-Δ, y1-Δ, x2+Δ, y2+Δ};

[0085] For image samples without suspended objects, random cropping is performed;

[0086] Where H is the length or width of the image.

[0087] The data enhancement strategy A plays a role in increasing the generalization of data during the training process of the model. For the water quality detection task, considering that the water body itself generally appears as a uniform background in the water sample image, the data enhancement strategy A described in this method will also include a random cropping strategy, which uses the random cropping strategy to alleviate the problem of redundant background information and lack of foreground information in the image.

[0088] After the training set has been subjected to data enhancement strategy A, step S22 is executed, where any annotated image in the training set is input into the neural network model for model training and model parameter tuning, specifically including the following steps:

[0089] S221: the enhanced sample set x l Extract multi-scale image features of water images through backbone network

[0090] Among them, I represents the number of multi-scale features;

[0091] S222: The F l The mixed feature f is obtained by fusing multi-scale features through the neck network l ;

[0092] S223: The suspended matter detection network and the water quality prediction network receive the mixed feature f l ;

[0093] S224: The suspended matter detection network outputs the category information and location information of the suspended matter in the water body image sample, and calculates the classification loss L with the annotated true value information respectively. cls and position regression loss L reg The water quality prediction network will output the water quality prediction score and the predicted value of the key indicators, and calculate the water quality score regression loss with the annotated true value information. Focus on the regression loss of the indicator

[0094]

[0095] Among them, j represents the jth water quality index;

[0096] S225: After completing the calculation of each loss, the final loss L of the labeled data in the training set is obtained by summing up the loss functions. l ;

[0097]

[0098] S226: and the final loss L of the labeled data l The parameters of the annotated suspended matter detection network and water quality prediction network are updated respectively.

[0099] Wherein, in step S21, before inputting the training set into the neural network model, the water quality detection method further includes:

[0100] For any unlabeled image x in the training set u The strong data enhancement sample set is obtained by strong and weak data enhancement respectively. With weak data enhancement sample set

[0101] Among them, strong data enhancement adopts strong data enhancement strategy A;

[0102] When any labeled image in the training set is input into the neural network model for model training and model parameter tuning, step S22 is executed to convert any unlabeled image x in the training set into u Input into the neural network model for model training and model parameter tuning, specifically including:

[0103] The weak data enhancement sample set The enhanced sample set is obtained through the backbone network and the neck network in turn. The corresponding mixed features are respectively input into the suspended matter detection branch to obtain the classification information and location information of the suspended matter, and the water quality prediction branch to obtain the water quality score and the predicted values ​​of each key indicator, and used as the strong data enhancement sample set Pseudo labels, that is, let the neural network model label these unlabeled samples;

[0104] Among them, the strong data enhancement sample set The weak data enhancement sample set is obtained through the backbone network and the neck network in turn. The corresponding mixed features are further input into the suspended matter detection network and the water quality prediction network to obtain the corresponding prediction results. The prediction results are respectively combined with the category information and location information of the suspended matter to calculate the classification loss. With position regression loss Calculation of water quality scores and key indicator prediction values and

[0105]

[0106] Finally, we will get the final loss of unlabeled data And through the final loss L of the unlabeled data u Update the parameters of the unlabeled suspended matter detection network and water quality prediction network respectively;

[0107] Combining the two parts of the loss function, we get L = L l +λL u , the stochastic gradient descent method is used to tune the parameters of L;

[0108] Among them, λ is a constant term, which is used to control the intensity of unlabeled data on the overall training of the model.

[0109] The implementation of this solution will first rely on small batch data annotation based on expert knowledge. That is, for each water sample image, we need data indicators of key factors in the water sample. These indicators can be changed according to specific needs. The present invention adopts a semi-supervised training method to realize an automatic annotation framework for unlabeled data and low-cost training without strong data dependence, thereby improving the efficiency of model training.

[0110] It should be noted that the present invention includes two model branches. During the training stage, the labeled images and the unlabeled images with strong data enhancement will output corresponding prediction values ​​through the student branch, while the unlabeled data with weak data enhancement will pass through the teacher branch to obtain the pseudo-labels corresponding to the unlabeled images, and the pseudo-labels will be used to supervise the corresponding unlabeled images in the student branch.

[0111] After completing the training of the model, the teacher branch of the model will be discarded, and an image sample of any water sample will be input into the model. The mixed depth features of the image sample will be obtained through the backbone network and neck network modules of the student branch network respectively. Then, the features will be simultaneously input into the suspended matter detection network and the water quality prediction network to obtain the category information of the suspended matter in the water sample image, the location information of the suspended matter, the water quality score, and the predicted value information of the key water quality indicators.

[0112] The backbone network, neck network, suspended matter detection network and water quality prediction network have the following specific functions:

[0113] Backbone network: used to extract deep features of image samples. The deep features of images contain strong semantic representation information, but due to their low resolution, the deep features have weak representation capabilities of geometric details. The application field of this solution belongs to fine-grained image tasks, so this solution will further extract multi-scale features of images. These feature maps will provide more refined detail features and contain rich contextual information to help identify fuzzy, small or overlapping difficult target features. For the choice of backbone network, you can choose multi-scale feature extraction networks such as CSPNet, ResNet, MobileNet, etc.

[0114] Neck network: It is mainly used for multi-scale feature fusion. By fusing the multi-scale feature network extracted by the backbone network into a hybrid feature, the feature representation capability is enhanced while greatly reducing the amount of calculation. Multi-scale feature fusion networks such as FPN network and PAN network can be selected.

[0115] Suspended matter detection network: Any convolutional neural network can be selected to output the location and category information of suspended matter.

[0116] Water quality prediction network: Any convolutional neural network can be selected to output the score information of water quality status and the prediction information of key water quality indicators.

[0117] The present invention also provides a computer-readable storage medium that stores a computer program for water quality detection based on a deep neural network, wherein the computer program enables a computer to execute the above-mentioned water quality detection method based on a deep neural network.

[0118] The present invention also provides an electronic device, including:

[0119] One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the programs include programs for performing the water quality detection based on the deep neural network as described above.

[0120] In summary, compared with the prior art, the present invention has the following beneficial effects:

[0121] 1. The present invention deploys computer vision technology on edge devices to complete rapid screening of water sample quality, outputs predicted water sample suspended matter location and related information, water quality score evaluation, water quality key indicators and other information, to help experimenters quickly discover and locate water sample quality problems, and solves the technical problem that existing technologies cannot quickly and comprehensively realize water quality monitoring of freshwater resources that are scattered in spatial distribution.

[0122] 2. The embodiment of the present invention takes into account that there is a natural correlation between water quality indicators that is difficult to model. Therefore, the present invention sets an improved cosine similarity loss function, which firstly supplements the insensitivity of the traditional regression function based on measuring Euclidean distance in measurement, and secondly, expands a single water quality indicator to R N*N In the space, we fully consider the implicit relationship between different water qualities and improve the effect of water quality detection.

[0123] 3. The embodiment of the present invention takes into account that the water body itself generally appears as a uniform background in the water sample image. Therefore, the data enhancement strategy A described in this method will also include a random cropping strategy, which uses the random cropping strategy to alleviate the problem of redundant background information and lack of foreground information in the image.

[0124] 4. The implementation of the embodiment of this scheme will first rely on small batch data annotation of expert knowledge, that is, for each water sample image, we need data indicators of key factors in the water sample. These indicators can be changed according to specific needs. The present invention adopts a semi-supervised training method to realize an automatic annotation framework for unlabeled data and low-cost training without strong data dependence, thereby improving the efficiency of model training.

[0125] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0126] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A water quality detection method based on deep neural network for edge devices, characterized in that: The water quality detection method detects water quality through a pre-constructed neural network model, wherein the neural network model includes a backbone network, a neck network, a suspended matter detection network, and a water quality prediction network, wherein the output of the backbone network is input into the neck network, and the output of the neck network is input into the suspended matter detection network and the water quality prediction network respectively; the water quality detection method includes: Acquire a water sample image to be detected; The water sample image to be detected is processed based on a preset neural network model, and the suspended matter detection network outputs category information and location information of the suspended matter present in the water body image sample; the water quality prediction network outputs the water quality prediction score and the prediction value of the key indicators.

2. A water quality detection method based on a deep neural network for edge devices as claimed in claim 1, characterized in that: The construction of the neural network model includes: Obtain a certain amount of water sample images, and randomly annotate the obtained water sample images in proportion. All the unannotated images and 90% of the annotated images are used as training sets, and the remaining 10% of the annotated images are used as validation sets. The training set is input into the neural network model for model training and model parameter tuning, and the trained neural network model is saved; Among them, the water quality score regression loss and the regression loss of the key indicators in the water quality prediction network both adopt the improved cosine similarity regression loss measurement function: Let G∈R N*1 represents the original true annotation, let P∈R N*1 Represents the predicted value of the indicator directly output by the model, then the cosine similarity loss is L cs_reg =1-CosSim(G*G T , P*P T ); Where N represents the number of indicators to be detected, CosSim represents the cosine similarity function, * represents matrix multiplication, and T represents matrix transposition.

3. A water quality detection method based on a deep neural network for edge devices as claimed in claim 2, characterized in that: Before inputting the training set into the neural network model, the water quality detection method further includes: For any labeled image in the training set, the enhanced sample set x is obtained by using the strong data enhancement strategy A l .

4. A water quality detection method based on a deep neural network for edge devices as claimed in claim 3, characterized in that: Any annotated image in the training set is input into the neural network model for model training and model parameter tuning, including: The enhanced sample set x l Extract multi-scale image features of water images through backbone network Among them, I represents the number of multi-scale features; The F l The mixed feature f is obtained by fusing multi-scale features through the neck network l ; The suspended matter detection network and the water quality prediction network receive the mixed features f l ; The suspended matter detection network outputs the category information and location information of the suspended matter in the water image sample, and calculates the classification loss L with the annotated true value information. cls and position regression loss L reg ; The water quality prediction network will output the water quality prediction score and the predicted value of the key indicators, and calculate the water quality score regression loss respectively with the annotated true value information Focus on the regression loss of the indicator Among them, j represents the jth water quality index; After completing the calculation of each loss, the final loss L of the labeled data in the training set is obtained by summing up the loss functions. l ; And through the final loss L of the labeled data l The parameters of the annotated suspended matter detection network and water quality prediction network are updated respectively.

5. A water quality detection method based on a deep neural network for edge devices as claimed in claim 4, characterized in that: Before inputting the training set into the neural network model, the water quality detection method further includes: For any unlabeled image x in the training set u The strong data enhancement sample set is obtained by strong and weak data enhancement respectively. With weak data enhancement sample set Among them, strong data enhancement adopts strong data enhancement strategy A.

6. A water quality detection method based on a deep neural network for edge devices as claimed in claim 5, characterized in that: Any unlabeled image x in the training set u Input into the neural network model for model training and model parameter tuning, including: The weak data enhancement sample set The enhanced sample set is obtained through the backbone network and the neck network in turn. The corresponding mixed features are respectively input into the suspended matter detection branch to obtain the classification information and location information of the suspended matter, and the water quality prediction branch to obtain the water quality score and the predicted values ​​of each key indicator, and used as the strong data enhancement sample set Pseudo labels of Among them, the strong data enhancement sample set The weak data enhancement sample set is obtained through the backbone network and the neck network in turn. The corresponding mixed features are further input into the suspended matter detection network and the water quality prediction network to obtain the corresponding prediction results. The prediction results are respectively combined with the category information and location information of the suspended matter to calculate the classification loss. With position regression loss Calculation of water quality scores and key indicator prediction values and Finally, we will get the final loss of unlabeled data And through the final loss L of the unlabeled data u Update the parameters of the unlabeled suspended matter detection network and water quality prediction network respectively; Combining the two parts of the loss function, we get L = L l +λL u , the stochastic gradient descent method is used to tune the parameters of L; Among them, λ is a constant term, which is used to control the intensity of unlabeled data on the overall training of the model.

7. A water quality detection method based on a deep neural network for edge devices as claimed in claim 2, characterized in that: The ratio of the obtained annotated image to the unannotated image is 1:

100.

8. The water quality detection method based on deep neural network for edge devices as claimed in claim 3, characterized in that: The strong data enhancement strategy A includes at least one of the following: Sensor noise simulation based on OPENCV; Motion blur simulation; Simulation of lighting environment changes based on HSV color space; Random cropping strategy, let {x1, y1, x2, y2} represent the upper left corner coordinates and lower right corner coordinates of the bounding box of the suspended object, let Δ∈[0,H] be a random value, then the cropping area is represented as: {x1-Δ, y1-Δ, x2+Δ, y2+Δ}; For image samples without suspended objects, random cropping is performed; Where H is the length or width of the image.

9. A computer-readable storage medium, characterized in that: It stores a computer program for water quality detection based on a deep neural network, wherein the computer program enables a computer to execute a water quality detection method based on a deep neural network as described in any one of claims 1-8.

10. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the programs include programs for executing water quality detection based on a deep neural network as described in any one of claims 1-8.