Sewage detection method based on sewage discharge image data automatic labeling

By combining the hybrid model of the comparative learning network and the YOLO5 detection network, automated sewage detection is realized, which solves the shortcomings of traditional methods that rely on manpower and material resources, improves the accuracy and reliability of detection, and is suitable for sewage discharge monitoring in complex environments.

CN118747892APending Publication Date: 2024-10-08FOSHAN KENEITE ENVIRONMENT TECH
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410846530.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-10-08

AI Technical Summary

Technical Problem

Traditional sewage discharge detection methods rely on manpower and material resources, making it difficult to achieve 24-hour monitoring. Manual annotation is costly and inaccurate. Target detection based on machine learning has limited accuracy in complex environments.

Method used

A hybrid model based on contrastive learning network and YOLO5 detection network is used to realize automatic detection of sewage discharge through automatic image data annotation. This method includes data preprocessing, building a contrastive learning network model, data enhancement and loss function training, combined with the YOLO5 detection network, to generate a hybrid network model for training to achieve automatic detection.

Benefits of technology

It realizes automated sewage detection, reduces manual intervention, improves the accuracy and reliability of detection, can effectively identify sewage discharge in complex environments, and reduces manual labeling costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118747892A_ABST
    Figure CN118747892A_ABST
Patent Text Reader

Abstract

The invention discloses a sewage detection method based on sewage discharge image data automatic labeling, which comprises the following steps: acquiring a sewage discharge data set, preprocessing the acquired data set, and dividing the acquired data set into a training set and a test set according to a ratio of 7: 3; constructing a comparative learning network model, and sending the training set into the comparative learning network model for training to obtain a trained comparative learning network model; splicing the trained comparative learning network model and a YOLO5 detection network to obtain a hybrid network model, and training the hybrid network model to obtain a trained hybrid network model; and sending the test set into the hybrid network model to obtain a final detection result, and aims to replace manual work to realize automatic labeling and automatic detection of image data, so as to realize automatic acquisition of a sewage detection result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of sewage detection, and in particular to a sewage detection method based on automatic labeling of sewage discharge image data. Background Art

[0002] Industrial wastewater is one of the main sources of water pollution, containing pollutants such as heavy metals and toxic organic matter. These harmful substances are directly discharged into the water without proper treatment, which will destroy the water ecological balance, threaten human health, and affect industrial and agricultural production and residents' lives, thus leading to the need for wastewater discharge testing.

[0003] In the monitoring of sewage discharge, the traditional method is to use methods such as field surveys, material audits, and sampling tests, mainly relying on manpower and material resources to achieve sewage discharge detection; target detection in computer vision can effectively identify sewage discharge, and target detection methods mainly include machine learning-based methods and deep learning-based methods. These methods have certain limitations, such as:

[0004] 1. Traditional methods consume human and material resources, and it is difficult to monitor 24 hours a day. Human subjective factors make it difficult to ensure the accuracy and reliability of data, and it is difficult to effectively and real-time monitor sewage discharge;

[0005] 2. Object detection tasks usually require annotated data sets when training models. Currently, some image annotation tools are commonly used for annotation, such as Labelmg and Labelme. The quality of annotation depends on the annotation personnel and annotation tools, and the labor cost is high.

[0006] 3. Machine learning-based object recognition algorithms mainly manually extract image features and use traditional machine learning methods for classification. However, the accuracy of these algorithms may be limited in complex or open environments, and their generalization ability is poor.

[0007] Therefore, based on the above problems, continue with the solution. Summary of the invention

[0008] The purpose of the present invention is to provide a sewage detection method based on automatic labeling of sewage discharge image data, so as to realize automatic detection and replace manual application.

[0009] In order to achieve the above object, the technical solutions of the present invention are:

[0010] A sewage detection method based on automatic annotation of sewage discharge image data comprises the following steps: obtaining a sewage discharge data set, preprocessing the obtained data set, and dividing the obtained data set into a training set and a test set in a ratio of 7:3;

[0011] Construct a contrastive learning network model, send the training set to the contrastive learning network model for training, and obtain a trained contrastive learning network model;

