Deep learning-based slaughter sewage turbidity detection method

By constructing the MTD-Net network architecture and combining multispectral image acquisition and multimodal feature fusion, the problems of accurate quantitative detection and adaptability to complex scenarios in slaughterhouse wastewater turbidity detection in existing technologies have been solved, enabling accurate detection of slaughterhouse wastewater turbidity and adjustment of process parameters.

CN121783871APending Publication Date: 2026-04-03HENAN INST OF SCI & TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing water turbidity detection methods cannot achieve accurate quantitative output, and have poor anti-interference and adaptability to complex scenarios, making it difficult to meet the process parameter adjustment needs of wastewater treatment plants.

Method used

A deep learning-based method for detecting turbidity in slaughterhouse wastewater was developed. By constructing an MTD-Net network architecture, combining multispectral image acquisition and multimodal feature fusion, and utilizing the ConvNeXt-T backbone network and SLCAM attention mechanism module, the turbidity of slaughterhouse wastewater can be accurately detected.

Benefits of technology

It enables precise numerical detection of turbidity in slaughterhouse wastewater, provides reliable reference for adjusting process parameters, can withstand interference from complex scenarios, supports integration with factory SCADA systems, and is suitable for wastewater treatment production lines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121783871A_ABST
    Figure CN121783871A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer vision and environment monitoring, and provides a slaughter sewage turbidity detection method based on deep learning to solve the problems that existing slaughter sewage turbidity detection is weak in interference resistance, only qualitative but not accurate quantitative, and poor in industrial scene adaptation. Comprising the following steps: acquiring white, red and blue visible light and 855nm NIR four-mode images of slaughter sewage, and preprocessing; an MTD-Net network is constructed based on a ConvNeXt-T network, the network extracts modal features through four-stream branches, core turbidity features are screened through an SLCAM spatial position channel attention module, and interference noise is suppressed; cross-modal feature weighted complementation is realized through an AMFF adaptive multi-modal fusion module; and in combination with a turbidity interval-category balance loss function training model, outputting a precise NTU quantitative value. According to the invention, non-contact online real-time monitoring is realized, the problems of stability and quantitative precision of turbidity detection in a complex sewage environment are solved, and the engineering practicability is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of wastewater turbidity detection technology, specifically a method for detecting turbidity in slaughterhouse wastewater based on deep learning. Background Technology

[0002] Turbidity reflects the degree to which suspended matter in water obstructs the transmission of light. Suspended and colloidal matter in water, such as mud, silt, fine organic matter, inorganic matter, zooplankton, and other microorganisms, can all cause water samples to exhibit turbidity. The level of turbidity is not only related to the content of particulate matter in the water but also directly affects process adjustments and water quality assessments in scenarios such as wastewater treatment and water quality monitoring. Existing methods for detecting water turbidity still have certain limitations in practice, such as:

[0003] For example, Chinese Patent CN116223455A discloses an underwater turbidity detection device based on image information. This device includes a mounting base, a support frame, a camera, an adjustment component, a depth observation component, and an imaging component. The adjustment component controls the camera to move at different depths underwater, the depth observation component allows the operator to know the detection position, the anti-sway component prevents the shooting deviation caused by water flow, and the imaging component can automatically trigger image acquisition at a specified depth. This enables the acquisition of turbidity images at multiple depths underwater, which improves the spatial flexibility of the detection to a certain extent, and the anti-sway design helps to reduce the interference of water flow on the detection.

[0004] Chinese Patent CN102169079A discloses an online real-time turbidity detection device. This device integrates a turbidity sensor into a water meter and achieves detection through beam transmission of photoelectric and photosensitive elements. It is equipped with a voltage stabilizing device to ensure the stability of the light source, and has a flow signal sampling circuit and a time control device to optimize the detection timing. It can also be linked with an alarm and control terminal to realize online real-time monitoring of turbidity. It has an alarm for exceeding the standard and basic anti-interference capabilities, and can be initially adapted to turbidity screening in simple scenarios such as drinking water.

[0005] Both of the above-mentioned existing technical solutions have obvious limitations in practical applications, which can be summarized into the following three key issues:

[0006] 1. Only qualitative judgment is possible, lacking precise quantitative output capability: CN116223455A can only collect images for manual visual comparison, without outputting specific turbidity NTU (turbidity unit) values; CN102169079A can only determine whether the standard is exceeded through voltage signals, and similarly cannot provide quantitative turbidity data. Neither of them can meet the needs of wastewater treatment plants and other scenarios for precise adjustment of process parameters, such as the dosage of chemicals, and their data has limited practical value.

[0007] 2. Poor anti-interference and adaptability to complex scenarios: CN102169079A uses a single image mode, which cannot distinguish between the reflective properties of pollutants and the turbidity of suspended solids in heavily oily or dark-colored wastewater; CN102169079A relies on a single photoelectric sensor, which is easily affected by colored pollutants and oil adhesion, resulting in signal distortion. Neither of them can cope with complex scenarios such as industrial wastewater, and the detection error is extremely large, making it difficult to support engineering applications.

[0008] Therefore, improvements are needed to address the aforementioned issues. Summary of the Invention

[0009] The technical problem to be solved by the present invention is to overcome the existing defects and provide a deep learning-based method for detecting turbidity in slaughterhouse wastewater, which can effectively solve the problems in the background technology.

[0010] To achieve the above objectives, this invention discloses a deep learning-based method for detecting turbidity in slaughterhouse wastewater. The technical solution includes the following steps:

[0011] Step 1: Preprocess the preset images in the slaughterhouse wastewater multispectral turbidity dataset to unify the resolution and effective area; the preset images in the slaughterhouse wastewater multispectral turbidity dataset include images illuminated by various visible light sources and images illuminated by NIR sources.

[0012] Step 2: Construct the MTD-Net network architecture with ConvNeXt-T as the backbone network. The MTD-Net network architecture includes the SlCAM attention mechanism module and the AMFF fusion module.

[0013] Step 3: Use the preprocessed images from Step 1 combined with the slaughterhouse wastewater multispectral turbidity dataset to train the MTD-Net network and obtain the optimal detection model;

[0014] Step 4: Place the sample to be tested into the sample placement position in the detection area. The detection area has a visible light source and a NIR light source, and an image acquisition device is set up in the detection area. The image acquisition device is positioned corresponding to the sample placement position, so as to acquire a multimodal input image. The type of visible light source is the same as the type of visible light source corresponding to the preset image in the slaughterhouse wastewater multispectral turbidity dataset in Step 1.

[0015] Step 5: Preprocess the multimodal input image to unify the resolution and effective area;

[0016] Step 6: Input the preprocessed multimodal input image obtained in Step 5 into the optimal detection model obtained in Step 3, and output accurate turbidity NTU values.

[0017] The above method can obtain accurate values ​​of wastewater turbidity, which can provide a reference for the automatic adjustment of process parameters and has high practical value. Furthermore, the automatic calculation through visual images has high signal accuracy, which is beneficial for engineering applications.

[0018] As a preferred embodiment of the present invention, in steps 1 and 4, the visible light source includes blue light, white light, and red light.

