A method and system for detecting appearance defects of a water chamber sub-assembly based on machine vision
By using a machine vision-based method for detecting surface defects in water chamber sub-assemblies, combined with three-channel pixel data balancing and an improved YOLOv8 model, the problem of detecting deformation and positional displacement defects in water chamber sub-assemblies in industrial environments has been solved, achieving efficient and accurate defect identification and early warning.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEFEI MINGZUN PRECISION TECH CO LTD
- Filing Date
- 2026-05-10
- Publication Date
- 2026-07-31
AI Technical Summary
Existing image enhancement technologies cannot accurately identify deformation and positional displacement defects in water chamber assembly components in industrial environments, resulting in insufficient efficiency in appearance defect detection. Furthermore, they are susceptible to interference from ambient light and material reflections, making it difficult to meet the requirements for high-efficiency detection.
A machine vision-based detection method is adopted. By performing three-channel pixel data balancing processing, multi-scale feature restoration, and an improved YOLOv8 model on the water chamber assembly image, combined with contrast constraint calculation of background light value, the illumination interference is suppressed, key structural details are clearly highlighted, and an early warning system is linked.
It effectively suppresses interference from industrial ambient light and material surface reflection, clearly highlights the end contour, the edge of the flat tube hole and the boundary of the partition, improves the accuracy and efficiency of defect detection, and realizes accurate judgment of deformation and positional displacement.
Smart Images