[0012] The trained contrastive learning network model is spliced ​​with the YOLO5 detection network to obtain a hybrid network model, and the hybrid network model is trained to obtain a trained hybrid network model;

[0013] The test set is fed into the hybrid network model to obtain the final detection result.

[0014] Furthermore, the preprocessing of the acquired data set specifically includes:

[0015] Check the size of the image data in the data set and determine whether the sizes of the various image data are the same; if not, adjust the size of the various image data.

[0016] Furthermore, the construction of the contrastive learning network model, sending the training set to the contrastive learning network model for training, and obtaining a trained contrastive learning network model specifically includes:

[0017] Construct a comparative learning network model including an encoder part, a part for constructing samples of the same type and samples of different types, and a loss function part;

[0018] Based on the encoder part, a convolutional neural network model is used to extract features from the input training set to obtain feature vectors corresponding to the image data in the training set;

[0019] Based on the construction part of the same type of samples and different types of samples, the feature vectors corresponding to the image data in the training set are obtained, and the image data in the training set are distinguished by the same type of samples and different types of samples by using data enhancement;

[0020] Based on the loss function part, the image data in the training set are distinguished and grouped into samples of the same type and samples of different types, and the contrastive learning network model is trained.

[0021] Furthermore, the encoder-based part uses a convolutional neural network model to extract features from the input training set to obtain feature vectors corresponding to the image data in the training set, specifically including:

[0022] The convolutional neural network model is used to extract features from the image data in the training set;

[0023] The data features are extracted from the image data in the training set, where the convolution kernel size is 2. After the image data in the training set undergoes causal hole convolution, the weights are normalized and mapped using a modified rectifier function. After repeating the operation, the result is superimposed with the input convolution to form a residual block. The output of the residual block is used as the input of the next layer until the final feature extraction result is output.

[0024] Furthermore, based on the construction part of the same type of samples and different type of samples, the feature vectors corresponding to the image data in the acquired training set are used to distinguish the same type of samples and different type of samples in the training set by using data enhancement, which specifically includes:

[0025] Each image data in the training set is rotated, cropped, and noise-added, and then the processed image data is added to the training set to obtain the expanded data;

[0026] According to the expanded data, the expanded data is distinguished into samples of the same type and samples of different types.

[0027] Furthermore, the loss function-based part trains the contrastive learning network model based on distinguishing sets of samples of the same type and samples of different types in the image data in the training set, specifically including: setting the number of iterations of the autoencoder according to the size of the high-definition image training set;

[0028] The form of constructing the loss function is as follows:

[0029]

[0030] Where K represents the number of samples of the same type, and L represents the number of samples of different types. Indicates the similarity of the same samples in group p, represents the similarity of samples of different classes in the jth group, and is a non-negative integer weight factor, and makes the similarity score approach the optimal value, so and Defined as:

[0031]

[0032]

[0033] [] + Indicates truncation at 0, ensuring and is a non-negative number, through and To adapt the weighting, the final loss function is constructed as:

[0034]

[0035]

[0036] After the image data in the training set is input into the encoder for encoding, that is, the encoded data of the same type of samples and the different type of samples, the loss value between the image data corresponding to the same type of samples and the different type of samples is calculated according to the similarity between the same type of samples and the different type of samples;

[0037] The back propagation algorithm is used to update the weights and offsets of the encoder to complete one iteration of encoder training until all encoder iterations are completed, thereby obtaining a trained contrastive learning network model.

[0038] Furthermore, the trained contrastive learning network model is spliced ​​with the YOL05 detection network to obtain a hybrid network model, and the hybrid network model is trained to obtain a trained hybrid network model, specifically including:

[0039] Read the parameters of the trained encoder, initialize the encoding network with the read parameter values, and set the parameters of the encoder to a non-trainable state;

[0040] Set the input image size of the YOL05 detection network to be the same as the input size of the encoder, and set the number of iterations of the YOL05 detection network according to the size of the collected dataset;

[0041] The high-definition image training set data is sent to the spliced ​​hybrid network for forward propagation to obtain the output detection results;

[0042] Use the loss function in the YOLO5 algorithm to calculate the loss value between the output detection result and the annotated correct label data; according to the size of the loss value, use the back propagation algorithm to update the weights and offsets of the hybrid network model to complete one iteration of the hybrid network model training;