[0019] As a preferred embodiment of the present invention, the method for constructing the MTD-Net network architecture in step 2 is as follows:

[0020] Step 2.1: Construct four independent branches, corresponding to the input images of four light sources: blue light, white light, red light, and NIR light, respectively; each independent branch sequentially performs feature extraction and enhancement through ConvNeXt-T's Stage1+SLCAM1, Stage2+SLCAM2, and Stage3+SLCAM3, outputting four enhanced high-level features;

[0021] Step 2.2: Input the four high-level features into the AMFF adaptive multimodal fusion module, and output the fused features through adaptive weighted balancing, multi-scale deep interaction and aggregation dimensionality reduction;

[0022] Step 2.3: Input the fused features into Stage4+SLCAM4 of ConvNeXt-T for final feature enhancement, and output the final enhanced features;

[0023] Step 2.4: Input the final enhanced features into the regression head, and output the predicted turbidity value through global average pooling, layer normalization, and fully connected layer operations. ;

[0024] Step 2.5, introduce the TI-CBL loss function, input... Compared with the true turbidity value Calculate the weighted error to guide network training.

[0025] As a preferred embodiment of the present invention, SLCAM1, SLCAM2, SLCAM3 in step 2.1 and SLCAM4 in step 2.3 are all used to process the input feature map. (Where C is the number of channels, H is the height, and W is the width) Feature enhancement is performed, and the calculation process includes the following sub-steps:

[0026] Step 2.1.1, calculate the horizontal attention weights. :

[0027] right Global average pooling and global max pooling are performed along the width W dimension. The results of the two pooling operations are then summed and passed through a shared multilayer perceptron (MLP) and a sigmoid activation function. Generate weights The calculation formula is:

[0028]

[0029] Step 2.1.2, calculate the vertical attention weights. ,

[0030] right Global average pooling and global max pooling are performed along the height H dimension respectively. The results of the two pooling are added together and then passed through the shared multilayer perceptron and the sigmoid activation function. Generate weights The calculation formula is:

[0031]

[0032] Step 2.1.3, Calculate spatial attention weights ,

[0033] right Global average pooling and global max pooling are performed along the channel C dimension. The results of the two pooling operations are then summed and processed through a kernel of size C. Separable convolutional layers with a fill size of N With Sigmoid activation function Generate weights The calculation formula is:

[0034]

[0035] Step 2.1.4, calculate channel attention weights ,

[0036] For SLCAM1, SLCAM2, and SLCAM3 modules, global average pooling is used, and the calculation formula is as follows:

[0037]

[0038] For the SLCAM4 module, the calculation method is the difference between the global average pooling and global max pooling results. The formula is as follows:

[0039]

[0040] The generated weights are all ;

[0041] Step 2.1.5 Feature Enhancement,

[0042] The four weights obtained from the calculation , , , With input feature map Element-wise multiplication is performed to obtain the enhanced output feature map. The calculation formula is:

[0043]

[0044] in, For average pooling along the width dimension, For average pooling along the height dimension, For average pooling along the spatial dimension, For global max pooling, For max pooling along the width dimension, For max pooling along the height dimension, For max pooling along the spatial dimension, For global average pooling, It is a multilayer perceptron containing hidden layers of neurons; This indicates element-wise multiplication.

[0045] As a preferred embodiment of the present invention, the feature fusion step in step 2.2 is as follows:

[0046] Step 2.2.1: Unify and input the feature dimensions.

[0047] The features of the four light source images were extracted using ConvNeXt-T Stage1-Stage2, resulting in the blue light source features. Characteristics of white light source Red light source characteristics NIR light source characteristics ;in, The feature dimension is represented by C, where C is the number of channels, H is the height, and W is the width.

[0048] Step 2.2.2, Adaptive weighted balancing,

[0049] Four learnable weights are introduced, namely , , , The four features are weighted and calibrated using the following formula:

[0050]

[0051] in, , , , These are the features after four-way weighting. This indicates element-wise multiplication of features;

[0052] Step 2.2.3, Multi-scale feature interaction,

[0053] The four-way weighted features are concatenated along the channel dimension to obtain... Three parallel CBR branches are designed: Conv2D, BN2D, and ReLU. These three parallel CBR branches capture multi-scale features, and the unified formula is:

[0054]

[0055] in, The kernel size is the convolution kernel size. Step size, This is the fill size;

[0056] CBR1 branch output CBR2 branch output CBR3 branch output ;

[0057] Step 2.2.4, Feature aggregation and dimensionality reduction,

[0058] The three CBR branch features are summed element-wise, and the final output is obtained by dimensionality reduction using a 1×1 convolution. The formula is as follows:

[0059]

[0060] in, This is the output feature of the AMFF adaptive multimodal fusion module.

[0061] As a preferred embodiment of the present invention, step 2.4 specifically includes the following steps:

[0062] Step 2.4.1, Global Average Pooling (GAP).

[0063] Features of Stage4+SLCAM4 output Perform global average pooling to transform it into a 2C-dimensional global feature vector. ;

[0064] Step 2.4.2, Layer Normalization,

[0065] For global feature vectors Perform layer normalization to regularize the feature distribution and output 2C-dimensional features. ;

[0066] Step 2.4.3, Fully Connected Layer 1,

[0067] right Nonlinear feature mapping is performed, and the 2C-dimensional features are transformed by combining the ReLU activation function. 3D features, output ;

[0068] Step 2.4.4, Fully Connected Layer 2,

[0069] right Perform a linear mapping, Transforming 3D features into 1D turbidity prediction values ,Right now .

[0070] As a preferred embodiment of the present invention, the specific steps for calculating the weighted error in step 2.5 are as follows:

[0071] Step 2.5.1, divide the interval.

[0072] The turbidity range is divided into low turbidity range, medium turbidity range, and high turbidity range;

[0073] Step 2.5.2, calculate the number of valid samples for each interval, using the following formula:

[0074]

[0075] in, The number of valid samples in the interval. The attenuation coefficient is... Let be the actual number of samples in the i-th interval;

[0076] Step 2.5.3, Interval weight adaptation,

[0077] The formula for designing normalized interval weights is as follows:

[0078]

[0079] Where C and K are the turbidity interval numbers;

[0080] Step 2.5.4, Regression Loss Fusion

[0081] Combining interval weights and MSE loss, the formula is:

[0082]

[0083] Where N is the batch sample size. This is the interval index of the i-th sample. For predicted values, These are the actual measured values.

[0084] As a preferred embodiment of the present invention, the preprocessing method in steps 1 and 5 is as follows:

[0085] Step a, Locating and extracting the square ROI.

[0086] The four original images (color visible light image and grayscale NIR image) were uniformly converted into grayscale images to weaken color interference. After noise suppression processing, the Canny edge detection operator was used to extract image edge information. The Hough line detection algorithm was combined to screen the two horizontal boundaries and two vertical boundaries of the detection slot. The intersection points of the four boundaries were solved by the line equation to determine the coordinates of the four vertices of the square detection slot. Based on this coordinate set, the detection slot area was extracted as the region of interest (ROI) and background interference outside the region was removed.