Figure CN122492630A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of defect detection technology, specifically relating to a method and system for detecting appearance defects in water chamber assemblies based on machine vision. Background Technology
[0002] The water chamber assembly is a core component of the automotive cooling or thermal management system. It is mostly made of aluminum alloy and is mainly responsible for the distribution, convergence, and uniform distribution of coolant to ensure stable heat dissipation of the battery or engine. It is a key structure to ensure smooth heat exchange circuit and reliable sealing. If there are appearance defects such as end / flat tube hole deformation, or misalignment of partition and code position during its production process, it is easy to cause coolant leakage, uneven flow distribution, heat dissipation failure, and even affect battery safety and vehicle operation.
[0003] Most of the visual defect inspection of water chamber assembly is carried out in industrial environments. It is subject to multiple complex interferences such as non-uniform workshop lighting, component curved surface composite structure, and the superposition of mirror reflection and local shadows of metal mixed materials. This results in the collection of water chamber assembly images with problems such as loss of details in low light areas, overexposure in reflective areas, micro-deformation, fine scratches, and misalignment of characters or partitions. In industrial environments, existing image enhancement technologies often use a single dark channel prior for background light estimation, which is easily affected by bright areas of the workpiece and structural edges, leading to calculation deviations. Moreover, existing enhancement methods are mostly single-scale uniform processing, which makes it difficult to adaptively enhance end contours, flat tube hole edges, partition boundaries, and engraved code details. This can easily cause geometric feature distortion, weakening of subtle defect features, and overcorrection, making it impossible to accurately identify component deformation and positional offset defects. Consequently, it is difficult to meet the high-efficiency detection requirements for the appearance defects of water chamber assemblies. Summary of the Invention
[0004] The purpose of this invention is to solve the problem that existing image enhancement technologies cannot accurately identify component deformation and positional displacement defects due to the influence of ambient light in industrial environments, resulting in insufficient efficiency in detecting appearance defects of water chamber assembly. Therefore, this invention proposes a machine vision-based method and system for detecting appearance defects of water chamber assembly.
[0005] In a first aspect of this invention, a method for detecting appearance defects in a water compartment assembly based on machine vision is first proposed, the method comprising: A standardized image of the water chamber assembly to be tested is acquired, and the standardized image is enhanced to obtain a first image; Extract the three-channel pixel data from the first image, perform channel balancing processing on the three-channel pixel data to output the second image, and calculate the background light value of the three channels based on the contrast constraint of the second image. The final feature-enhanced image is obtained by performing multi-scale feature recovery based on the first image and the background light value; The final feature-enhanced image is input into a preset defect detection model to output defect detection results; the defect detection model is based on YOLOv8 and the improvement includes: replacing the Conv module in the backbone network of the YOLOv8 model with the target Conv module and replacing the C2f module with the target C2f module; Based on the defect detection results, an early warning is triggered, an early warning report is generated, and uploaded to the cloud.
[0006] Optionally, the standardized image is enhanced to obtain a first image, including: The standardized image is divided into N×N image sub-blocks, and the histogram clipping threshold is calculated for each image sub-block. The grayscale histogram of each image sub-block is statistically analyzed. The pixels of the grayscale histogram of each image sub-block are marked as cropped pixels by the cropping threshold. The cropped pixels of all image sub-blocks are summed to obtain the total number of allocatable cropped pixels. Traverse the cropped grayscale histograms and allocate pixels according to a preset rule based on the total number of allocable cropped pixels to obtain the histogram of the first stage image sub-blocks, which is defined as the first histogram. The dynamic step size is calculated for the remaining unallocated cropped pixels according to a preset algorithm. The remaining cropped pixels are then cyclically allocated to the first histogram at dynamic step size intervals until all remaining cropped pixels are allocated, thus obtaining the final grayscale histogram of the second-stage image sub-block, which is defined as the second histogram. The second histogram of each image sub-block is equalized and bilinearly interpolated, and then stitched together to obtain the first image.
[0007] Optionally, a second image is output by performing channel balancing on the three-channel pixel data, including: The red-green channel pixel difference is calculated based on the red channel pixel values and green channel pixel values in the first image; The green channel normalization factor is calculated based on the maximum pixel value of the green channel, and the red channel pixel attenuation factor is calculated based on the pixel value of the red channel. The comprehensive attenuation factor is obtained by weighted fusion of the red-green channel pixel difference, the green channel normalization factor, and the red channel pixel attenuation factor. The ideal red channel pixel without attenuation is calculated based on the comprehensive attenuation factor, and the original attenuated red channel pixel is replaced to obtain a color image with the red channel restored. The three-channel pixels of the color image are traversed, and the combined statistics of the three-channel pixels are calculated to obtain the mixed statistics of each channel; the mixed statistics include the mixed pixel mean and the mixed pixel standard deviation; Using the green channel as the brightness benchmark, the compensation coefficients for the red, green, and blue channels are calculated respectively. Based on the mixing statistics and compensation coefficients, the dynamic constraint range of pixels is set, and pixel values that exceed the constraint range are cropped to the boundary to obtain the second image.
[0008] Optionally, the background light values of the three channels are calculated based on the contrast constraint of the second image, including: The dark channel value and bright channel value are extracted from each pixel in the second image by traversing all pixels in the second image using a first local window of size m×m. Extract a preset number of pixels from the dark channel value and the bright channel value respectively to obtain the first group of pixels and the second group of pixels. After merging the first group of pixels and the second group of pixels, perform deduplication to obtain the candidate region of the background light. For each pixel in the candidate region, take a second local window of size n×n and calculate the local contrast of grayscale pixels in the second local window. Filter out the effective weights of all pixels in the candidate region based on the local contrast and the contrast threshold. The background light value of each channel is obtained by weighting the three channels of the pixels in the candidate region according to the effective weights.
[0009] Optionally, multi-scale feature recovery is performed based on the first image and the background light value to obtain the final feature-enhanced image, including: An adaptive weight map is calculated for each pixel and background light value in the first image, and the adaptive transmittance is calculated by substituting the adaptive weight map into a preset formula. The initial feature-enhanced image is obtained by calculating the standardized image, background light value, and adaptive transmittance. Extract the mid-frequency and high-frequency components from the initial feature-enhanced image; The high-frequency component weight and the mid-frequency component weight are calculated pixel by pixel based on the preset scaling factor. The high-frequency component weight and the mid-frequency component weight are multiplied element by element with the corresponding frequency domain component and then added together to obtain the detail compensation component. The initial feature-enhanced image is added pixel-by-pixel to the detail compensation component to obtain the final feature-enhanced image.
[0010] Optionally, the defect detection model is based on an improved version of YOLOv8, and the improvements include: The Conv modules in layers 1, 3, 5, and 7 of the YOLOv8 model backbone network are replaced with target Conv modules; the target Conv modules are used to fuse local fine-grained features with global context information to reduce feature loss during downsampling of small defects on the aluminum profile surface. The C2f modules in layers 2, 4, 6 and 8 are replaced with target C2f modules; the target C2f modules are used to expand the receptive field and enhance the feature extraction and fusion capabilities of multi-scale aluminum profile surface defects without increasing parameters; Replace all C2f modules in the neck network of the YOLOv8 model with the target C2f module.
[0011] Optionally, the target Conv module works as follows: The first input feature map is obtained, and then the first input feature map is input into the Conv module. Then, the first target feature map and the second target feature map are obtained by inputting the first input feature map into the parallel Conv module with two different convolution kernels respectively. The first target feature map and the second target feature map are concatenated and then subjected to batch normalization and PReLU function activation to obtain the third target feature map; The third target feature map is processed sequentially by average pooling and two fully connected layers to output the fourth target feature map. The third and fourth target feature maps are fused to obtain the fifth target feature map, which is then used as the input for the next module.
[0012] Optionally, the improvement to the target C2f module includes: Replace DarknetBottleneck in the C2f module with the target Bottleneck module; The working principle of the target Bottleneck module is as follows: Obtain the second input feature map, input the input feature map into the DWR module to obtain the first convolutional feature map, and input the first convolutional feature map into the Conv module to obtain the second convolutional feature map; The second convolutional feature map is input into a parallel Conv module with three different convolutional kernels to obtain the third convolutional feature map; The third convolutional feature map is sequentially input into the Conv module and the DWR module to obtain the fourth convolutional feature map, which is then used as the input for the next module.
[0013] Optionally, an early warning report is generated based on the defect detection results, including: Obtain the defect type, defect location coordinates, and confidence score from the defect detection results; According to a preset defect level mapping table, the defect type and confidence score are matched with the corresponding warning level; the warning level includes low risk warning, medium risk warning and high risk warning. Based on the defect location coordinates, the defect area image is extracted from the final feature-enhanced image, and the defect area image, defect type, confidence score, and warning level are integrated to generate a structured warning record; The structured early warning records are compared with a preset defect knowledge base. If the defect type is a repetitive defect, the defect frequency is accumulated and trend analysis data is generated. Based on the warning level and defect frequency, corresponding warning actions are triggered; the warning actions include recording logs and pushing them to the monitoring dashboard when the risk warning is low, sending information to notify the quality inspector when the risk warning is medium, and immediately stopping the testing line and issuing an audible and visual alarm when the risk warning is high. All structured early warning records, trend analysis data, and triggered early warning actions are packaged into an early warning report and uploaded to the cloud server.
[0014] In a second aspect of this invention, a machine vision-based water compartment assembly appearance defect detection system is provided, the system comprising: An enhancement module is used to acquire a standardized image of the water chamber assembly to be tested, and to enhance the standardized image to obtain a first image; The balancing module is used to extract three-channel pixel data from the first image, perform channel balancing processing on the three-channel pixel data to output a second image, and calculate the background light value of the three channels based on the contrast constraint calculation of the second image. The recovery module is used to perform multi-scale feature recovery based on the first image and the background light value to obtain the final feature-enhanced image; The detection module is used to input the final feature-enhanced image into a preset defect detection model and output the defect detection result; the defect detection model is based on YOLOv8 and the improvement includes: replacing the Conv module in the backbone network of the YOLOv8 model with the target Conv module and replacing the C2f module with the target C2f module; The upload module is used to trigger an early warning based on the defect detection results, generate an early warning report, and upload it to the cloud.
[0015] The beneficial effects of this invention are: This invention proposes a machine vision-based method for detecting appearance defects in water chamber sub-assemblies. By performing enhanced preprocessing on standardized images of the water chamber sub-assemblies, correcting imaging color difference and brightness deviation through three-channel balance, accurately calculating background light values by combining contrast constraints, and then performing multi-scale feature restoration to enhance key structural details, the method effectively suppresses interference from industrial ambient light and material surface reflection, clearly highlighting end contours, flat tube hole edges, partition boundaries, and character features. Based on the defect model, the method accurately identifies deformation and positional deviations and provides linked early warnings, thereby improving the accuracy of defect detection. Attached Figure Description
[0016] The invention will now be further described with reference to the accompanying drawings.
[0017] Figure 1 A flowchart of a machine vision-based method for detecting appearance defects in a water chamber assembly is provided in an embodiment of the present invention; Figure 2 This is a network architecture diagram of the defect detection model provided in an embodiment of the present invention; Figure 3 This is a network structure diagram of the target C2f module provided in an embodiment of the present invention; Figure 4 This is a network structure diagram of the target Bottleneck module provided in an embodiment of the present invention; Figure 5 This is a network structure diagram of the target Conv module provided in an embodiment of the present invention; Figure 6 This is an illustration of the effect of visual defect detection of the water chamber assembly provided in an embodiment of the present invention; Figure 7 A partially enlarged view of the water chamber assembly appearance defect detection provided in this embodiment of the invention. Detailed Implementation
[0018] 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. The term "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and B can represent: A alone, A and B simultaneously, and B alone. Furthermore, descriptions involving "first," "second," etc., in this invention are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined with "first" or "second" can explicitly or implicitly include at least one of those features. Additionally, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention.
[0019] 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.
[0020] This invention provides a machine vision-based method for detecting appearance defects in water compartment assemblies. See also... Figure 1 , Figure 1A flowchart illustrating a machine vision-based method for detecting appearance defects in a water compartment assembly, provided as an embodiment of the present invention. The method includes the following steps: S1, acquire a standardized image of the water chamber assembly to be tested, and perform enhancement processing on the standardized image to obtain the first image; S2, extract the three-channel pixel data from the first image, perform channel balancing processing on the three-channel pixel data to output the second image, and calculate the background light value of the three channels based on the contrast constraint of the second image; S3, perform multi-scale feature recovery based on the first image and background light value to obtain the final feature-enhanced image; S4, input the final feature-enhanced image into the preset defect detection model and output the defect detection result; S5 triggers an early warning based on the defect detection results, generates an early warning report, and uploads it to the cloud.
[0021] The defect detection model is based on an improvement of YOLOv8. The improvements include replacing the Conv module in the backbone network of the YOLOv8 model with the target Conv module and replacing the C2f module with the target C2f module.
[0022] The present invention provides a machine vision-based method for detecting appearance defects in water chamber sub-assemblies. This method enhances the standardized image of the water chamber sub-assembly by performing enhanced preprocessing, correcting the color difference and brightness deviation of the image through three-channel balance, accurately calculating the background light value by combining contrast constraints, and then performing multi-scale feature restoration to enhance key structural details. This effectively suppresses interference from industrial lighting and material surface reflection, clearly highlighting the end contour, the edge of the flat tube hole, the partition boundary and the character features. Based on the defect model, the method accurately identifies deformation and position deviation and provides linked early warning, thereby improving the accuracy of defect detection.
[0023] In one implementation, the original image of the water chamber assembly to be tested is acquired, and the original image is preprocessed to obtain a standardized image. The process is as follows: Initialize fixed parameters: initial neighborhood radius is 3, maximum neighborhood radius is 8, and total number of gray levels is 256; Traverse each pixel position of the original image pixel by pixel, and construct a square neighborhood window with the current pixel as the center and an initial radius. Calculate the maximum, minimum, and median pixel values within a square neighborhood window; If the median value in the square neighborhood window is an extreme value (maximum or minimum), the neighborhood radius is dynamically expanded until a non-extreme median value is found. If the center pixel value equals the window extremum, it is determined to be a noise point and replaced with the window midpoint; otherwise, the original pixel value is retained. Complete pixel traversal of the entire original image and perform global denoising to obtain a standardized image.
[0024] In one implementation, the size of the filtering window is dynamically adjusted to preserve key detection details such as image edges and foreign object contours to the greatest extent possible, thereby avoiding excessive amplification of noise during subsequent image enhancement and ensuring the accuracy and effectiveness of subsequent foreign object detection.
[0025] In one embodiment, enhancing a standardized image to obtain a first image includes: The standardized image is divided into N×N image sub-blocks, and the clipping threshold of the histogram is calculated for each image sub-block. The grayscale histogram of each image sub-block is statistically analyzed. The pixels in the grayscale histogram of each image sub-block are marked as clipping pixels by a clipping threshold. The clipping pixels of all image sub-blocks are summed to obtain the total number of allocable clipping pixels. Traverse the cropped grayscale histograms and allocate pixels according to a preset rule based on the total number of allocable cropped pixels to obtain the histogram of the first stage image sub-blocks, which is defined as the first histogram. The dynamic step size is calculated for the remaining unallocated cropped pixels according to a preset algorithm. The remaining cropped pixels are then cyclically allocated to the first histogram at dynamic step size intervals until all remaining cropped pixels are allocated. This yields the final grayscale histogram of the second-stage image sub-block, which is defined as the second histogram. The second histogram of each image sub-block is equalized and bilinearly interpolated, and then stitched together to obtain the first image.
[0026] In one implementation, the cropping threshold = fixed parameter × total number of gray levels × number of pixels in a single image sub-block.
[0027] In one implementation, the total number of allocatable cropped pixels is allocated according to a preset rule to obtain a histogram of the first-stage image sub-blocks. The preset rule includes: If the current number of pixels is greater than or equal to the cropping threshold, no cropping pixels are assigned, and the number of pixels is directly fixed to the cropping threshold. If the cropping threshold - current number of pixels < current number of pixels < cropping threshold, then the number of pixels to be added is calculated as cropping threshold - current number of pixels. The current number of pixels is added to the cropping threshold, and the number of pixels to be added is deducted from the total number of available cropping pixels. If the current number of pixels is less than or equal to the cropping threshold minus the standard supplementary pixels, then the current number of pixels will be supplemented with the standard supplementary pixels, and the standard supplementary pixels will be deducted from the total number of available cropping pixels.
[0028] In one implementation, the dynamic step size is calculated for the remaining unallocated cropped pixels according to a preset algorithm. The preset algorithm is as follows: Where S is the dynamic step size. This represents the total number of allocatable crop pixels.
[0029] In one implementation, by enhancing the defect images of industrial water chamber assembly components with low light, uneven brightness and specular reflection interference, the overall brightness and local contrast of the image are effectively improved, and the details of minor defects such as end deformation, flat pipe hole deformation, partition and code misalignment are clearly restored. At the same time, the problems of over-enhancement, block effect, noise amplification and distortion of reflective areas of metal surface that are easy to occur in traditional enhancement processing are avoided.
[0030] In one implementation, compared to existing image enhancement technologies such as CLAHE, the uniform distribution of cropped pixels is abandoned. Instead, a two-stage pixel allocation strategy is adopted, which prioritizes on-demand filling and is supplemented by dynamic step-size uniform spreading. This makes the pixel allocation more consistent with the grayscale distribution of metal surface images, which not only enhances the distinction between defects and background, but also suppresses artifacts and preserves key defect details, thus greatly improving the applicability and effect of enhancing surface defect images of industrial water chamber assembly components.
[0031] In one embodiment, channel balancing processing is performed on the three-channel pixel data to output a second image, including: The red-green channel pixel difference is calculated based on the red channel pixel values and green channel pixel values in the first image; The green channel normalization factor is calculated based on the maximum pixel value of the green channel, and the red channel pixel attenuation factor is calculated based on the pixel value of the red channel. The comprehensive attenuation factor is obtained by weighted fusion of the pixel difference in the red and green channels, the normalization factor of the green channel, and the pixel attenuation factor of the red channel. The ideal red channel pixels without attenuation are calculated based on the comprehensive attenuation factor, and the original attenuated red channel pixels are replaced to obtain a color image with restored red channel. The three-channel pixels of the color image are traversed, and the joint statistics of the three-channel pixels are calculated to obtain the mixture statistics of each channel; the mixture statistics include the mean and standard deviation of the mixture pixels. Using the green channel as the brightness benchmark, the compensation coefficients for the red, green, and blue channels are calculated respectively. Based on the mixing statistics and compensation coefficients, the dynamic constraint range of pixels is set, and pixel values that exceed the constraint range are cropped to the boundary to obtain the second image.
[0032] In one implementation, the global mean of the red channel and the global mean of the green channel are calculated from the pixel values of the red channel and the pixel values of the green channel in the first image, respectively, and the difference between the two is obtained as the pixel difference between the red and green channels.
[0033] In one implementation, the green channel normalization factor is calculated based on the maximum pixel value of the green channel, and the red channel pixel attenuation factor is calculated based on the pixel value of the red channel. The calculation process is as follows: The green channel normalization factor is obtained by dividing the current green channel pixel value by the maximum green channel pixel value. Subtract the ratio of the current red channel pixel value to 255 from 1 to obtain the red channel pixel attenuation factor.
[0034] In one implementation, the ideal red channel pixel without attenuation is calculated based on the comprehensive attenuation factor. The process is as follows:
[0035]
[0036] in, and These are the global mean values for the red channel and the green channel, respectively. This represents the current green channel pixel value at coordinate x. This represents the maximum pixel value of the green channel. The original attenuated red channel pixel at coordinate x. The ideal red channel pixel at coordinate x is the one without attenuation. is the red channel attenuation compensation coefficient, with experimental values ranging from 1.0 to 1.5; D is the comprehensive attenuation factor.
[0037] In one implementation, a joint statistical measure is performed on the three-channel pixels to obtain the mixed statistical measure of each channel. The process is as follows: The global mean and global variance of each of the three channels are calculated separately. The global mean of each channel is averaged to obtain the joint mean, and the global variance of each channel is averaged to obtain the joint standard deviation. The mean and standard deviation of the mixed pixels are calculated based on the joint mean and joint variance.
[0038]
[0039] in, and These are the mean and standard deviation of the mixed pixels, respectively. , , These are the global average values for the three RGB channels, respectively. and These are the joint mean and joint standard deviation, respectively. , , These are the global variances of the three RGB channels, respectively. The preset blending weights are used to control the intensity of color correction.
[0040] In one implementation, the constraint range for pixel dynamics is set based on the hybrid statistics and compensation coefficients. The process is as follows:
[0041]
[0042]
[0043] in, , , These are the compensation coefficients for the red, green, and blue channels, respectively. To compensate for the intensity factor, For a minimal constant such as To prevent the denominator from being 0; The constraint range includes a dynamic upper bound and a dynamic lower bound for pixels, and the calculation process is as follows:
[0044]
[0045] in, and These are the dynamic upper bound and the dynamic lower bound of pixels, respectively. This indicates element-wise multiplication; the dynamic upper bound of pixels is used to avoid overexposure of highlights, and the dynamic lower bound of pixels is used to avoid loss of shadow details.
[0046] In one implementation, in the scenario of surface defect detection of industrial water chamber assembly components, metal surfaces are prone to strong light reflection, interference from oil and sewage fog, and uneven lighting. The green channel is least affected by metal mirror reflection and color shift interference, retains the most complete imaging information, and has the brightness closest to the real surface features. Therefore, the green channel is selected as the brightness reference. Using the green channel as the brightness reference means using the brightness characteristics of the green channel as the global correction standard. The same compensation intensity factor is used to calculate the compensation coefficients of the red and blue channels. The compensation coefficients of the red and blue channels are calculated according to this standard, thereby eliminating the brightness distortion and color shift of the metal surface, ensuring the brightness of the defect area is uniform, and the details of the minor defects are not disturbed.
[0047] In one implementation, in the scenario of industrial metal surface defect detection, color channel restoration solves the problems of image RGB channel brightness imbalance, color deviation, and brightness distortion in defect areas caused by strong specular reflection, oil and sewage fog coverage, and uneven workshop lighting. It repairs the distorted channels caused by interference and corrects the global color and brightness, restoring the true texture and defect features of the metal surface.
[0048] In one embodiment, the background light values of the three channels are calculated based on the contrast constraint of the second image, including: The background light values for the three channels are obtained by contrast constraint calculation based on the second image, including: The dark channel value and bright channel value are extracted from each pixel in the second image by traversing all pixels in the first local window of size m×m. Extract a preset number of pixels from the dark channel value and the bright channel value respectively to obtain the first group of pixels and the second group of pixels. After merging the first group of pixels and the second group of pixels, perform deduplication to obtain the candidate region of the background light. For each pixel in the candidate region, take a second local window of size n×n and calculate the local contrast of grayscale pixels in the second local window. Filter out the effective weights of all pixels in the candidate region based on the local contrast and the contrast threshold. The background light value of each channel is obtained by weighting the three channels of the pixels in the candidate region according to the effective weights.
[0049] In one implementation, the minimum value of the RGB three channels of each pixel in the first local window is taken, and the global minimum value is taken from all the minimum values in the first local window as the dark channel value of the current pixel. For each pixel within the first local window, take the maximum value of the RGB three channels. Then, take the global maximum value from all the maximum values within the first local window and use it as the brightness channel value of the current pixel.
[0050] In one implementation, the dark channel values and bright channel values of all pixels are sorted in descending order, and the pixels with the highest brightness in the dark channel values (which can be 0.1%) are extracted as the first group of pixels, and the pixels with the highest brightness in the bright channel values are extracted as the second group of pixels.
[0051] In one implementation, the effective weights of all pixels within the candidate region are selected based on local contrast and a contrast threshold. The process is as follows: Take a 5×5 second local window and calculate the mean and standard deviation of grayscale pixels within the window;
[0052] in, For grayscale pixels within the second local window Local contrast at coordinates; and The grayscale pixels are respectively in Mean and standard deviation at coordinates For a minimal constant such as To prevent the denominator from being 0; like If the contrast ratio is not less than the contrast threshold, it is determined to be a high-contrast interference area, with an effective weight. ; like If the contrast ratio is less than the contrast threshold, it is considered a valid background light area, and the effective weight is determined accordingly. ;in, For pixels in Mean brightness at coordinates.
[0053] In one implementation, the calculation process for the background light value of each channel is as follows:
[0054] in, In order to be in Background light value of channel c at coordinates [location] For pixels within the candidate region The original pixel brightness value on channel c at coordinate T, where T is the candidate region and c is any one of the three RGB channels.
[0055] In one implementation, background light estimation using dual-channel priors and contrast constraints effectively solves the problems of high-brightness reflection caused by strong specular reflection on metal surfaces, oil and sewage fog coverage, uneven lighting in workshops, and interference from high-contrast defect areas in accurate background light estimation. This obtains pure background light unaffected by industrial stray light and surface defects, providing a reliable benchmark for subsequent transmittance calculations and defect detail enhancement.
[0056] In one implementation, the accuracy and robustness of background light estimation in highly turbulent industrial imaging scenarios are significantly improved by fusing the dark channel and bright channel priors to cover complex industrial imaging areas such as high reflectivity and fog-like blur, and by combining local contrast constraints to filter high-contrast interference such as bright spots and scratches on aluminum materials.
[0057] In one embodiment, multi-scale feature recovery based on a first image and background light values is performed to obtain a final feature-enhanced image, including: An adaptive weight map is calculated for each pixel and background light value in the first image. The adaptive transmittance is then calculated by substituting the adaptive weight map into a preset formula. The initial feature-enhanced image is obtained by calculating the standardized image, background light value, and adaptive transmittance. Extract the mid-frequency and high-frequency components from the initial feature enhancement image; The high-frequency component weight and the mid-frequency component weight are calculated pixel by pixel based on the preset scaling factor. The high-frequency component weight and the mid-frequency component weight are multiplied element by element with the corresponding frequency domain component and then added together to obtain the detail compensation component. The initial feature-enhanced image is added pixel by pixel to the detail compensation component to obtain the final feature-enhanced image.
[0058] In one implementation, an adaptive weight map is calculated for each pixel and background light value in the first image, including: For each pixel in the first image, calculate the L2 norm distance between the pixel value and the background light value, and then divide it by the L2 norm of the background light value itself to obtain the fog density quantization ratio. Subtract the fog density quantization ratio from 1 to obtain the adaptive weight map.
[0059] In one implementation, the adaptive transmittance is calculated by substituting the adaptive weight map into a preset formula, including:
[0060] in, This represents the initial transmittance of pixel x. Represents the adaptive weight map of pixel x. This represents a local window centered at x. This represents the c-channel value of the y-value within the window. This refers to the background light value of channel c; Initial transmittance All pixel values are limited to the range [0.1, 1.0] to avoid division by zero errors caused by values that are too small, and blurring failure caused by values that are too large. Guided filtering is used to smooth the restricted transmittance image, removing noise, block effects, and edge distortion to obtain adaptive transmittance.
[0061] In one implementation, an initial feature-enhanced image is calculated from the standardized image, background light value, and adaptive transmittance, including:
[0062] in, Enhance the image with initial features. For standardized images.
[0063] In one implementation, extracting the mid-frequency and high-frequency components from the initial feature-enhanced image includes: Mean filtering is applied to the initial feature-enhanced image to extract low-frequency components, which are used to characterize the overall illumination and background light. The low-frequency component is mean-filtered again, and the filtering result is subtracted from the low-frequency component to obtain the mid-frequency component, which is used to characterize the object contour and texture transition. By subtracting low-frequency components from the image enhanced with initial features, high-frequency components are obtained, which are used to characterize edges, textures, and fine features.
[0064] In one implementation, the weights of the high-frequency components and the intermediate-frequency components are calculated pixel by pixel according to a preset scaling factor, including: The local standard deviation of the high-frequency component and the local standard deviation of the mid-frequency component are calculated pixel by pixel by traversing the image using an 11×11 window. The weights of the high-frequency components and the intermediate-frequency components are calculated based on the local standard deviations of the high-frequency components and the intermediate-frequency components.
[0065]
[0066] in, and These are the high-frequency component weights and the mid-frequency component weights, respectively. and These are the scaling factors for the high-frequency components and the intermediate-frequency components, respectively. and These are the local standard deviations of the high-frequency component and the mid-frequency component, respectively.
[0067] In one implementation, multi-scale detail restoration compensates for the edge weakening caused by previous image correction and anti-interference processing, improves the problems of blurred component end contours, unclear deformed edges of flat tube holes, weakened partition boundary features, and shallow text engraving texture, highlights various key structural boundaries and engraving details, and provides clear image features for deformation determination, component position verification, and text position verification. In one implementation, the image background, structural contour and fine texture are decomposed into layers at multiple scales, and the fusion weights are adaptively allocated according to the local standard deviation. This can specifically enhance the end shape, hole edge, partition boundary line and character stroke details without causing structural distortion and feature distortion, effectively ensuring the accuracy and stability of size deformation, assembly position and engraving position detection.
[0068] In one embodiment, the defect detection model is based on an improvement of YOLOv8, the improvements including: The Conv modules in layers 1, 3, 5, and 7 of the YOLOv8 model backbone network are replaced with target Conv modules. The target Conv modules are used to fuse local fine-grained features with global contextual information to reduce feature loss during downsampling of small defects on the aluminum profile surface. Replace the C2f modules in layers 2, 4, 6, and 8 with target C2f modules; the target C2f modules are used to expand the receptive field without increasing parameters, thereby enhancing the feature extraction and fusion capabilities of multi-scale aluminum profile surface defects. Replace all C2f modules in the neck network of the YOLOv8 model with the target C2f module.
[0069] In one implementation, see [link to implementation details]. Figure 2 , Figure 2This is a network architecture diagram of the defect detection model provided in this embodiment of the invention. Addressing the issues of surface reflection and complex background interference on metal components of water chamber assemblies in industrial environments, traditional YOLOv8 is prone to feature loss, insufficient receptive field, missed detection of small targets, and positioning errors in detecting minute surface defects. This invention replaces the original Conv convolution with a target Conv module, fusing local fine-grained features with global context to reduce micro-defect feature loss. The target C2f module employs multi-branch dilated convolution to expand the receptive field and enhance multi-scale defect feature extraction without increasing the number of parameters, achieving accurate capture of fine-grained geometric deformation features and precise positioning of small targets. These two improvements synergistically optimize feature extraction, fusion, and small target detection and positioning capabilities, significantly improving detection accuracy while reducing the number of model parameters.
[0070] In one implementation, the training dataset used by the defect detection model consists of the AL-DET dataset and a self-built dataset, with the training dataset divided into a 7:2:1 ratio: training set: validation set: test set; The software environment during training is as follows: Operating system: Ubuntu 20.04.3 LTS, deep learning framework: PyTorch, computing environment: CUDA 10.2; hardware environment: CPU: AMD EPYC 7551P, GPU: RTX 4060 Ti.
[0071] In one implementation, defects are detected in the metal components of the water chamber assembly using a base YOLOv8 and defect detection model based on the training dataset. The main defect detection results are shown in Table 1. Table 1
[0072] As can be clearly seen from Table 1 above, among the four types of defect features—end deformation, pipe hole deformation, and deviations in baffle position and code position—the accuracy, recall, and mAP@0.5 of the defect detection model are significantly better than the traditional YOLOv8 model, making it more suitable for defect detection of metal components in water chamber assemblies in industrial environments.
[0073] In one embodiment, the target Conv module works as follows: Obtain the first input feature map, input the first input feature map into the Conv module, and then input it into two parallel Conv modules with different convolution kernels to obtain the first target feature map and the second target feature map; The first target feature map and the second target feature map are concatenated and then subjected to batch normalization and PReLU function activation to obtain the third target feature map; The third target feature map is processed sequentially by average pooling and two fully connected layers to output the fourth target feature map. The third and fourth target feature maps are fused to obtain the fifth target feature map, which is then used as the input for the next module.
[0074] In one implementation, see [link to implementation details]. Figure 5 , Figure 5 This is a network structure diagram of the target Conv module provided in this embodiment of the invention. The target Conv module extracts the first and second target feature maps of multi-scale local details through parallel convolution with different convolution kernels. After concatenation, batch normalization, and PReLU (an existing activation function) activation to enhance fine-grained feature expression, a third target feature map is obtained to preserve the texture of small defects on the metal surface. The third target feature map is then processed by average pooling and dual fully connected layers to generate global channel weights to achieve global context awareness and channel attention weighting. Finally, the global semantic features of the third target feature map and the local fine features of the fourth target feature map are fused. When replacing the original downsampling Conv convolution, it effectively alleviates the feature loss caused by downsampling of small defects, takes into account both local details and global information, and significantly improves the model's feature extraction and recognition accuracy for subtle defects.
[0075] Table 2 shows the comparison results of downsampling experiments performed on the backbone network using three different convolutional modules in one implementation method: Table 2
[0076] Wherein, 1 is the Conv module, 2 is the LDConv module (linear deformable convolution), and 3 is the target Conv module; Params / M refers to the total number of model parameters in millions, used to measure model size and memory usage, the smaller the value, the more lightweight the model; Flops / G is the floating-point operation quantity, used to measure the computational complexity and inference time of the model, the smaller the value, the lower the computational cost and the faster the inference speed; As can be seen from Table 2, the target Conv module outperforms the Conv module in all three performance indices, but its Params / M and Flops / G performance indices are slightly lower than those of the LDConv module. However, its overall performance is superior to that of the LDConv module.
[0077] In one embodiment, the improvement to the target C2f module includes: Replace DarknetBottleneck in the C2f module with the target Bottleneck module; The working principle of the target Bottleneck module is as follows: Obtain the second input feature map, input the input feature map into the DWR module to obtain the first convolutional feature map, and input the first convolutional feature map into the Conv module to obtain the second convolutional feature map; The second convolutional feature map is input into three parallel Conv modules with different convolutional kernels to obtain the third convolutional feature map; The third convolutional feature map is sequentially input into the Conv module and the DWR module to obtain the fourth convolutional feature map, which is then used as the input for the next module.
[0078] In one implementation, see [link to implementation details]. Figure 3 , Figure 3 The network structure diagram of the target C2f module provided in the embodiment of the present invention is shown. By replacing the original C2f DarknetBottleneck with the target Bottleneck, the receptive field is expanded without increasing the number of parameters and computational cost. It can simultaneously extract defect features of different scales (small, medium, and large), enhance the multi-scale feature fusion capability, and retain residual connections to ensure training stability and avoid gradient vanishing.
[0079] In one implementation, see [link to implementation details]. Figure 4 , Figure 4 The network structure diagram of the target Bottleneck module provided in the embodiment of the present invention is shown; wherein, the front-end Conv module is a 1×1 convolutional kernel, the three middle Conv modules are all 3×3 convolutional kernels, and the last Conv module is a 5×5 convolutional kernel.
[0080] In one implementation, the receptive field is expanded through multi-branch dilated residual convolution of the first DWR (multi-scale dilated residual module) module without significantly increasing the number of parameters, efficiently capturing multi-scale defect features and ensuring training stability by utilizing residual connections; the middle single Conv and three parallel Conv structures first complete the basic alignment of the channel dimension, and then extract differential local detail features through multi-branch parallel convolution, and subsequent convolutions achieve efficient fusion of multi-scale features; the fused features are then refined at multiple scales by the DWR module. The overall structure, through a combination of global multi-scale feature extraction and local detail enhancement, compensates for the deficiencies of the original C2f module, such as insufficient receptive field and weak multi-scale feature fusion capability of the standard Darknet Bottleneck, and significantly enhances the model's ability to extract and represent features of defects of different sizes and shapes on metal surfaces.
[0081] In one embodiment, triggering an early warning and generating an early warning report based on defect detection results includes: Obtain the defect type, defect location coordinates, and confidence score from the defect detection results; According to the preset defect level mapping table, the defect type and confidence score are matched with the corresponding warning level; the warning levels include low risk warning, medium risk warning and high risk warning. Based on the defect location coordinates, the defect area image is extracted from the final feature-enhanced image, and the defect area image, defect type, confidence score, and warning level are integrated to generate a structured warning record; The structured early warning records are compared with the preset defect knowledge base. If the defect type is a repetitive defect, the defect frequency is accumulated and trend analysis data is generated. Based on the warning level and defect frequency, corresponding warning actions are triggered. Warning actions include logging and pushing to the monitoring dashboard when the risk is low, sending information to notify the quality inspector when the risk is medium, and immediately stopping the inspection line and issuing an audible and visual alarm when the risk is high. All structured early warning records, trend analysis data, and triggered early warning actions are packaged into an early warning report and uploaded to the cloud server.
[0082] In one implementation, a graded judgment is completed based on key parameters of defect detection, and a standardized early warning record is constructed by combining defect area screenshots to ensure that defect information is complete and intuitive. By connecting to the defect knowledge base, the frequency of repeated defects is counted and trend data is generated to achieve defect tracing and routine analysis. Simultaneously, differentiated handling strategies are implemented based on different early warning levels, precisely matching control intensity and implementing prevention and control measures at different levels. All early warning data is integrated to form reports and stored in the cloud, efficiently improving defect response and handling efficiency, achieving closed-loop management of the entire defect process, and strengthening the ability to prevent and control industrial production quality risks.
[0083] In one implementation, see [link to implementation details]. Figure 6 , Figure 6 This is an illustration of the effect of visual defect detection of the water chamber assembly provided in an embodiment of the present invention; Figure 6 This is a rendering of the flat tube hole after processing. Basic information about the component can be obtained from the drawing.
[0084] In one implementation, see [link to implementation details]. Figure 7 , Figure 7 A partially enlarged view of the water chamber assembly appearance defect detection provided in this embodiment of the invention; Figure 7 This is a magnified view of a flat tube hole. Based on the basic information, the defect type, defect coordinate location, confidence score, and early warning risk level are determined. Production control of the water chamber assembly components is then implemented based on this information.
[0085] Based on the same inventive concept, this invention also provides a machine vision-based water chamber assembly appearance defect detection system. The system includes: The enhancement module is used to acquire a standardized image of the water chamber assembly to be tested, and to enhance the standardized image to obtain the first image; The balancing module is used to extract three-channel pixel data from the first image, perform channel balancing processing on the three-channel pixel data to output the second image, and calculate the background light value of the three channels based on the contrast constraint of the second image. The recovery module is used to perform multi-scale feature recovery based on the first image and background light values to obtain the final feature-enhanced image; The detection module is used to input the final feature-enhanced image into the preset defect detection model and output the defect detection result. The defect detection model is based on YOLOv8 and the improvements include: replacing the Conv module in the backbone network of the YOLOv8 model with the target Conv module and replacing the C2f module with the target C2f module. The upload module is used to trigger early warnings based on defect detection results, generate early warning reports, and upload them to the cloud.
[0086] The foregoing has described one embodiment of the present invention in detail, but this content is merely a preferred embodiment and should not be considered as limiting the scope of the present invention. All equivalent variations and modifications made within the scope of the claims of this invention should still fall within the scope of the claims of this invention.
Claims
1. A method for detecting appearance defects in a water compartment assembly based on machine vision, characterized in that, The method includes: A standardized image of the water chamber assembly to be tested is acquired, and the standardized image is enhanced to obtain a first image; Extract the three-channel pixel data from the first image, perform channel balancing processing on the three-channel pixel data to output the second image, and calculate the background light value of the three channels based on the contrast constraint of the second image. The final feature-enhanced image is obtained by performing multi-scale feature recovery based on the first image and the background light value; The final feature-enhanced image is input into a preset defect detection model to output defect detection results; the defect detection model is based on YOLOv8 and the improvement includes: replacing the Conv module in the backbone network of the YOLOv8 model with the target Conv module and replacing the C2f module with the target C2f module; Based on the defect detection results, an early warning is triggered, an early warning report is generated, and uploaded to the cloud.
2. The method for detecting appearance defects in a water compartment assembly based on machine vision according to claim 1, characterized in that, The first image is obtained by enhancing the standardized image, including: The standardized image is divided into N×N image sub-blocks, and the histogram clipping threshold is calculated for each image sub-block. The grayscale histogram of each image sub-block is statistically analyzed. The pixels of the grayscale histogram of each image sub-block are marked as cropped pixels by the cropping threshold. The cropped pixels of all image sub-blocks are summed to obtain the total number of allocatable cropped pixels. Traverse the cropped grayscale histograms and allocate pixels according to a preset rule based on the total number of allocable cropped pixels to obtain the histogram of the first stage image sub-blocks, which is defined as the first histogram. The dynamic step size is calculated for the remaining unallocated cropped pixels according to a preset algorithm. The remaining cropped pixels are then cyclically allocated to the first histogram at dynamic step size intervals until all remaining cropped pixels are allocated, thus obtaining the final grayscale histogram of the second-stage image sub-block, which is defined as the second histogram. The second histogram of each image sub-block is equalized and bilinearly interpolated, and then stitched together to obtain the first image.
3. The method for detecting appearance defects in a water compartment assembly based on machine vision according to claim 1, characterized in that, The second image is output by performing channel balancing on the three-channel pixel data, including: The red-green channel pixel difference is calculated based on the red channel pixel values and green channel pixel values in the first image; The green channel normalization factor is calculated based on the maximum pixel value of the green channel, and the red channel pixel attenuation factor is calculated based on the pixel value of the red channel. The comprehensive attenuation factor is obtained by weighted fusion of the red-green channel pixel difference, the green channel normalization factor, and the red channel pixel attenuation factor. The ideal red channel pixel without attenuation is calculated based on the comprehensive attenuation factor, and the original attenuated red channel pixel is replaced to obtain a color image with the red channel restored. The three-channel pixels of the color image are traversed, and the combined statistics of the three-channel pixels are calculated to obtain the mixed statistics of each channel; the mixed statistics include the mixed pixel mean and the mixed pixel standard deviation; Using the green channel as the brightness benchmark, the compensation coefficients for the red, green, and blue channels are calculated respectively. Based on the mixing statistics and compensation coefficients, the dynamic constraint range of pixels is set, and pixel values that exceed the constraint range are cropped to the boundary to obtain the second image.
4. The method for detecting appearance defects in a water compartment assembly based on machine vision according to claim 1, characterized in that, Based on the second image, the background light values of the three channels are calculated using contrast constraints, including: The dark channel value and bright channel value are extracted from each pixel in the second image by traversing all pixels in the second image using a first local window of size m×m. Extract a preset number of pixels from the dark channel value and the bright channel value respectively to obtain the first group of pixels and the second group of pixels. After merging the first group of pixels and the second group of pixels, perform deduplication to obtain the candidate region of the background light. For each pixel in the candidate region, take a second local window of size n×n and calculate the local contrast of grayscale pixels in the second local window. Filter out the effective weights of all pixels in the candidate region based on the local contrast and the contrast threshold. The background light value of each channel is obtained by weighting the three channels of the pixels in the candidate region according to the effective weights.
5. The method for detecting appearance defects in a water compartment assembly based on machine vision according to claim 1, characterized in that, The final feature-enhanced image is obtained by performing multi-scale feature recovery based on the first image and the background light value, including: An adaptive weight map is calculated for each pixel and background light value in the first image, and the adaptive transmittance is calculated by substituting the adaptive weight map into a preset formula. The initial feature-enhanced image is obtained by calculating the standardized image, background light value, and adaptive transmittance. Extract the mid-frequency and high-frequency components from the initial feature-enhanced image; The high-frequency component weight and the mid-frequency component weight are calculated pixel by pixel based on the preset scaling factor. The high-frequency component weight and the mid-frequency component weight are multiplied element by element with the corresponding frequency domain component and then added together to obtain the detail compensation component. The initial feature-enhanced image is added pixel-by-pixel to the detail compensation component to obtain the final feature-enhanced image.
6. The method for detecting appearance defects in a water compartment assembly based on machine vision according to claim 1, characterized in that, The defect detection model is based on an improved version of YOLOv8, and the improvements include: The Conv modules in layers 1, 3, 5, and 7 of the YOLOv8 model backbone network are replaced with target Conv modules; the target Conv modules are used to fuse local fine-grained features with global context information to reduce feature loss during downsampling of small defects on the aluminum profile surface. The C2f modules in layers 2, 4, 6 and 8 are replaced with target C2f modules; the target C2f modules are used to expand the receptive field and enhance the feature extraction and fusion capabilities of multi-scale aluminum profile surface defects without increasing parameters; Replace all C2f modules in the neck network of the YOLOv8 model with the target C2f module.
7. The method for detecting appearance defects in a water compartment assembly based on machine vision according to claim 6, characterized in that, The working principle of the target Conv module is as follows: The first input feature map is obtained, and then the first input feature map is input into the Conv module. Then, the first target feature map and the second target feature map are obtained by inputting the first input feature map into the parallel Conv module with two different convolution kernels respectively. The first target feature map and the second target feature map are concatenated and then subjected to batch normalization and PReLU function activation to obtain the third target feature map; The third target feature map is processed sequentially by average pooling and two fully connected layers to output the fourth target feature map. The third and fourth target feature maps are fused to obtain the fifth target feature map, which is then used as the input for the next module.
8. The method for detecting appearance defects in a water compartment assembly based on machine vision according to claim 6, characterized in that, The improvements to the target C2f module include: Replace DarknetBottleneck in the C2f module with the target Bottleneck module; The working principle of the target Bottleneck module is as follows: Obtain the second input feature map, input the input feature map into the DWR module to obtain the first convolutional feature map, and input the first convolutional feature map into the Conv module to obtain the second convolutional feature map; The second convolutional feature map is input into a parallel Conv module with three different convolutional kernels to obtain the third convolutional feature map; The third convolutional feature map is sequentially input into the Conv module and the DWR module to obtain the fourth convolutional feature map, which is then used as the input for the next module.
9. The method for detecting appearance defects in a water compartment assembly based on machine vision according to claim 1, characterized in that, Based on the defect detection results, an early warning is triggered and an early warning report is generated, including: Obtain the defect type, defect location coordinates, and confidence score from the defect detection results; According to a preset defect level mapping table, the defect type and confidence score are matched with the corresponding warning level; the warning level includes low risk warning, medium risk warning and high risk warning. Based on the defect location coordinates, the defect area image is extracted from the final feature-enhanced image, and the defect area image, defect type, confidence score, and warning level are integrated to generate a structured warning record; The structured early warning records are compared with a preset defect knowledge base. If the defect type is a repetitive defect, the defect frequency is accumulated and trend analysis data is generated. Based on the warning level and defect frequency, corresponding warning actions are triggered; the warning actions include recording logs and pushing them to the monitoring dashboard when the risk warning is low, sending information to notify the quality inspector when the risk warning is medium, and immediately stopping the testing line and issuing an audible and visual alarm when the risk warning is high. All structured early warning records, trend analysis data, and triggered early warning actions are packaged into an early warning report and uploaded to the cloud server.
10. A machine vision-based water chamber assembly appearance defect detection system, characterized in that, The system includes: An enhancement module is used to acquire a standardized image of the water chamber assembly to be tested, and to enhance the standardized image to obtain a first image; The balancing module is used to extract three-channel pixel data from the first image, perform channel balancing processing on the three-channel pixel data to output a second image, and calculate the background light value of the three channels based on the contrast constraint calculation of the second image. The recovery module is used to perform multi-scale feature recovery based on the first image and the background light value to obtain the final feature-enhanced image; The detection module is used to input the final feature-enhanced image into a preset defect detection model and output the defect detection result; the defect detection model is based on YOLOv8 and the improvement includes: replacing the Conv module in the backbone network of the YOLOv8 model with the target Conv module and replacing the C2f module with the target C2f module; the upload module is used to trigger an early warning based on the defect detection result, generate an early warning report, and upload it to the cloud.