[0043] Until the hybrid network model training is completed with the number of iterations, a trained hybrid network model is obtained.

[0044] As a second aspect of the present application, a computer-readable storage medium stores a program, and the program is executed by a processor to implement the sewage detection method as described above.

[0045] As a third aspect of the present application, a computer program product includes a computer program, and when the computer program is executed by a processor, the sewage detection method as described above is implemented.

[0046] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 is a flow chart of a sewage detection method in this embodiment;

[0048] Figure 2 is a specific flow chart indicating step S2 in a sewage detection method in this embodiment;

[0049] Figure 3 is a flow chart indicating automatic labeling in a sewage detection method in this embodiment;

[0050] Figure 4 is a data enhancement diagram indicating a comparative learning process in a sewage detection method in this embodiment;

[0051] Figure 5 is a schematic diagram of automatic labeling indicating comparative learning in a sewage detection method in this embodiment;

[0052] Figure 6 It is a flow chart of a hybrid network model that integrates a contrast learning network model and a YOLO5 detection network model in a sewage detection method in this embodiment. DETAILED DESCRIPTION

[0053] In order to better illustrate the present invention, the present invention is further described in detail below with reference to the accompanying drawings.

[0054] It should be clear that the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the embodiments of the present application.

[0055] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the embodiments of the present application. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0056] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims. In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and do not have to be used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances.

[0057] In addition, in the description of this application, unless otherwise specified, "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.

[0058] First, in the monitoring of sewage discharge, the traditional method is to use methods such as field surveys, material audits, and sampling tests, mainly relying on manpower and material resources to achieve sewage discharge detection; target detection in computer vision can effectively identify sewage discharge, and target detection methods mainly include machine learning-based methods and deep learning-based methods. These methods have certain limitations.

[0059] Therefore, the technical problem actually solved by this application is to replace manual sewage detection with machine learning solutions in the field of sewage detection.

[0060] As an illustrative example of this application, Figure 1 As shown, a sewage detection method based on automatic labeling of sewage discharge image data includes the following steps:

[0061] Step S1, obtaining a sewage discharge data set, preprocessing the obtained data set, and dividing the obtained data set into a training set and a test set in a ratio of 7:3;

[0062] Collect image data taken by drones, where the height and width of the image are determined according to the parameter values ​​of the camera;

[0063] In addition, the obtained data set is preprocessed:

[0064] Check the size of the image data in the data set and determine whether the sizes of the various image data are the same; if not, adjust the size of each image data to ensure that all image data have the same size, and then standardize the image data to eliminate the impact of the dimension.

[0065] Finally, the data is divided into a training set for training the model and a test set for testing the model, 70% as the training set and 30% as the test set;

[0066] Step S2, constructing a contrastive learning network model, sending the training set to the contrastive learning network model for training, and obtaining a trained contrastive learning network model;

[0067] Specific, combined Figure 2 As shown, including:

[0068] Step S21, constructing a comparative learning network model including an encoder part, a part for constructing samples of the same type and samples of different types, and a loss function part;

[0069] Step S22: using a convolutional neural network model based on the encoder part to extract features from the input training set to obtain feature vectors corresponding to the image data in the training set;

[0070] Specifically, a convolutional neural network model is used to extract features from image data in the training set;

[0071] The data features are extracted from the image data in the training set, where the convolution kernel size is 2. After the image data in the training set undergoes causal hole convolution, the weights are normalized and mapped using a modified rectifier function. After repeating the operation, the result is superimposed with the input convolution to form a residual block. The output of the residual block is used as the input of the next layer until the final feature extraction result is output.

[0072] Among them, preferably, the convolutional neural network model is preferably a causal void convolution model.

[0073] In addition, based on the above, the core function of the encoder is to convert input data (such as images, text, etc.) into high-dimensional feature vectors, which can effectively reflect the similarities and differences between samples.

[0074] Combination Figure 3 As shown in the figure, since the output at time T is at most related to the input at time T and before time T, the input is restricted to ensure that the model does not use future information, so a causal convolution is constructed to extract data features. The introduction of dilated convolution means that the sampling interval of the convolution kernel in the input feature map is enlarged, and the spacing between the elements inside the convolution kernel becomes larger. In this way, as the number of convolution kernels continues to increase, the field of view of the convolution increases, capturing a wider range of contextual information.