[0087] Step b: Geometric regularization and resolution unification.

[0088] Based on the coordinates of the four vertices of the detection slot, a perspective transformation algorithm is used to correct geometric distortion, uniformly normalizing the square ROIs from different shooting angles into standard squares. A bilinear interpolation algorithm is then used to proportionally scale the normalized ROIs, ensuring consistent resolution across all input images. The interpolation formula is:

[0089]

[0090] in, To scale the image in coordinates Pixel value at that location, These are the pixel coordinates of the scaled image. For the original image and The corresponding adjacent pixel coordinates, For the original image in Pixel value at;

[0091] Step c, image standardization,

[0092] Visible light images were normalized using the mean and standard deviation from the ImageNet dataset;

[0093] NIR images are normalized using global mean and standard deviation;

[0094] The normalization formula is:

[0095]

[0096] in, For the standardized image in Pixel value at that location, These are unnormalized pixel values ​​after scaling. The average pixel value. denoted as the pixel standard deviation.

[0097] As a preferred technical solution of the present invention, in step 3, when training the MTD-Net network, the training set adopts data augmentation strategies of rotation, scaling, salt-and-pepper noise addition, and random erasure, while the validation set and test set do not undergo data augmentation; the training is implemented based on the PyTorch framework, the iteration adopts an early stopping strategy, the ConvNeXt-T backbone network adopts ImageNet pre-trained weights, and the SlCAM attention mechanism module and AMFF fusion module are initialized with Xavier normal distribution.

[0098] Compared with existing technologies, the beneficial effects of this invention are as follows: This invention effectively filters out interference from oil, colored pollutants, and other contaminants in wastewater through multimodal feature complementarity and stage-by-stage attention enhancement, accurately outputting turbidity NTU values ​​and providing reliable data support for adjusting wastewater treatment process parameters; through adaptive multimodal fusion and interval balance loss design, it maintains stable detection accuracy across the low, medium, and high turbidity ranges, resisting interference from complex slaughterhouse wastewater composition and light fluctuations, and exhibiting high long-term operational reliability; the model structure is simplified, the inference speed is fast, it can interface with conventional multispectral acquisition equipment, and it supports linkage with factory SCADA systems, enabling rapid integration into existing wastewater treatment production lines while balancing detection accuracy and real-time requirements. Attached Figure Description

[0099] Figure 1 This is a flowchart of the present invention;

[0100] Figure 2 This is a schematic diagram of the SLCAM module introduced in this invention;

[0101] Figure 3 This is a schematic diagram of the structure of the improved AMFF adaptive multimodal fusion module of the present invention;

[0102] Figure 4 This is a diagram of the MTD-Net network structure of the present invention. Detailed Implementation

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

[0104] Example 1

[0105] like Figures 1 to 4As shown, this invention discloses a method for detecting turbidity in slaughterhouse wastewater based on deep learning. The technical solution adopted is as follows:

[0106] (a) Conducting preliminary preparations

[0107] First, an image acquisition device was constructed, consisting of an industrial color camera and white, red, and blue visible light sources and a near-infrared light source. The color and near-infrared cameras were mounted 25.5 cm directly above the detection position, with their lenses pointing vertically downwards. The visible light sources were located on three sides of the sample container placement position, and the near-infrared light source was located directly below the sample container placement position. All light sources were 5 cm away from the detection slot. The wavelengths of the white, red, and blue visible light sources were 400-760 nm, 630 nm, and 450 nm, respectively, with powers of 30 W, 20 W, and 20 W. The near-infrared light source had a wavelength of 855 nm and a power of 25 W. The two cameras were connected to an industrial computer via a GigE interface and controlled synchronously by a PLC (model S7-1200), with a synchronization delay ≤0.5 ms.

[0108] The sample container is placed on a quartz glass support plate with a thickness of 5mm and a length and width of 20cm, and a light transmittance of ≥99.5%. The sample container is a quartz glass detection tank with a length, width, and height of 5cm, a wall thickness of 2mm, and a light transmittance of ≥99.5%. During the detection, the sample container is placed on the quartz glass support plate at the same distance from the industrial color camera and the near-infrared camera. The water sample is quantitatively injected into the sample container through a peristaltic pump.

[0109] Secondly, a comprehensive calibration and verification of the image acquisition device is performed, specifically including:

[0110] 1. Optical system calibration: The dual cameras are calibrated using a checkerboard calibration plate (12×9 grids, 20mm side length of each grid) to ensure that the reprojection error is ≤0.5 pixels, thus eliminating the influence of image distortion; the uniformity of light within the detection slot is ≥92% by using an illuminance meter to avoid feature distortion caused by uneven illumination.

[0111] 2. Mechanical system calibration: After 100 consecutive sampling verifications, the volume error of injecting 100mL of water sample by the peristaltic pump is ≤±0.3mL;

[0112] 3. Synchronization Verification: 100 sets of four-modal (white light, red light, blue light, near-infrared light) images were continuously acquired, and the PLC triggered the camera sequence via Modbus-TCP.

[0113] With white light source enabled, industrial color camera exposure time is 3ms.

[0114] With the red light source activated, the industrial color camera exposure time is 3ms.

[0115] Blue light source activated, industrial color camera exposure 3ms;

[0116] Near-infrared light source turned on, near-infrared camera exposure 5ms;

[0117] The switching interval between adjacent light sources is ≤0.3ms; all raw images are uploaded to the host computer via the GigE interface;

[0118] By comparing timestamps, the synchronization delay of dual-camera acquisition is ≤100ms, ensuring the temporal consistency of multimodal images and avoiding excessive image changes caused by particulate matter sedimentation in the sample.

[0119] Furthermore, a multispectral turbidity dataset of slaughterhouse wastewater was constructed.

[0120] Three key nodes were selected from the pretreatment unit effluent outlet, the middle of the biochemical reaction tank, and the sedimentation tank outlet of a slaughterhouse wastewater treatment plant in a certain area to cover the characteristics of wastewater at different treatment stages and ensure the representativeness of the dataset.

[0121] In terms of sample specifications, 63 water samples with turbidity levels (0, 3, 5, ..., 200 NTU, with intervals of 3-5 NTU) were collected. The true value of each turbidity level was calibrated using a Qiwei portable turbidity meter ZD-10A, and the water temperature was recorded simultaneously to avoid the influence of environmental factors on the accuracy of the true value.

[0122] For image acquisition, 10 quadmodal images were repeatedly taken for each turbidity level, for a total of 630 samples (the original quadmodal images totaled 2520). The images were named according to the rule of "turbidity value_shot sequence number_light source type" (e.g., "0_1_blue", "50_3_nir"), in JPG format, and the acquisition interval was ≥3 minutes to avoid the water sample settling due to suspension sedimentation.

[0123] In terms of dataset partitioning, the dataset was randomly divided into a training set (44 samples), a validation set (6 samples), and a test set (13 samples) in a ratio of 7:1:2, for a total of 63 samples. Each sample contains 40 images (4 light sources, 10 shots for each light source), with a total of 2520 original images. The samples are evenly distributed across each turbidity range (low:medium:high = 4:4:2).

