Surface defect detection method, system and device based on amsdnet
By combining image acquisition, preprocessing, and feature fusion techniques with the AMSDNet detection method, the problems of low efficiency and high error in traditional detection methods are solved, achieving efficient and accurate detection of automotive metal surface defects, adapting to complex environments and diverse defects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-03-31
AI Technical Summary
Traditional methods for detecting defects on automotive metal surfaces rely on manual visual inspection, which is inefficient and easily affected by human factors. It is also difficult to cope with changes in lighting and diverse defect characteristics in complex environments, leading to missed or false detections.
A surface defect detection method based on AMSDNet is adopted. Through image acquisition, preprocessing, image enhancement and feature fusion techniques, including nonlocal mean filtering, histogram equalization, wavelet transform and generative adversarial network, combined with a bidirectional feature refinement module for feature fusion and adaptive anchor point selection, efficient and accurate defect detection is achieved.
It improves the accuracy and efficiency of detection, reduces missed detections and false detections, has the ability to adapt to complex environments and diverse defects, and meets the real-time requirements of industrial online detection.
Smart Images

Figure CN121190490B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automotive metal surface defect detection technology, and in particular to a surface defect detection method, system and device based on AMSDNet. Background Technology
[0002] With the rapid development of the automotive industry, quality control in the automobile manufacturing process has become particularly important. As a crucial component of automobiles, the surface defects of metal parts cannot be ignored; even minor flaws can directly affect the overall safety and reliability of the vehicle. Traditional methods for detecting metal surface defects mostly rely on manual visual inspection. While this method can detect some defects to a certain extent, it is inefficient and highly susceptible to human error. Factors such as the inspector's experience level, visual fatigue, lighting conditions, and personal judgment standards can all significantly impact the inspection results, leading to missed or false detections of defects, posing potential risks to the quality and safety of automobiles. Therefore, exploring more efficient and accurate methods for detecting metal surface defects has become a crucial issue that urgently needs to be addressed in the current automotive manufacturing industry.
[0003] Existing automotive metal surface defect detection technologies overcome the limitations of single-source illumination by acquiring images from multiple angles and extracting grayscale pixel values, significantly improving detection accuracy and efficiency while reducing the risk of missed and false detections. However, they may struggle to handle lighting variations and diverse defect characteristics in complex environments. Summary of the Invention
[0004] This invention aims to at least solve one of the technical problems existing in related technologies. To this end, this invention provides a surface defect detection method, system, and apparatus based on AMSDNet, which can effectively reduce noise in images; after denoising, wavelet transform adaptive enhancement algorithm and adversarial generative network-based image enhancement are used to reduce the complexity of subsequent image processing and speed up the detection time.
[0005] This invention provides a surface defect detection method based on AMSDNet, comprising:
[0006] S1: Acquire image data of defects on the metal surface of the car through the image acquisition module, and perform preprocessing on the image data to obtain a preprocessed image;
[0007] S2: Perform image enhancement processing on the preprocessed image, label various defect types, and obtain an image dataset;
[0008] S3: Construct the AMSDNet model. The AMSDNet model uses a bidirectional feature refinement module for feature fusion and is trained using an image dataset to obtain the trained AMSDNet model.
[0009] S4: Input the actual image of the car's metal surface into the trained AMSDNet model to obtain the actual detection results.
[0010] According to the present invention, a surface defect detection method based on AMSDNet is provided, wherein the image acquisition module includes an industrial camera, a light source system and an image collection module. The industrial camera is used to acquire image data, the light source system includes an oblique light source and a ring light source, and the image collection module is used to acquire automotive metal surface defects under different lighting conditions.
[0011] According to the surface defect detection method based on AMSDNet provided by the present invention, the preprocessing step in step S1 includes:
[0012] S11: The original image is denoised using a nonlocal mean filtering method to remove Gaussian noise and salt-and-pepper noise.
[0013] S12: Use histogram equalization to improve image contrast;
[0014] S13: Crop the image to a fixed size and perform normalization processing to normalize the image pixel values, resulting in a preprocessed image.
[0015] According to the surface defect detection method based on AMSDNet provided by the present invention, step S2 includes:
[0016] S21: The preprocessed image is decomposed into low-frequency and high-frequency components using two-dimensional discrete wavelet transform technology;
[0017] S22: The high-frequency part calculates the local contrast through a sliding window and adjusts the set threshold according to the contrast difference. For regions with contrast lower than or equal to the set threshold, a nonlinear function is used for enhancement. For regions with contrast higher than the threshold, smoothing is performed to obtain the smoothed high-frequency part. The low-frequency part is smoothed and optimized using a mean filter to obtain the smoothed low-frequency part.
[0018] S23: By using inverse wavelet transform, the smoothed high-frequency part and the smoothed low-frequency part are synthesized to obtain a preliminary enhanced image;
[0019] S24: Using a generative adversarial network to enhance the image details of the initial enhanced image, the enhanced image is obtained;
[0020] S25: Defects in the enhanced image are labeled to obtain an image dataset. According to the AMSDNet-based surface defect detection method provided by this invention, the bidirectional feature refinement module includes:
[0021] S31: Use the backbone network to extract multi-scale features from the input image dataset to obtain low-level feature maps, mid-level feature maps, and high-level feature maps;
[0022] S32: After the high-level feature map is processed by the multi-scale feature calibration unit, the fused high-level information is obtained. The low-level feature map, the middle-level feature map and the fused high-level information are input into the global context aggregation unit to obtain the fused feature map.
[0023] S33: An adaptive anchor point filtering module is used to calculate the importance score of the fused feature map and predict the confidence of the presence of defects and the initial bounding box at each location;
[0024] S34: Sort the scores according to the importance scores, and select several of the top-ranked data as the initial query for the decoder;
[0025] S35: Based on the confidence level of the predicted defects at each location and the initial bounding box, a lightweight decoder is used to fine-tune the adaptive anchor points, and the defect classification and localization results are output.
[0026] According to the surface defect detection method based on AMSDNet provided by the present invention, the process of the global context aggregation unit is as follows:
[0027] S321: Input the fused high-level information into the first linearization module to obtain a high-level linearization result;
[0028] S322: The high-level linear result and the mid-level feature map are fused to obtain the first fusion result;
[0029] S323: Input the first fusion result into the first linearization module to obtain the first linear result;
[0030] S324: The first linear result and the low-level feature map are fused to obtain a second fusion result;
[0031] S325: Input the second fusion result into the second linearization module to obtain the second linear result;
[0032] S326: Merge the second linear result and the first linear result to obtain a third fused result;
[0033] S327: Input the third fusion result into the second linearization module to obtain the fourth linear result;
[0034] S328: The fourth linear result and the high-level linear result are fused to obtain the fourth fusion result;
[0035] S329: The fourth fusion result, the third fusion result, and the second fusion result are spliced together to obtain the fused feature map.
[0036] According to the AMSDNet-based surface defect detection method provided by the present invention, the adaptive anchor point screening module process is as follows:
[0037] S331: Normalize the fused feature map to form a feature vector, and obtain the corresponding candidate feature set;
[0038] S332: The importance score is predicted for each candidate input anchor point by the classification head, and the corresponding features of several candidate positions that are most likely to contain the target are selected according to the score ranking. The importance score is obtained by weighting the feature vector using learnable parameters.
[0039] S333: The corresponding feature predictions of the candidate positions are transformed by a multi-layer feedforward network to obtain the initial bounding box;
[0040] S334: Perform a linear projection layer transformation on the corresponding feature predictions of the candidate positions to obtain the confidence level of the defect.
[0041] According to the surface defect detection method based on AMSDNet provided by the present invention, the first linearization module process is as follows:
[0042] S111: Perform a 1×1 convolution on the input of the first linearization module to obtain the convolution value of the first linearization module;
[0043] S112: Perform BN batch normalization on the convolution value of the first linearization module to obtain the normalized convolution value of the first linearization module;
[0044] S113: The normalized first linearization module convolution value is nonlinearized using the SiLU activation function to obtain the output of the first linearization module;
[0045] The second linearization module process is as follows:
[0046] S121: Perform a 3×3 convolution on the input of the second linearization module to obtain the convolution value of the second linearization module;
[0047] S122: Perform BN batch normalization on the convolutional values of the second linearization module to obtain normalized convolutional values of the second linearization module;
[0048] S123: The normalized second linearization module convolution value is nonlinearized using the SiLU activation function to obtain the output of the second linearization module.
[0049] The present invention also provides a surface defect detection system based on AMSDNet, comprising:
[0050] Image acquisition module: used to acquire image data of defects on the metal surface of automobiles, and to preprocess the image data to obtain a preprocessed image;
[0051] Image processing module: used to perform image enhancement processing on the preprocessed image, label various defect types, and obtain an image dataset;
[0052] Model training module: used to build AMSDNet model. The AMSDNet model uses a bidirectional feature refinement module for feature fusion and trains an object detection model using an image dataset to obtain the trained AMSDNet model.
[0053] Actual data detection module: This module is used to input actual images of automotive metal surfaces into the trained AMSDNet model to obtain actual detection results.
[0054] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the AMSDNet-based surface defect detection method as described above.
[0055] The above-described one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:
[0056] This invention provides a surface defect detection method, system, and device based on AMSDNet. It employs nonlocal mean filtering and histogram equalization for image preprocessing, which can effectively reduce noise in the image. After denoising, it uses wavelet transform adaptive enhancement algorithm and adversarial generative network-based image enhancement, which reduces the complexity of subsequent image processing and speeds up the detection time.
[0057] This invention proposes an AMSDNet defect detection model, which improves both average precision and recall, effectively solving the challenge of detecting defects on automotive metal surfaces. Currently, most detection methods in this field rely on manual visual inspection or algorithms based on traditional machine vision, resulting in low efficiency, high error rates, and poor generalization. In contrast, the defect detection method proposed in this invention has the following advantages: ① It adopts a principle based on ensemble prediction, avoiding the complex post-processing steps such as prior box design and redundant box suppression operations required in traditional detection models, reducing performance loss caused by improper adjustment of parameters of these manually designed components, and simplifying the detection process. ② Through multi-scale feature fusion optimized by statistical constraint representation, the model can autonomously and accurately focus on potential defect regions, thus exhibiting strong adaptability to metal surface defects with varying shapes and sizes. It can accurately locate various defects, from large-area dents to fine scratches, reducing the occurrence of missed and false detections. ③ It employs a highly optimized lightweight decoder and removes the auxiliary supervision module used in the training phase during inference, ensuring efficient operation of the algorithm and meeting the real-time requirements of industrial online inspection while maintaining high accuracy.
[0058] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0059] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0060] Figure 1 This is a schematic flowchart of the surface defect detection method based on AMSDNet provided by the present invention.
[0061] Figure 2 This is a structural block diagram of the AMSDNet-based surface defect detection device provided by the present invention.
[0062] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention.
[0063] Figure 4 This is a diagram showing the metal recognition results of the present invention.
[0064] Figure label:
[0065] 101. Image acquisition module; 102. Image processing module; 103. Model training module; 104. Actual data detection module; 810. Processor; 820. Communication interface; 830. Memory; 840. Communication bus. Detailed Implementation
[0066] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention. The following embodiments are used to illustrate this invention but cannot be used to limit the scope of this invention.
[0067] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0068] The following is combined Figures 1 to 4 This invention is described.
[0069] Example
[0070] like Figure 1 As shown, Figure 1 This is a flowchart illustrating the surface defect detection method based on AMSDNet provided by the present invention, including:
[0071] S1: Acquire image data of defects on the metal surface of the car through the image acquisition module, and perform preprocessing on the image data to obtain a preprocessed image;
[0072] S2: Perform image enhancement processing on the preprocessed image, label various defect types, and obtain an image dataset;
[0073] S3: Construct the AMSDNet model. The AMSDNet model uses a bidirectional feature refinement module for feature fusion and trains the object detection model using an image dataset to obtain the trained AMSDNet model.
[0074] S4: Input the actual image of the car's metal surface into the trained AMSDNet model to obtain the actual detection results.
[0075] Specifically, the image acquisition module includes an industrial camera, a light source system, and an image collection module. The industrial camera is used to acquire image data, and the light source system includes an oblique light source and a ring light source. The light source system is used to acquire defects on the metal surface of automobiles under different lighting conditions. The frame rate of the images acquired by the industrial camera is 5 frames per second.
[0076] Specifically, the preprocessing steps in step S1 include:
[0077] S11: The original image is denoised using a nonlocal mean filtering method to remove Gaussian noise and salt-and-pepper noise. In this embodiment of the invention, the filtering window size is set to 15×15, the search window size is 21×21 pixels, and the weight parameter is 0.1.
[0078] S12: Histogram equalization is used to improve image contrast. In this invention, the contrast limit parameter is set to 0.02 to avoid information loss caused by over-enhancement and to make subtle defects in the image more prominent.
[0079] S13: Crop the image to a fixed size and perform normalization processing. Normalize the image pixel values to obtain the preprocessed image. In this embodiment of the invention, the image is cropped to a fixed size of 640×640 pixels, and the image pixel value range is scaled from 0-255 to 0-1 to ensure the consistency of image data and improve the stability and accuracy of model training.
[0080] Specifically, step S2 includes:
[0081] S21: The preprocessed image is decomposed into low-frequency and high-frequency components using two-dimensional discrete wavelet transform technology. In this embodiment of the invention, the number of transform layers is set to three. Haar is selected as the wavelet basis function in this embodiment of the invention to retain sufficient image details while reducing computational complexity.
[0082] S22: The high-frequency component calculates local contrast using a sliding window and adjusts a set threshold based on the contrast difference. For regions with contrast below the set threshold, a non-linear function is used for enhancement to highlight defects. For regions with contrast above the threshold, smoothing is performed to avoid over-enhancement, resulting in a smoothed high-frequency component. The low-frequency component is smoothed and optimized using a mean filter, resulting in a smoothed low-frequency component. This reduces excessive changes in image structure and maintains the overall shape and brightness information. The processed low-frequency component will serve as the basis for image reconstruction.
[0083] S23: By using inverse wavelet transform, the smoothed high-frequency part and the smoothed low-frequency part are synthesized to obtain a preliminary enhanced image;
[0084] S24: The enhanced image is obtained by using a generative adversarial network (GAN) to enhance the image details of the initial enhanced image. In this embodiment of the invention, stochastic gradient descent is used to alternately train the generator and discriminator, updating their weights in each training iteration. The training process stabilizes and optimizes image quality by minimizing the adversarial loss function. Through adversarial training, the generator continuously optimizes image details, especially the clarity of defective areas.
[0085] S25: Label the defects in the enhanced image; the labeling targets include defect types such as inclusions, patches, dented surfaces, rolled oxide scale, and scratches. After labeling, the dataset is divided into training, validation, and test sets in a 7:2:1 ratio.
[0086] Specifically, the bidirectional feature refinement module includes the following steps:
[0087] S31: Use the backbone network to extract multi-scale features from the input image dataset to obtain low-level feature maps, mid-level feature maps, and high-level feature maps;
[0088] S32: After the high-level feature map is processed by the multi-scale feature calibration unit, the fused high-level information is obtained. The low-level feature map, the middle-level feature map and the fused high-level information are input into the global context aggregation unit to obtain the fused feature map.
[0089] S33: An adaptive anchor point filtering module is used to calculate the importance score of the fused feature map and predict the confidence of the presence of defects and the initial bounding box at each location;
[0090] S34: Sort the scores according to the importance scores, and select several of the top-ranked data as the initial query for the decoder;
[0091] S35: Based on the confidence level of the predicted defects at each location and the initial bounding box, a lightweight decoder is used to fine-tune the adaptive anchor points, and the defect classification and localization results are output.
[0092] The AMSDNet model employs a bidirectional feature refinement module for feature fusion, comprising a Multi-Scale Feature Convolution Unit (MFCU) and a Global Context Attention Unit (GCAU). The MFCU flattens the input high-level feature map spatially into a token sequence, introducing positional encoding to preserve spatial structure information. This sequence is then fed into a lightweight encoder, which, through its inherent multi-head self-attention mechanism, models the global context of the feature sequence. This allows each feature location to interact and enhance with all other locations in the entire image. The encoder's enhanced sequence is then restored to its spatial feature map structure and fused with the original input features via residual connections, forming an enhanced feature output rich in global context information. The GCAU utilizes low-level, mid-level, and high-level feature maps... Figure 3 Using feature maps as input, adjacent features are fused through a fusion block composed of convolutional layers to integrate features at different scales. A 1×1 convolution is used to achieve cross-channel feature recombination, eliminating channel redundancy caused by splicing, and maintaining the final output resolution. This effectively integrates detailed features and contextual information, enhancing the model's adaptability to scale changes and its ability to detect small-scale objects. The statistical constraint representation optimization module in the AMSDNet model performs global semantic analysis on the multi-scale features output by the encoder through a lightweight counting sub-network, generating a category-independent defect spatial probability distribution heatmap. Subsequently, a Sigmoid activation function is used to transform density prediction values into spatial attention weights, forming a feature selection mask for potential defect regions. Finally, a channel-wise weighted fusion mechanism is used to dynamically modulate the original features, thereby improving the signal-to-noise ratio of subtle defect regions.
[0093] The bidirectional feature refinement module merges adjacent features through a fusion block composed of convolutional layers, integrating features at different scales. It also uses 1×1 convolutions to achieve cross-channel feature recombination, eliminating channel redundancy caused by splicing. The final output maintains resolution, effectively integrating detailed features and contextual information, enhancing the model's adaptability to scale changes and its ability to detect small-scale objects.
[0094] Specifically, the process of the global context aggregation unit is as follows:
[0095] S321: Input the fused high-level information into the first linearization module to obtain a high-level linear result;
[0096] S322: The high-level linear result and the mid-level feature map are fused to obtain the first fusion result;
[0097] S323: Input the first fusion result into the first linearization module to obtain the first linear result;
[0098] S324: The first linear result and the low-level feature map are fused to obtain a second fusion result;
[0099] S325: Input the second fusion result into the second linearization module to obtain the second linear result;
[0100] S326: Merge the second linear result and the first linear result to obtain a third fused result;
[0101] S327: Input the third fusion result into the second linearization module to obtain the fourth linear result;
[0102] S328: The fourth linear result and the high-level linear result are fused to obtain the fourth fusion result;
[0103] S329: The fourth fusion result, the third fusion result, and the second fusion result are spliced together to obtain the fused feature map.
[0104] Specifically, the adaptive anchor point filtering module process is as follows:
[0105] S331: Normalize the fused feature map to form a feature vector, and obtain the corresponding candidate feature set;
[0106] S332: The importance score is predicted for each candidate input anchor point by the classification head, and the corresponding features of several candidate positions that are most likely to contain the target are selected according to the score ranking. The importance score is obtained by weighting the feature vector using learnable parameters.
[0107] S333: The corresponding feature predictions of the candidate positions are transformed by a multi-layer feedforward network to obtain the initial bounding box;
[0108] S334: Perform a linear projection layer transformation on the corresponding feature predictions of the candidate positions to obtain the confidence level of the defect.
[0109] Specifically, after model training, defect detection and result output are performed. The AMSDNet model detects the location and category of defects in the input image, outputting the defect bounding boxes and category labels. The types of various defects (such as inclusions, patches, dents, etc.) and their specific locations are accurately labeled. Subsequently, visualization processing is performed, marking the detected defect regions in the image and highlighting the defect bounding boxes, such as... Figure 4 As shown in the image, the visual interface allows for an intuitive view of defects on the car's metal surface. The test results are stored in a database and a detailed test report is generated.
[0110] Specifically, the process of the first linearization module is as follows:
[0111] S111: Perform a 1×1 convolution on the input of the first linearization module to obtain the convolution value of the first linearization module;
[0112] S112: Perform BN batch normalization on the convolution value of the first linearization module to obtain the normalized convolution value of the first linearization module;
[0113] S113: The normalized first linearization module convolution values are nonlinearized using the SiLU activation function to obtain the output of the first linearization module, as shown in the formula:
[0114]
[0115] in, The output of the first linearization module, The SiLU activation function is used. For BN batch normalization, For 1×1 convolution, This is the input to the first linearization module.
[0116] The second linearization module process is as follows:
[0117] S121: Perform a 3×3 convolution on the input of the second linearization module to obtain the convolution value of the second linearization module;
[0118] S122: Perform BN batch normalization on the convolutional values of the second linearization module to obtain normalized convolutional values of the second linearization module;
[0119] S123: The normalized second linearization module convolution values are nonlinearized using the SiLU activation function to obtain the output of the second linearization module, as shown in the formula:
[0120]
[0121] in, The output of the second linearization module, The SiLU activation function is used. For BN batch normalization, It is a 3×3 convolution. This is the input to the second linearization module.
[0122] Specifically, Figure 4 (a) shows the detection results of oxide scale on the metal surface, where oxide_scale represents the identification result of oxide scale on the metal surface, and the following numbers represent the confirmation probability. Figure 4(b) Metal patch detection results, where Surface_patch represents the metal patch detection results and the following numbers represent the confirmation probability; Figure 4 (c) Metal cracking defect detection results, where cracking is the metal cracking defect detection result identification, and the following number is the confirmation probability; Figure 4 (d) Results of pitting detection on metal surfaces, where pitting is the identification of pitting detection results and the following number is the confirmation probability; Figure 4 (e) Detection results of metal inclusions, where inclusion is the identification result of metal inclusions, and the following number is the confirmation probability; Figure 4 (f) Metal scratch defect detection results, where scratch represents the metal scratch defect detection result, and the following number is the confirmation probability.
[0123] like Figure 2 As shown, the present invention also provides a surface defect detection system based on AMSDNet, comprising the following modules:
[0124] Image acquisition module 101: used to acquire image data of defects on the metal surface of automobiles through the image acquisition module, and to preprocess the image data to obtain a preprocessed image;
[0125] Image processing module 102: used to perform image enhancement processing on the preprocessed image, label various defect types, and obtain an image dataset;
[0126] Model training module 103: used to construct the AMSDNet model. The AMSDNet model uses a bidirectional feature refinement module for feature fusion and trains an object detection model using an image dataset to obtain the trained AMSDNet model.
[0127] Actual data detection module 104: used to input actual car metal surface images into the trained AMSDNet model to obtain actual detection results.
[0128] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute a surface defect detection method based on AMSDNet, which includes:
[0129] S1: Acquire image data of defects on the metal surface of the car through the image acquisition module, and perform preprocessing on the image data to obtain a preprocessed image;
[0130] S2: Perform image enhancement processing on the preprocessed image, label various defect types, and obtain an image dataset;
[0131] S3: Construct the AMSDNet model. The AMSDNet model uses a bidirectional feature refinement module for feature fusion and trains the object detection model using an image dataset to obtain the trained AMSDNet model.
[0132] S4: Input the actual image of the car's metal surface into the trained AMSDNet model to obtain the actual detection results.
[0133] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0134] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0135] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0136] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
[0137] It should be noted that the embodiments of this disclosure can be implemented using hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by a suitable instruction execution system, such as a microprocessor or dedicated-design hardware. Those skilled in the art will understand that the above-described devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code provided on a programmable memory or a data carrier such as an optical or electronic signal carrier.
[0138] Furthermore, although the operation of the methods of this disclosure is described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Rather, the steps depicted in the flowcharts may be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps. It should also be noted that the features and functions of two or more devices according to this disclosure may be embodied in one device. Conversely, the features and functions of one device described above may be further divided and embodied by multiple devices.
[0139] While this disclosure has been described with reference to several specific embodiments, it should be understood that this disclosure is not limited to the specific embodiments disclosed. This disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. A surface defect detection method based on AMSDNet, characterized in that, The method comprises the following steps: S1: acquiring image data of a metal surface defect of a vehicle through an image acquisition module, and performing a pretreatment operation on the image data to obtain a pretreated image; S2: performing image enhancement processing on the pretreated image, and labeling various defect types to obtain an image dataset, and step S2 comprises: S21: using a two-dimensional discrete wavelet transform technology to decompose the pretreated image into a low-frequency part and a high-frequency part; S22: calculating a local contrast of the high-frequency part through a sliding window, adjusting a threshold value according to a contrast difference, using a nonlinear function to enhance a region with a contrast lower than or equal to the threshold value, and performing smoothing processing on a region with a contrast higher than the threshold value to obtain a smoothed high-frequency part; the low-frequency part is smoothed and optimized by using a mean filter to obtain a smoothed low-frequency part; S23: synthesizing the smoothed high-frequency part and the smoothed low-frequency part through wavelet inverse transform to obtain a preliminary enhanced image; S24: using a generative adversarial network to enhance image details of the preliminary enhanced image to obtain an enhanced image; S25: labeling defects of the enhanced image to obtain an image dataset; S3: constructing an AMSDNet model, using a bidirectional feature refining module for feature fusion, training the AMSDNet model by using the image dataset, and obtaining a trained AMSDNet model; the bidirectional feature refining module comprises: S31: using a backbone network to extract multi-scale features of the input image dataset to obtain low-level feature maps, middle-level feature maps and high-level feature maps; S32: processing the high-level feature maps through a multi-scale feature calibration unit to obtain fused high-level information, inputting the low-level feature maps, the middle-level feature maps and the fused high-level information into a global context aggregation unit to obtain fused feature maps, and a process of the global context aggregation unit is as follows: S321: inputting the fused high-level information into a first linearization module to obtain high-level linear results; S322: fusing the high-level linear results and the middle-level feature maps to obtain first fusion results; S323: inputting the first fusion results into the first linearization module to obtain first linear results; S324: fusing the first linear results and the low-level feature maps to obtain second fusion results; S325: inputting the second fusion results into a second linearization module to obtain second linear results; S326: fusing the second linear results and the first linear results to obtain third fusion results; S327: inputting the third fusion results into the second linearization module to obtain fourth linear results; S328: fusing the fourth linear results and the high-level linear results to obtain fourth fusion results; S329: splicing the fourth fusion results, the third fusion results and the second fusion results to obtain the fused feature maps; The multi-scale feature calibration unit flattens the input high-level feature map in the spatial dimension into a token sequence, introduces position encoding to retain spatial structure information, and sends the token sequence into a lightweight encoder, restores the enhanced sequence output by the encoder into a spatial feature map structure through a multi-head self-attention mechanism, fuses the original input feature with the spatial feature map structure, and forms an enhanced feature output of global context information; S33: An adaptive anchor point screening module is used to calculate the importance score of the fused feature map, predict the defect existence confidence and initial bounding box of each position, and the process of the adaptive anchor point screening module is as follows: S331: The fused feature map is normalized to form a feature vector, and a corresponding candidate feature set is obtained; S332: The importance score of each candidate input anchor point is predicted through a classification head, and a corresponding feature of a candidate position most likely to contain the target is screened out according to the score ranking, and the feature vector is weighted and scored by using a learnable parameter to obtain the importance score; S333: The initial bounding box is obtained by performing multi-layer forward network transformation on the corresponding feature prediction of the candidate position; S334: The confidence of the existence of defects is obtained by performing linear projection layer transformation on the corresponding feature prediction of the candidate position; S34: The importance score is ranked according to the importance score, and a plurality of top-ranked data are selected as the initial query of the decoder; S35: A lightweight decoder is used to fine-tune the adaptive anchor point according to the confidence of the existence of defects and the initial bounding box of each position, and the defect classification and positioning result is output. S4: The actual automobile metal surface image is input into the AMSDNet model after training to obtain an actual detection result.
2. The surface defect detection method based on AMSDNet according to claim 1, wherein, The image acquisition module includes an industrial camera, a light source system and an image collection module, the industrial camera is used to acquire image data, the light source system includes an inclined light source and a ring light source, and the image collection module is used to acquire automobile metal surface defects under different lighting conditions.
3. The surface defect detection method based on AMSDNet according to claim 1, wherein, The preprocessing step in step S1 includes: S11: A non-local mean filtering method is used to denoise the original image to remove Gaussian noise and salt and pepper noise in the image; S12: A histogram equalization technique is used to improve the contrast of the image; S13: The image is cropped to a fixed size, normalized, and the pixel values of the image are normalized to obtain a preprocessed image.
4. The surface defect detection method based on AMSDNet according to claim 1, wherein, The process of the first linearization module is as follows: S111: 1*1 convolution is performed on the input of the first linearization module to obtain a first linearization module convolution value; S112: BN batch normalization is performed on the first linearization module convolution value to obtain a normalized first linearization module convolution value; S113: The normalized first linearization module convolution value is subjected to SiLU activation function for non-linearization to obtain the output of the first linearization module; The process of the second linearization module is as follows: S121: 3*3 convolution is performed on the input of the second linearization module to obtain a second linearization module convolution value; S122: BN batch normalization is performed on the second linearization module convolution value to obtain a normalized second linearization module convolution value; S123: Nonlinearization is performed on the normalized second linearization module convolution value using a SiLU activation function to obtain the output of the second linearization module.
5. An AMSDNet-based surface defect detection system for performing the AMSDNet-based surface defect detection method according to any one of claims 1 to 4. The image acquisition module is configured to acquire image data of the automobile metal surface defects through the image acquisition module, and perform a pretreatment operation on the image data to obtain pretreated images. The image processing module is configured to perform image enhancement processing on the pretreated images, and label various defect types to obtain an image data set. The model training module is configured to construct an AMSDNet model, perform feature fusion on the AMSDNet model by using a bidirectional feature refining module, train a target detection model by using the image data set, and obtain a trained AMSDNet model. The actual data detection module is configured to input actual automobile metal surface images into the trained AMSDNet model to obtain actual detection results. 6.An electronic device comprising a processor, a communication interface, a memory, and a communication bus, characterized in that, The processor executes the computer program to implement the steps of the AMSDNet-based surface defect detection method according to any one of claims 1 to 4.
Citation Information
Patent Citations
PCB defect detection method based on small target enhanced feature pyramid
CN119785175A
Road defect detection method based on heavy parameter multi-scale fusion
CN120070417A