[0075] superior Figure 3 The left figure shows the causal dilated convolution process, where the convolution kernel size is 2, and d represents the dilation factor, which is an exponential power of 2, i.e. 1, 2, 4, 8, ... The data length may not be enough, so padding operation is performed on the left.

[0076] Causal atrous convolution may cause gradient vanishing due to the depth of the model. To deal with this problem, the encoder is constructed in the form of residual blocks, as shown below: Figure 1 As shown in the figure on the right, after the data passes through the causal dilated convolution (Dliated Causal Conv), it is weighted normalized (WeightNorm) and mapped using Relu (corrected rectifier function). After repeating these operations, the result is superimposed with the input convolution to form a residual block. The output of the residual block is used as the input of the next layer until the final result is output. In this way, the data features can be effectively extracted while ensuring the efficiency of data processing and calculation.

[0077] Step S23, based on the construction part of the same type of samples and different type of samples, the feature vectors corresponding to the image data in the training set are obtained, and the image data in the training set are distinguished into the same type of samples and the different type of samples by using data enhancement;

[0078] The essence of contrastive learning is to learn the similarities and differences between samples. The similarities are between samples of the same type, while the differences are between samples of different types. This requires the construction of samples of the same type and samples of different types. Since the data is not labeled, it is difficult to divide the data into the same type and different types by the data category. In the experiment, data enhancement is used to construct samples of the same type and samples of different types. Data enhancement uses three methods: rotation, cropping, and adding noise. This can improve the generalization ability of the model and resist overfitting. Rotation can help the model recognize the shape of the data at different angles. Cropping can simulate the change in camera perspective to help the model process features at different scales. Adding noise can simulate the noise that occurs in practice to improve the model's ability to suppress noise and the stability of sewage discharge identification. The specific data enhancement process is as follows Figure 4 and Figure 5 As shown, flip means rotation, crop means cropping, and noise means noise enhancement.

[0079] During the training of the encoder, a batch is taken from the entire training set without replacement each time as the training set until all the training sets are taken, which is considered a complete training. Considering the memory resources during the training process, the batch size batch_size is set to 16, and the number of training epochs is 100. In each batch, the batch is enhanced to obtain three sets of 16-size enhanced data, namely, rotation, cropping, and noise addition. In this way, there will be 64 sets of data, including batch, rotation enhancement, cropping enhancement, and noise enhancement. If a sample in the batch is denoted as q, its rotation, cropping, and noise enhancement data are denoted as flip. pos 、crop pos 、noise pos , batch and the batch’s rotation, cropping, and other samples with noise added are denoted as b neg 、flip neg 、crop neg 、noise neg In the experiment, the noise is added by adding Gaussian noise with a standard deviation of 0.1, then q is flipped sos 、crop pos 、noise pos Constitute 3 groups of similar samples, q and b neg 、flip neg 、crop neg 、noise neg Composed of 60 groups of different categories of data.

[0080] Step S24: Based on the loss function, the image data in the training set is distinguished and grouped into samples of the same type and samples of different types, and the contrastive learning network model is trained, specifically including:

[0081] Set the number of iterations of the autoencoder according to the size of the HD image training set;

[0082] The form of constructing the loss function is as follows:

[0083]

[0084] Where K represents the number of samples of the same type, and L represents the number of samples of different types. Indicates the similarity of the same samples in group p, represents the similarity of samples of different classes in the jth group, and is a non-negative integer weight factor, and makes the similarity score approach the optimal value, so and Defined as:

[0085]

[0086]

[0087] []+ means truncation at 0, ensuring and is a non-negative number, through and To adapt the weighting, the final loss function is constructed as:

[0088]

[0089]

[0090] After the image data in the training set is input into the encoder for encoding, that is, the encoded data of the same type of samples and the different type of samples, the loss value between the image data corresponding to the same type of samples and the different type of samples is calculated according to the similarity between the same type of samples and the different type of samples;