[0124] (ii) Model building and training

[0125] Includes the following steps:

[0126] Step 1: Preprocess the preset images in the multispectral turbidity dataset of slaughterhouse wastewater to unify the resolution and effective area;

[0127] Specifically, the following steps are included:

[0128] Step 1.1: Square ROI localization and extraction employs a combination of the Canny edge detection operator and the Hough line detection algorithm to extract the square detection slot region. Specifically: for visible light images, the Canny operator's high threshold is set to 80 and the low threshold to 30; the Hough line detection accumulator's threshold is 55, the line length threshold is 150 pixels, and the line gap threshold is 20 pixels; the horizontal / vertical boundary length range of the detection slot is set to [480, 550] pixels. For NIR images, the Canny operator's high threshold is set to 60 and the low threshold to 25; the Hough line detection accumulator's threshold is 35, the line length threshold is 120 pixels, and the line gap threshold is 15 pixels; the horizontal / vertical boundary length range of the detection slot is set to [450, 520] pixels. 100 randomly selected samples were used for verification. The square ROI localization accuracy was ≥99.5%, with no background residue or missing boundary issues.

[0129] Step 1.2, Geometric Regularization and Proportional Scaling: Based on the coordinates of the four vertices of the detection slot, a perspective transformation algorithm is used to correct geometric distortion caused by the shooting angle (transformation matrix error ≤ 0.02), uniformly regularizing square ROIs at different angles into standard squares. Then, a bilinear interpolation algorithm is used to scale the regularized image to a resolution of 224×224. The scaled image exhibits no stretching distortion, continuous pixel distribution, and meets geometric consistency standards. The interpolation formula is as follows:

[0130]

[0131] in, To scale the image in coordinates Pixel value at that location, These are the pixel coordinates of the scaled image. For the original image and The corresponding adjacent pixel coordinates, For the original image in Pixel value at;

[0132] Step 1.3, Image Standardization,

[0133] Visible light images were normalized using the mean ([0.485, 0.456, 0.406]) and standard deviation ([0.229, 0.224, 0.225]) of the ImageNet dataset, while NIR images were normalized using the global mean and standard deviation. After normalization, pixel values ​​were distributed in the range [-1, 1], reducing feature fluctuations caused by illumination differences by 32%. The normalization formula is shown below:

[0134]

[0135] in, For the standardized image in Pixel value at that location, These are unnormalized pixel values ​​after scaling. The average pixel value. The standard deviation of pixels;

[0136] Step 1.4, Data Augmentation

[0137] To mitigate overfitting and improve model generalization ability, data augmentation was performed only on the images in the training set, expanding the number of images from 1760 to 7040. Combined with the original images, the final training set contains a total of 8800 images. The validation and test sets maintained their original image counts (240 and 520 images respectively) to ensure the objectivity and consistency of the evaluation results, avoid data skew leading to overfitting, and ensure that the evaluation results truly reflect the model's generalization ability. The image data augmentation steps in the training set are as follows:

[0138] Step 1.4.1, Rotational Enhancement,

[0139] The image is randomly rotated ±10° around the center of the image to simulate the imaging angle deviation caused by slight shaking of the detection slot;

[0140] Step 1.4.2, Scaling Enhancement,

[0141] The image is randomly scaled by 0.8-1.2 times to maintain the integrity of the effective area and adapt to scenarios with slight fluctuations in the liquid level of different water samples.

[0142] Step 1.4.3, Salt and pepper noise enhancement,

[0143] Salt-and-pepper noise was randomly added at an intensity of 0.01 to improve the robustness of the model to interference from minute impurities in wastewater.

[0144] Step 1.4.4, Random Erasure Enhancement,

[0145] Random grayscale filling and erasing were performed in non-core areas of the image (0.05-0.2%) to simulate actual interference such as local grease coverage and bubble occlusion.

[0146] Four enhancements increased the number of training set images from 1760 to 7040;

[0147] Step 2: Construct the MTD-Net network architecture using ConvNeXt-T as the backbone network. The construction method is as follows:

[0148] Step 2.1: Construct four independent branches corresponding to the three visible light sources and NIR sources respectively. The architecture of each independent branch is unified as follows: the input image passes through the ConvNeXt-T Stage1 feature extraction module, SLCAM1 attention module, Stage2 feature extraction module, SLCAM2 attention module, Stage3 feature extraction module, and SLCAM3 attention module in sequence.

[0149] Stages 1-3 are the basic feature extraction modules of ConvNeXt-T, and SLCAM1-SLCAM3 are the spatial location channel attention modules. The parameters are independent and adaptively fine-tuned during training.

[0150] Evolution of feature dimensions in each branch:

[0151] Each branch inputs a 3×224×224 pixel image, an NIR grayscale image expanded to 3 channels; the Stage1 output features... Output after SLCAM1 enhancement Output features via Stage2 Output after SLCAM2 enhancement Output features via Stage 3 Output after SLCAM3 enhancement Ultimately, the features output by the four branches Corresponding to , , , (All are) ), which are features to be fused;

[0152] in, Indicates feature dimension, number of channels ,high ,width ; The SLCAM module outputs advanced features; SLCAM1 output is used by Stage2; SLCAM2 output is used by Stage3; SLCAM3 output (i.e., ...) This is for use by the AMFF adaptive multimodal fusion module in step 2.2;

[0153] Furthermore, the SLCAM modules (SLCAM1-SLCAM3) in step 2.1 have a consistent structure and independent parameters. They are designed for different levels of characteristics of each stage, and their core function is to accurately select the key features of the current stage. The specific working process is as follows:

[0154] Step 2.1.1, calculate the horizontal attention weights. :

[0155] right Global average pooling and global max pooling are performed along the width W dimension. The results of the two pooling operations are then summed and passed through a shared multilayer perceptron (MLP) and a sigmoid activation function. Generate weights The calculation formula is:

[0156]

[0157] Step 2.1.2, calculate the vertical attention weights. ,

[0158] right Global average pooling and global max pooling are performed along the height H dimension respectively. The results of the two pooling are added together and then passed through the shared multilayer perceptron and the sigmoid activation function. Generate weights The calculation formula is:

[0159]

[0160] Step 2.1.3, Calculate spatial attention weights ,

[0161] right Global average pooling and global max pooling are performed separately along the channel C dimension. The results of the two pooling are then summed and passed through a depthwise separable convolutional layer with a kernel size of 7×7 and a padding size of 3. With the Sigmoid activation function Generate weights The calculation formula is:

[0162]

[0163] Step 2.1.4, calculate channel attention weights ,

[0164] For SLCAM1, SLCAM2, and SLCAM3 modules, global average pooling is used, and the calculation formula is as follows:

[0165]

[0166] For the SLCAM4 module, the calculation method is the difference between the global average pooling and global max pooling results. The formula is as follows:

[0167]

[0168] The generated weights are all ;

[0169] Step 2.1.5 Feature Enhancement,

[0170] The four weights obtained from the calculation , , , With input feature map Element-wise multiplication is performed to obtain the enhanced output feature map. The calculation formula is:

[0171]