[0091] The back propagation algorithm is used to update the weights and offsets of the encoder to complete one iteration of encoder training until all encoder iterations are completed to obtain a trained contrastive learning network model.

[0092] Step S3, splicing the trained contrastive learning network model with the YOLO5 detection network to obtain a hybrid network model, and training the hybrid network model to obtain a trained hybrid network model;

[0093] like Figure 6As shown in the figure, based on the hybrid network model obtained by splicing the contrastive learning network model with the YOLO5 detection network model, the structure of the hybrid network model mainly includes four parts: input end, backbone network (Backbone), neck network (Neck) and output end (Head). The input end is the data that is automatically annotated by the contrast learning process. The data is preprocessed, including steps such as Mosaic data enhancement, adaptive anchor box calculation, and adaptive image scaling. These operations are conducive to the model to better adapt to images of different sizes and shapes to improve the sewage detection performance. Backbone uses CSPDarknet53 as a feature extractor, which consists of two CSP structures. The CSP structure can improve the performance of the model and reduce parameters and calculations. Backbone gradually completes the feature extraction of sewage discharge data through a series of convolution (Conv) and pooling (Maxpool) operations. The neck network (Neck) uses FPN and PAN structures. FPN fuses features at different levels through sampling to enrich the expression ability of features. The PAN structure further enhances the effect of feature fusion, so that the model can process features of different scales. The output end (Head) uses GIOU_Loss as the loss function to calculate the loss between the predicted box and the real box. The model will split the image data into a series of grids, each grid is responsible for detecting and locating a target, and the model will predict the position of the target box in each grid and the probability of the corresponding category.

[0094] Based on the above, read the parameters of the trained encoder and initialize the encoding network with the read parameter values.

[0095] And set the parameters of the encoder to a non-trainable state;

[0096] Set the input image size of the YOLO5 detection network to be the same as the input size of the encoder, and set the number of iterations of the YOLO5 detection network according to the size of the collected dataset;

[0097] The high-definition image training set data is sent to the spliced ​​hybrid network for forward propagation to obtain the output detection results;

[0098] Use the loss function in the YOLO5 algorithm to calculate the loss value between the output detection result and the annotated correct label data; according to the size of the loss value, use the back propagation algorithm to update the weights and offsets of the hybrid network model to complete one iteration of the hybrid network model training;

[0099] Until the hybrid network model training is completed with the number of iterations, a trained hybrid network model is obtained.

[0100] As a second aspect of the present application, a computer-readable storage medium stores a program, and the program is executed by a processor to implement the sewage detection method as described above.

[0101] As a third aspect of the present application, a computer program product includes a computer program, and when the computer program is executed by a processor, the sewage detection method as described above is implemented.

[0102] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0103] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0104] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0105] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0106] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0107] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0108] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0109] According to the disclosure and teaching of the above description, those skilled in the art to which the present invention belongs may also make changes and modifications to the above embodiments. Therefore, the present invention is not limited to the specific embodiments disclosed and described above, and some modifications and changes to the present invention should also fall within the scope of protection of the claims of the present invention. In addition, although some specific terms are used in this specification, these terms are only for the convenience of description and do not constitute any limitation to the present invention.

Claims

1. A sewage detection method based on automatic labeling of sewage discharge image data, characterized in that: The steps include: Obtain a sewage discharge data set, preprocess the obtained data set, and divide the obtained data set into a training set and a test set in a ratio of 7:3; Construct a contrastive learning network model, send the training set to the contrastive learning network model for training, and obtain a trained contrastive learning network model; The trained contrastive learning network model is spliced ​​with the YOLO5 detection network to obtain a hybrid network model, and the hybrid network model is trained to obtain a trained hybrid network model; The test set is fed into the hybrid network model to obtain the final detection result.

2. The sewage detection method according to claim 1, characterized in that: The preprocessing of the acquired data set specifically includes: Check the size of the image data in the data set and determine whether the sizes of the image data are the same; If not, the size of each image data is adjusted.

3. The sewage detection method according to claim 1, characterized in that: The constructing of the contrastive learning network model, sending the training set to the contrastive learning network model for training, and obtaining a trained contrastive learning network model specifically includes: Construct a comparative learning network model including an encoder part, a part for constructing samples of the same type and samples of different types, and a loss function part; Based on the encoder part, a convolutional neural network model is used to extract features from the input training set to obtain feature vectors corresponding to the image data in the training set; Based on the construction part of the same type of samples and different types of samples, the feature vectors corresponding to the image data in the training set are obtained, and the image data in the training set are distinguished by the same type of samples and different types of samples by using data enhancement; Based on the loss function part, the image data in the training set are distinguished and grouped into samples of the same type and samples of different types, and the contrastive learning network model is trained.

4. The sewage detection method according to claim 3, characterized in that The encoder-based part uses a convolutional neural network model to extract features from the input training set to obtain feature vectors corresponding to the image data in the training set, specifically including: The convolutional neural network model is used to extract features from the image data in the training set; The data features are extracted from the image data in the training set, where the convolution kernel size is 2. After the image data in the training set undergoes causal hole convolution, the weights are normalized and mapped using a modified rectifier function. After repeating the operation, the result is superimposed with the input convolution to form a residual block. The output of the residual block is used as the input of the next layer until the final feature extraction result is output.

5. The sewage detection method according to claim 3, characterized in that: Based on the construction part of the same type of samples and different types of samples, the feature vectors corresponding to the image data in the training set are obtained, and the image data in the training set are distinguished by data enhancement, which specifically includes: Each image data in the training set is rotated, cropped, and noise-added, and then the processed image data is added to the training set to obtain the expanded data; According to the expanded data, the expanded data is distinguished into samples of the same type and samples of different types.

6. The sewage detection method according to claim 3, characterized in that: The loss function-based part trains the contrastive learning network model based on distinguishing the same type of samples and different types of samples in the image data in the training set, and specifically includes: Set the number of encoder iterations according to the size of the HD image training set; The form of constructing the loss function is as follows: Where K represents the number of samples of the same type, and L represents the number of samples of different types. Indicates the similarity of the same samples in group p, represents the similarity of samples of different classes in the jth group, and is a non-negative integer weight factor, and makes the similarity score approach the optimal value, so and Defined as: [] + Indicates truncation at 0, ensuring and is a non-negative number, through and To adapt the weighting, the final loss function is constructed as: After the image data in the training set is input into the encoder for encoding, that is, the encoded data of the same type of samples and the different type of samples, the loss value between the image data corresponding to the same type of samples and the different type of samples is calculated according to the similarity between the same type of samples and the different type of samples; The back propagation algorithm is used to update the weights and offsets of the encoder to complete one iteration of encoder training until all encoder iterations are completed to obtain a trained contrastive learning network model.

7. The sewage detection method according to claim 1, characterized in that: The method of splicing the trained contrastive learning network model with the YOLO5 detection network to obtain a hybrid network model, and training the hybrid network model to obtain a trained hybrid network model, specifically includes: Read the parameters of the trained encoder, initialize the encoding network with the read parameter values, and set the parameters of the encoder to a non-trainable state; Set the input image size of the YOLO5 detection network to be the same as the input size of the encoder, and set the number of iterations of the YOLO5 detection network according to the size of the collected dataset; The high-definition image training set data is sent to the spliced ​​hybrid network for forward propagation to obtain the output detection results; Use the loss function in the YOLO5 algorithm to calculate the loss value between the output detection result and the annotated correct label data; according to the size of the loss value, use the back propagation algorithm to update the weights and offsets of the hybrid network model to complete one iteration of the hybrid network model training; Until the hybrid network model training is completed with the number of iterations, a trained hybrid network model is obtained.

8. A computer-readable storage medium, characterized in that: The storage medium stores a program, and the program is executed by a processor to implement the sewage detection method according to any one of claims 1 to 4.

9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the sewage detection method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • High-definition image small target detection method based on auto-encoder and YOLO algorithm

    CN111126359A

  • Encoder and model training method, fault detection method and related equipment

    CN117036355A

  • Electrical equipment defect detection method and system based on self-supervised learning

    CN117671587A

  • Multi-modal target detection method based on comparative learning

    CN118154844A

  • Method and system for evaluating organoid vitality on the basis of microscopic images

    WO2022252298A1