[0172] in, For average pooling along the width dimension, For average pooling along the height dimension, For average pooling along the spatial dimension, For global max pooling, For max pooling along the width dimension, For max pooling along the height dimension, For max pooling along the spatial dimension, For global average pooling, It is a multilayer perceptron containing hidden layers of neurons; This represents element-wise multiplication;

[0173] Step 2.2: The enhanced high-level features obtained in Step 2.1 are subjected to adaptive weighted balancing, multi-scale deep interaction, and aggregation dimensionality reduction through the AMFF adaptive multimodal fusion module, and the fused features are output.

[0174] The input to the AMFF adaptive multimodal fusion module consists of four branches of high-level features processed by "Stage3+SLCAM3" (i.e., ... The core issue is to address the imbalance in the four-stream characteristic responses and insufficient cross-modal interaction. The specific steps are as follows:

[0175] Step 2.2.1, Feature Input,

[0176] 4-way characteristics: Blue light source characteristics Characteristics of white light source Red light source characteristics NIR light source characteristics These are all high-level features of each branch after complete stage extraction and attention enhancement (i.e., );

[0177] Step 2.2.2, Adaptive weighted balancing,

[0178] Four learnable weights are introduced, namely , , , The four features are weighted and calibrated using the following formula:

[0179]

[0180] in, , , , These are the weighted 4-way features, This indicates element-wise multiplication of features;

[0181] Step 2.2.3, Multi-scale feature interaction,

[0182] The weighted 4 features are concatenated along the channel dimension to obtain Three parallel CBR branches (Conv2D+BN2D+ReLU) are designed to capture multi-scale features, with a unified formula as follows:

[0183]

[0184] in, The kernel size is (1 / 2 / 3). Step size, Fill size (0 / 1 / 1);

[0185] Step 2.2.4, Feature aggregation and dimensionality reduction,

[0186] The three CBR branch features are added element-wise, and the dimensions are integrated through a 1×1 convolution to obtain the final output. The formula is:

[0187]

[0188] in, The AMFF module outputs features; CBR1 (k=1, p=0) focuses on fine-grained feature complementarity and outputs... CBR2 (k=2, p=1) focuses on the correlation of mesoscale features and outputs... CBR3 (k=3, p=1) focuses on global feature dependencies and outputs... ;

[0189] Step 2.3: Input the fused features into the SLCAM4 module of stage 4 for final enhancement, and output the final enhanced features. The core is to perform global semantic enhancement on the features after AMFF fusion;

[0190] Among them, the SLCAM module is SLCAM4, which has the same structure as SLCAM1-SLCAM3 but with independent parameters;

[0191] ConvNeXt-T Stage 4 contains 3 ConvNeXt Blocks, input Output ;SLCAM4 input After independent branch weight calculation, weight fusion, and feature enhancement similar to steps 2.1.2 to 2.1.4, SLCAM4 outputs the final enhanced features. Further enhance global turbidity correlation characteristics and suppress residual noise;

[0192] Step 2.4: Input the final enhanced features into the regression head and output the predicted turbidity value. ;

[0193] The regression head in step 2.4 is Figure 4 The functional unit marked with a dashed box is responsible for aggregating 2D features into a one-dimensional vector and mapping it to a turbidity prediction value. The internal process is as follows:

[0194] Step 2.4.1, Global Average Pooling (GAP).

[0195] right Global average pooling is performed to aggregate the 2D feature maps into a 768-dimensional global feature vector. Stable extraction of global semantic information;

[0196] Step 2.4.2, Layer Normalization (LN).

[0197] For global feature vectors Layer normalization is performed to regularize the feature distribution and avoid training oscillations, resulting in a 768-dimensional feature output. ;

[0198] Step 2.4.3, Fully Connected Layer 1 (Linear1).

[0199] right Nonlinear feature mapping is performed, transforming the 768-dimensional features into 256-dimensional mid-dimensional features through a fully connected layer. The ReLU activation function is then used to uncover the nonlinear correlation between features and turbidity, resulting in the output. ;

[0200] Step 2.4.4, Fully Connected Layer 2 (Linear2).

[0201] Through the fully connected layer A linear mapping is performed to transform the 256-dimensional mid-dimensional features into 1-dimensional turbidity prediction values. (Predicted turbidity NTU value), directly output quantitative detection results;

[0202] Step 2.5 introduces the TI-CBL loss function, drawing on the core idea of ​​CB Loss (Class-Balanced Loss), and designs it to address the imbalance problem of continuous interval samples in turbidity regression tasks. Input... Compared with the true turbidity value The weighted error is calculated to guide network training. The specific process is as follows:

[0203] Step 2.5.1, Turbidity range division,

[0204] The continuous turbidity range of 0-200 NTU is divided into three non-overlapping pseudo-class intervals: low turbidity interval (0-50 NTU), medium turbidity interval (50-150 NTU), and high turbidity interval (150-200 NTU). The turbidity sample ratio is approximately 4:4:2. The interval division is based on the actual sample distribution obtained by diluting slaughterhouse wastewater samples, which is adapted to the class balance logic of CB Loss.

[0205] Step 2.5.2, Calculation of the number of valid samples in the interval.

[0206] Count the number of samples in each interval (( (where ) is the interval index), and the effective sample number formula of CB Loss is used to quantify the actual contribution of the interval. The formula is:

[0207]

[0208] in, The number of valid samples in the interval. The attenuation coefficient is... Let be the actual number of samples in the i-th interval;

[0209] Step 2.5.3, Interval Weight Adaptation: Design normalized interval weights to ensure stable loss scale. The formula is:

[0210]

[0211] Where C and K are the turbidity interval numbers;

[0212] Step 2.5.4, Regression Loss Fusion

[0213] Combining the interval weights with the mean squared error (MSE), the final form of TI-CBL is obtained, as shown in the formula:

[0214]

[0215] Among them, hyperparameters =0.99 (determined by 5-fold cross-validation, balancing the smoothness of the weights and the effect of mitigating imbalance); when The time weights approach the "inverse class frequency" when There is no weight adjustment, consistent with the original CB Loss hyperparameter definition; This represents the number of turbidity intervals (normalization coefficient). The weight of the k-th interval; sparse intervals (such as high turbidity 150-200 NTU) are due to Smaller intervals receive greater weight, while denser intervals receive less weight, achieving "loss amplification in sparse intervals and loss suppression in dense intervals"; N is the batch size. Let i be the index of the turbidity interval to which the i-th sample belongs. To predict turbidity values, The actual turbidity value measured by the Qiwei ZD-10A portable turbidity meter;

[0216] Step 3: Using the preprocessed images from Step 1 combined with the slaughterhouse wastewater multispectral turbidity dataset, train the MTD-Net network to obtain the optimal detection model; the training hardware and software environment and parameter configuration are as follows:

[0217] Hardware environment: Intel Core i9-13900KF CPU (3.0GHz), 64GB DDR5 RAM, NVIDIA GeForce RTX 4090 graphics card (24GB VRAM); Software environment: Python 3.9, PyTorch 2.1.1, OpenCV 4.8.0, CUDA 12.2, with mixed precision training (AMP) enabled to accelerate convergence; Core parameters: Optimizer: AdamW, weight decay coefficient: 0.0001; Initial learning rate: 1e-4, linear warm-up for the first 5 rounds, decaying to 1e-5, 1e-6, and 1e-7 in rounds 50, 100, and 150 respectively; Training batch size: 16, validation batch size: 8, gradient accumulation steps: 2; Number of iterations: 200, early stopping strategy triggered by "validation set MAE change ≤ 0.02 NTU for 10 consecutive rounds"; Initialization strategy: ConvNeXt-T backbone network using ImageNet. The pre-trained weights, SlCAM attention mechanism module and AMFF fusion module are initialized using Xavier normal distribution to avoid training instability caused by improper initial weights.

[0218] To ensure that all modules work together effectively, this embodiment adopts a step-by-step debugging and optimization strategy, with the specific steps as follows:

[0219] First, debug the module step by step:

[0220] 1. Train the ConvNeXt-T baseline model (including four-stream branches + Stage0-4) to verify that a simple backbone network is insufficient to solve the problems of multimodal conflict and interval imbalance;

[0221] 2. Stage-wise SLCAM (SLCAM1-SLCAM3) was added, and the weights of the first 3 layers of the backbone network were frozen for 80 epochs of training; feature visualization showed that the signal-to-noise ratio of each modality feature was improved by 38%, proving the effectiveness of stage-wise enhancement;

[0222] 3. Unfreeze the backbone network, add the AMFF module and continue training for 60 epochs; cross-modal feature complementarity is enhanced by 45%, solving the problem of insufficient fusion;

[0223] 4. Add Stage4+SLCAM4 and regression head, train for 40 epochs; the model initially achieves turbidity regression, and the MAE drops to 3.2 NTU;

[0224] 5. Introduce the TI-CBL (Turbidity Range-like Equilibrium Loss) function and adjust the attenuation coefficient. Early stop was triggered after 120 rounds of training, reducing the error in the high turbidity range by 60% and stabilizing the MAE at 2.1 NTU across the entire range;

[0225] Furthermore, the key parameters are optimized, and the steps are as follows:

[0226] (1) AMFF learnable weight initialization: The initial weight values ​​[0.8, 1.0, 1.2] were tested by grid search. The experiment showed that the convergence speed was the fastest and the feature balancing effect was the best when the initial value was 1.0.

[0227] (2) SLCAM convolution kernel test: Four convolution kernel sizes of 3×3, 5×5, 7×7 and 9×9 were tested. It was found that the 7×7 convolution kernel performed best in capturing the spatial local dependence of suspended object aggregation areas, and the feature extraction accuracy was improved by 12% compared with the 3×3 convolution kernel;

[0228] (3) TI-CBL hyperparameters Optimization: Testing ,Discover The MAE is the lowest across the entire time interval (2.1 NTU), which alleviates the imbalance and avoids overfitting caused by excessive weight skew.

[0229] (4) Training was conducted to ensure stability: gradient clipping was added during training to avoid gradient explosion caused by modal feature conflicts; the model weights were saved every 20 rounds, and the intersection model of "lowest MAE on the validation set + lowest MAE on the test set" was finally selected to ensure the generalization ability of the model;

[0230] (III) Sample Testing

[0231] Step 4: Place the sample to be tested into the sample placement position in the detection area and acquire multimodal input images of the sample;

[0232] Step 5: Perform the same preprocessing as in Step 1 on the multimodal input image to unify the resolution and effective area;

[0233] Step 6: Input the preprocessed multimodal input image obtained in Step 5 into the optimal detection model obtained in Step 3, and output accurate turbidity NTU values.

[0234] (iv) Assessment

[0235] To objectively and comprehensively evaluate the quantitative regression performance of the model, this embodiment uses four core evaluation indicators: mean absolute error (MAE), root mean square error (RMSE), coefficient of determination (CQD), and mean square error (RMSE). The Mean Absolute Percentage Error (MAPE) is defined, calculated using the following formulas and symbols:

[0236] Mean Absolute Error (MAE): Measures the average absolute deviation between predicted and actual values; a smaller value indicates higher regression accuracy. Root Mean Square Error (RMSE): Amplifies the impact of larger errors and more sensitively reflects prediction bias. Coefficient of Determination (CDO) ): Measures the degree of model fit to the data, with a value range of [0,1]. The closer to 1, the better the fit. Mean Absolute Percentage Error (MAPE): Reflects the relative proportion of prediction error and is suitable for comparing errors in different turbidity ranges. The specific calculation formulas for each indicator are as follows:

[0237]

[0238]

[0239]

[0240]

[0241] Where N is the total number of samples, Let be the predicted turbidity value (NTU) for the i-th sample. Let be the true turbidity value (NTU) of the i-th sample. This represents the average true turbidity of all samples.

[0242] To quantify the effectiveness of each innovative module, four sets of comparative ablation experiments were designed in this embodiment. The original ConvNeXt-T was represented as model (1), ConvNeXt-T + SLCAM as model (2), ConvNeXt-T + SLCAM + AMFF as model (3), and ConvNeXt-T + SLCAM + AMFF + TI-CBL from Example 1 as model (4). Specific results are shown in the table below:

[0243] Table 1 Comparison of various indicators in the ablation experiment

[0244]

[0245] Experimental results show that with the gradual addition of the three innovative modules, the MAPE index decreased from 5.53% to 1.43%, and the relative error decreased by 74.1% cumulatively, which is consistent with the downward trend of MAE and RMSE. This fully verifies the synergistic value of each module in optimizing absolute and relative errors, and ensures the quantitative accuracy and stability of the model in the full turbidity range.

[0246] Furthermore, to comprehensively verify the overall performance of the MTD-Net invention in the turbidity detection scenario of slaughterhouse wastewater, this experiment selected 3 mainstream machine learning methods and 8 classic deep learning architectures, totaling 11 sets of comparison objects. All algorithms used the same dataset and evaluation metrics. The specific results are shown in Table 2:

[0247] Table 2 Comparison of results between the algorithm of this invention and other methods

[0248]

[0249] Experimental results show that, compared with traditional machine learning algorithms, MTD-Net reduces the MAE by 59.6% compared with the best machine learning method XGBoost (5.218 NTU). An improvement of 0.0514 indicates that the deep learning architecture's ability to deeply model multimodal image features is significantly superior to the shallow feature mapping of traditional machine learning. Compared with other deep learning architectures, MTD-Net has only 30.4% of the parameters of ConvNeXt-B and 17.2% of Swin-B, but its MAE is reduced by 69.6% compared to ResNeXt50 and by 65.6% compared to ViT-L-16. This demonstrates that the implementation achieves a breakthrough in accuracy without relying on model size, balancing "lightweight, high accuracy, and real-time performance".

[0250] Furthermore, a comparative experiment was conducted with a commercial turbidimeter to verify the comprehensive performance of this embodiment in practical application scenarios. The Qiwei ZD-10A portable turbidimeter (0-200 NTU range) was selected as the benchmark, with the following technical parameters: indication error ±2.5% FS (i.e., maximum error 5 NTU), and repeatability ≤0.8%. The comparison results show that the mean absolute error (MAE) of the MTD-Net algorithm of this invention is 2.108 NTU, far lower than the maximum indication error of the turbidimeter, and the standard deviation obtained through 5-fold cross-validation is 0.032, indicating that the prediction stability is comparable to the repeatability of the turbidimeter. In terms of engineering practicality, the Qiwei turbidity meter uses contact measurement, requiring manual sampling, settling to remove bubbles, and manual reading, with a total time of approximately 30 seconds per sample and a risk of cross-contamination. In contrast, this embodiment, based on visual detection principles, achieves non-contact measurement. Sampling, image acquisition, and inference are completed through automated equipment, with a single sample detection time of only 0.014 seconds (69.8 fps). It can operate continuously for 24 hours without manual intervention, significantly reducing maintenance costs. Based on these results, this invention, while ensuring detection accuracy, significantly improves detection efficiency and scenario adaptability, better meeting the actual needs of online monitoring of slaughterhouse wastewater.

[0251] To support the performance improvement conclusions with more rigorous statistical analysis, a more detailed statistical validation of the model performance was conducted using K-fold cross-validation. The dataset was divided into almost five equal parts, and five experiments were performed. For MAE, a crucial indicator in turbidity detection, the following experimental results were obtained: 2.085, 2.132, 2.076, 2.154, and 2.093. Based on these results, the mean (2.108), standard deviation (0.032), and 95% confidence interval ([2.071, 2.145]) were further calculated. These statistical results show that the model in Example 1 exhibits relatively stable performance across different training / test partitions, with a small fluctuation range in MAE, indicating high reliability of the model's performance. Furthermore, these results further support the effectiveness of the improvement method proposed in Example 1.

[0252] Furthermore, robustness testing was conducted on the algorithm. To verify the model's adaptability to complex wastewater components, this embodiment simulated common interference scenarios in slaughterhouse wastewater, such as floating grease and suspended protein colloids. 0.1-0.5 g / L of grease and 0.2-0.8 g / L of protein colloids were added to the water sample, and the model's anti-interference ability was tested under different interference intensities. The results showed that under high interference conditions, the MAE of MTD-Net only increased to 2.512 NTU, with an error increase of ≤19.2%. Compared to the best-performing deep learning architecture ResNeXt50 in the comparison group, its anti-interference ability was improved by 71.3%, and compared to the best machine learning method XGBoost, it was improved by 68.3%.

[0253] The above results demonstrate that MTD-Net's multimodal feature complementarity and dynamic attention mechanism can significantly resist the interference of complex components in slaughterhouse wastewater and adapt to the harsh environment of real industrial scenarios.

[0254] After completing model training and performance verification, the automated visual inspection equipment and the MTD-Net model were deployed at the outlet of the biochemical reaction tank of a slaughterhouse wastewater treatment plant. The specific deployment plan is as follows:

[0255] 1. Equipment Connection. The equipment is connected to the sewage pipeline via a peristaltic pump with a sampling flow rate of 5 L / min to ensure real-time updates of water samples and avoid detection errors caused by static conditions.

[0256] Data interaction: It interfaces with the factory's SCADA system via Modbus-RTU protocol (RS485 interface), with a data update frequency of 1Hz. The detection results are fed back to the process control system in real time, and automatic adjustment of parameters such as dosage is supported.

[0257] 2. Environmental Adaptability: The equipment housing is designed with an IP65 protection rating, making it suitable for the humid and dusty industrial environment of sewage treatment plants; the camera lens is equipped with a heated defogging film to prevent condensation from affecting imaging accuracy;

[0258] 3. Long-term operation verification: After on-site deployment, the equipment and model underwent 72 hours of continuous operation verification. The results are as follows:

[0259] A total of 8640 water samples were tested. Comparison of the results with those from commercial turbidity meters showed an overall MAE of 2.3 NTU. =0.988; the model accuracy showed no significant attenuation, and the equipment operated without downtime, meeting the long-term operational requirements of industrial scenarios. Regarding equipment reliability, the cleaning module effectively prevented the adhesion of grease and suspended solids to the surface of the detection tank and lens. After 72 hours of operation, there was no significant contamination on the inner wall of the detection tank, and the camera's imaging quality did not decline. The detection data was successfully used to guide the adjustment of chemical dosage in the wastewater treatment process, ensuring that the effluent turbidity was stably controlled below 50 NTU. Compared to traditional manual detection methods, chemical costs were reduced by 15%, and manual intervention time was reduced by 80%, significantly improving the intelligence level and economic benefits of wastewater treatment.

[0260] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for detecting turbidity in slaughterhouse wastewater based on deep learning, characterized in that, Includes the following steps: Step 1: Preprocess the preset images in the slaughterhouse wastewater multispectral turbidity dataset to unify the resolution and effective area; the preset images in the slaughterhouse wastewater multispectral turbidity dataset include images illuminated by various visible light sources and images illuminated by NIR sources. Step 2: Construct the MTD-Net network architecture with ConvNeXt-T as the backbone network. The MTD-Net network architecture includes the SlCAM attention mechanism module and the AMFF fusion module. Step 3: Use the preprocessed images from Step 1 combined with the slaughterhouse wastewater multispectral turbidity dataset to train the MTD-Net network and obtain the optimal detection model; Step 4: Place the sample to be tested into the sample placement position in the detection area. The detection area has a visible light source and a NIR light source, and an image acquisition device is set up in the detection area. The image acquisition device is positioned corresponding to the sample placement position, so as to acquire a multimodal input image. The type of visible light source is the same as the type of visible light source corresponding to the preset image in the slaughterhouse wastewater multispectral turbidity dataset in Step 1. Step 5: Preprocess the multimodal input image to unify the resolution and effective area; Step 6: Input the preprocessed multimodal input image obtained in Step 5 into the optimal detection model obtained in Step 3, and output accurate turbidity NTU values.

2. The method for detecting turbidity of slaughterhouse wastewater based on deep learning according to claim 1, characterized in that: In steps 1 and 4, the visible light source includes blue light, white light, and red light.

3. The method for detecting turbidity of slaughterhouse wastewater based on deep learning according to claim 2, characterized in that, In step 2, the method for constructing the MTD-Net network architecture is as follows: Step 2.1: Construct four independent branches, corresponding to the input images of four light sources: blue light, white light, red light, and NIR light, respectively; each independent branch sequentially performs feature extraction and enhancement through ConvNeXt-T's Stage1+SLCAM1, Stage2+SLCAM2, and Stage3+SLCAM3, outputting four enhanced high-level features; Step 2.2: Input the four high-level features into the AMFF adaptive multimodal fusion module, and output the fused features through adaptive weighted balancing, multi-scale deep interaction and aggregation dimensionality reduction; Step 2.3: Input the fused features into Stage4+SLCAM4 of ConvNeXt-T for final feature enhancement, and output the final enhanced features; Step 2.4: Input the final enhanced features into the regression head, and output the predicted turbidity value through global average pooling, layer normalization, and fully connected layer operations. ; Step 2.5, introduce the TI-CBL loss function, input... Compared with the true turbidity value Calculate the weighted error to guide network training.

4. The method for detecting turbidity of slaughterhouse wastewater based on deep learning according to claim 3, characterized in that, SLCAM1, SLCAM2, SLCAM3 in step 2.1 and SLCAM4 in step 2.3 are all used to process the input feature map. Feature enhancement is performed, where C is the number of channels, H is the height, and W is the width. The calculation process includes the following sub-steps: Step 2.1.1, calculate the horizontal attention weights. : right Global average pooling and global max pooling are performed along the width W dimension. The results of the two pooling operations are then summed and passed through a shared multilayer perceptron and a sigmoid activation function. Generate weights The calculation formula is: Step 2.1.2, calculate the vertical attention weights. , right Global average pooling and global max pooling are performed along the height H dimension respectively. The results of the two pooling are added together and then passed through the shared multilayer perceptron and the sigmoid activation function. Generate weights The calculation formula is: Step 2.1.3, Calculate spatial attention weights , right Global average pooling and global max pooling are performed along the channel C dimension. The results of the two pooling operations are then summed and processed through a kernel of size C. Separable convolutional layers with a fill size of N With the Sigmoid activation function Generate weights The calculation formula is: Step 2.1.4, calculate channel attention weights , For SLCAM1, SLCAM2, and SLCAM3 modules, global average pooling is used, and the calculation formula is as follows: For the SLCAM4 module, the calculation method is the difference between the global average pooling and global max pooling results. The formula is as follows: The generated weights are all ; Step 2.1.5 Feature Enhancement, The four weights obtained from the calculation , , , With input feature map Element-wise multiplication is performed to obtain the enhanced output feature map. The calculation formula is: in, For average pooling along the width dimension, For average pooling along the height dimension, For average pooling along the spatial dimension, For global max pooling, For max pooling along the width dimension, For max pooling along the height dimension, For max pooling along the spatial dimension, For global average pooling, It is a multilayer perceptron containing hidden layers of neurons; This indicates element-wise multiplication.

5. The method for detecting turbidity of slaughterhouse wastewater based on deep learning according to claim 4, characterized in that, In step 2.2, the feature fusion steps are as follows: Step 2.2.1: Unify and input the feature dimensions. The features of the four light source images were extracted using ConvNeXt-T Stage1-Stage2, resulting in the blue light source features. Characteristics of white light source Red light source characteristics NIR light source characteristics ;in, The feature dimension is represented by C, where C is the number of channels, H is the height, and W is the width. Step 2.2.2, Adaptive weighted balancing, Four learnable weights are introduced, namely , , , The four features are weighted and calibrated using the following formula: in, , , , These are the features after four-way weighting. This indicates element-wise multiplication of features; Step 2.2.3, Multi-scale feature interaction, The four-way weighted features are concatenated along the channel dimension to obtain... Three parallel CBR branches are designed: Conv2D, BN2D, and ReLU. These three parallel CBR branches capture multi-scale features, and the unified formula is: in, The kernel size is the convolution kernel size. Step size, This is the fill size; CBR1 branch output CBR2 branch output CBR3 branch output ; Step 2.2.4, Feature aggregation and dimensionality reduction, The three CBR branch features are summed element-wise, and the final output is obtained by dimensionality reduction using a 1×1 convolution. The formula is as follows: in, This is the output feature of the AMFF adaptive multimodal fusion module.

6. The method for detecting turbidity of slaughterhouse wastewater based on deep learning according to claim 4, characterized in that, In step 2.4, the specific steps are as follows: Step 2.4.1, Global Average Pooling, Features of Stage4+SLCAM4 output Perform global average pooling to transform it into a 2C-dimensional global feature vector. ; Step 2.4.2, Layer Normalization, For global feature vectors Perform layer normalization to regularize the feature distribution and output 2C-dimensional features. ; Step 2.4.3, Fully Connected Layer 1, right Nonlinear feature mapping is performed, and the 2C-dimensional features are transformed by combining the ReLU activation function. 3D features, output ; Step 2.4.4, Fully Connected Layer 2, right Perform a linear mapping, Transforming 3D features into 1D turbidity prediction values ,Right now .

7. The method for detecting turbidity of slaughterhouse wastewater based on deep learning according to claim 6, characterized in that, The specific steps for calculating the weighted error in step 2.5 are as follows: Step 2.5.1, divide the interval. The turbidity range is divided into low turbidity range, medium turbidity range, and high turbidity range; Step 2.5.2, calculate the number of valid samples for each interval, using the following formula: in, The number of valid samples in the interval. The attenuation coefficient is... Let be the actual number of samples in the i-th interval; Step 2.5.3, Interval weight adaptation, The formula for designing normalized interval weights is as follows: Where C and K are the turbidity interval numbers; Step 2.5.4, Regression Loss Fusion Combining interval weights and MSE loss, the formula is: Where N is the batch sample size. This is the interval index of the i-th sample. For predicted values, These are the actual measured values.

8. The method for detecting turbidity of slaughterhouse wastewater based on deep learning according to claim 1, characterized in that, In steps 1 and 5, the preprocessing method is as follows: Step a, Locating and extracting the square ROI. After converting the original images to grayscale, the Canny edge detection operator is used to extract the image edge information. The Hough line detection algorithm is combined to screen the two horizontal boundaries and two vertical boundaries of the detection slot. The intersection of the four boundaries is solved by the line equation to determine the coordinates of the four vertices of the square detection slot. Based on this coordinate set, the detection slot area is extracted as the ROI area, and background interference outside the area is removed. Step b: Geometric regularization and resolution unification. Based on the coordinates of the four vertices of the detection slot, a perspective transformation algorithm is used to correct geometric distortion, uniformly normalizing the square ROIs from different shooting angles into standard squares. A bilinear interpolation algorithm is then used to scale the normalized ROI proportionally, ensuring consistent resolution for all input images. The interpolation formula is: in, To scale the image in coordinates Pixel value at that location, These are the pixel coordinates of the scaled image. For the original image and The corresponding adjacent pixel coordinates, For the original image in Pixel value at; Step c, image standardization, Visible light images were normalized using the mean and standard deviation from the ImageNet dataset; NIR images are normalized using global mean and standard deviation; The normalization formula is: in, For the standardized image in Pixel value at that location, These are unnormalized pixel values ​​after scaling. The average pixel value. denoted as the pixel standard deviation.

9. The method for detecting turbidity of slaughterhouse wastewater based on deep learning according to claim 1, characterized in that: In step 3, when training the MTD-Net network, the training set adopts data augmentation strategies such as rotation, scaling, salt-and-pepper noise addition, and random erasure, while the validation set and test set do not undergo data augmentation. Training was implemented using the PyTorch framework, with early stopping strategy for iteration. The ConvNeXt-T backbone network used ImageNet pre-trained weights, and the SlCAM attention mechanism module and AMFF fusion module were initialized using Xavier normal distribution.

Citation Information

Patent Citations

  • Device for detecting turbidity on line and in real time

    CN102169079A

  • Underwater turbidity detection device based on image information

    CN116223455A