A steel ball appearance defect detection method and system based on deep learning

By optimizing the training process using an autoencoder model and introducing weighted grayscale and gradient loss, the problem of distinguishing between benign color differences and malignant defect features on the surface of steel balls is solved, thereby improving the accuracy and reliability of defect detection.

CN120876489BActive Publication Date: 2026-03-03CHINA NAT GENERAL MASCH ENG CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511396312.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-28
Publication Date
2026-03-03
Estimated Expiration
2045-09-28

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively distinguish between benign color differences and malignant defect features on the surface of steel balls, leading to false alarms or false negatives. Furthermore, the scarcity of defect samples negatively impacts model training performance.

Method used

An autoencoder model is adopted, and weighted grayscale loss and gradient loss are introduced by customizing the loss degree of defect-free steel ball images. This optimizes the model training process, reduces the focus on the inherent color difference of defect-free steel balls, improves the feature learning of smooth regions, enhances the focus on weak edges, and reduces the learning weight of strong edges.

Benefits of technology

It improved the detection rate of defects, reduced the risk of missed detection, and achieved efficient identification of steel ball appearance defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120876489B_ABST
    Figure CN120876489B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image processing, and more particularly to a steel ball appearance defect detection method and system based on deep learning. The method comprises the following steps: collecting defect-free steel ball images to form a training data set, obtaining the gray loss of each pixel point in the defect-free steel ball image and the weight of the gray loss, obtaining the gradient loss of each pixel point in the defect-free steel ball image and the weight of the gradient loss, obtaining the loss of each pixel point in the defect-free steel ball image, and obtaining the loss degree of the defect-free steel ball image according to the loss of each pixel point in the defect-free steel ball image; inputting each defect-free steel ball image and the loss degree of each defect-free steel ball image into a self-encoder for training to obtain a trained self-encoder, inputting a steel ball image to be detected into the trained self-encoder for defect detection, and improving the accuracy of steel ball defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method and system for detecting defects in the appearance of steel balls based on deep learning. Background Technology

[0002] Steel balls are core components in precision machinery such as bearings, and their surface quality directly affects the service life and operational stability of the entire equipment. The production process of steel balls is characterized by large-scale production and a high degree of automation. Minor surface defects such as cracks, scratches, chipping, black spots, and dents may appear on their surfaces. Machine vision-based automated inspection is the mainstream method for ensuring steel ball quality. This method uses industrial cameras to capture images of the steel balls and then uses image processing or deep learning algorithms to identify defects. However, this process faces two major challenges: First, in the industrial production of steel balls, the occurrence of defective samples is a low-probability event, making it difficult to collect a sufficient number and variety of defect images to train a robust supervised learning model (such as conventional image classification algorithms). Second, steel balls themselves are spherical, and under industrial lighting conditions, their surfaces will produce inherent, non-defect-related color differences due to variations in curvature. These normal visual features may be confused with real defect features (such as strong edges) in the image.

[0003] Therefore, this invention uses an autoencoder to solve the problem of scarce defect samples, that is, to perform anomaly detection by learning only the features of defect-free samples. However, conventional autoencoders usually use standard loss functions such as mean square error or absolute error during training. These functions treat all pixel differences in the image equally and are difficult to effectively distinguish between the inherent benign color difference and malignant defect features of steel balls. Therefore, when faced with objects with complex surface characteristics such as steel balls, false alarms or false negatives are still easy to occur. Summary of the Invention

[0004] To address the technical problem that standard loss functions such as mean squared error used in conventional autoencoder training treat all pixel differences in an image equally, making it difficult to effectively distinguish between the inherent benign color differences and malignant defect features of steel balls, this invention provides a deep learning-based method and system for detecting steel ball appearance defects.

[0005] In a first aspect, the present invention provides a method for detecting steel ball appearance defects based on deep learning, employing the following technical solution:

[0006] A deep learning-based method for detecting surface defects in steel balls, comprising the following steps:

[0007] Train an autoencoder model based on a training dataset containing only images of defect-free steel balls;

[0008] During the training of the autoencoder model, the model is optimized by customizing the loss level of the defect-free steel ball image. The loss level includes: obtaining the grayscale loss of each pixel and the weight of the grayscale loss of each pixel; obtaining the gradient loss of each pixel and the weight of the gradient loss of each pixel; calculating the sum of the weighted grayscale loss and the weighted gradient loss for each pixel as the loss of each pixel in the defect-free steel ball image; and taking the average loss of all pixels as the loss level of the defect-free steel ball image.

[0009] The process of using a trained autoencoder model to detect a steel ball includes inputting an image of the steel ball into the model to calculate its loss level, and determining whether the steel ball has an appearance defect based on a comparison between the loss level and a preset anomaly threshold.

[0010] The innovation of this invention lies in its firstly employing an autoencoder architecture. This architecture requires only easily acquired images of defect-free steel balls for model training, effectively avoiding the performance bottleneck caused by the scarcity of defect samples, thus demonstrating strong practicality and deployability. Furthermore, the model is optimized by customizing the loss parameters of the defect-free steel ball images. Firstly, a weighted grayscale loss is introduced, allowing the model to reduce its focus on the inherent color difference boundaries of the defect-free steel balls during training, concentrating on learning the essential features of smooth regions, thereby avoiding misclassifying normal brightness variations as defects. Next, a weighted gradient loss is introduced. By reducing the learning weights of irrelevant strong edges such as the boundary between the steel ball and the background, while increasing the learning weights of weak edges on the steel ball surface, the autoencoder is guided to accurately grasp the normal texture and edge patterns of defect-free steel balls. This prevents the model from generating significant reconstruction errors when faced with images containing strong edge defects such as cracks and scratches, as it cannot accurately reconstruct these unlearned strong edges. This significantly improves the detection rate of real defects and reduces the risk of missed detections.

[0011] Preferably, obtaining the grayscale loss of each pixel includes:

[0012] The output image obtained by inputting the image of the defect-free steel ball into the autoencoder is used as the output image corresponding to the image of the defect-free steel ball.

[0013] ;

[0014] In the formula, This represents the grayscale loss of the i-th pixel in the image of a defect-free steel ball; This represents the grayscale value of the i-th pixel in the image of a defect-free steel ball; || represents the grayscale value of the i-th pixel in the output image corresponding to the image of the defect-free steel ball; || represents the absolute value sign.

[0015] Preferably, obtaining the weights of the grayscale loss for each pixel includes:

[0016] Obtain the neighboring pixels of each pixel in a defect-free image;

[0017] ;

[0018] In the formula, The weight representing the grayscale loss of the i-th pixel in a defect-free image; This represents the standard deviation of the gray values ​​of all neighboring pixels of the i-th pixel in a defect-free image. This represents the maximum gray value among all neighboring pixels of the i-th pixel in a defect-free image. This represents the minimum gray value among all neighboring pixels of the i-th pixel in a defect-free image. `norm()` represents the preset hyperparameters; `norm()` represents the normalization function.

[0019] By reducing the weight of grayscale loss at the boundary of inherent color difference of defect-free steel balls, we can focus on learning the essential features of smooth areas, thereby avoiding misjudging normal brightness changes as defects.

[0020] Preferably, obtaining the gradient loss for each pixel includes:

[0021] ;

[0022] In the formula, The gradient loss represents the i-th pixel in the image of a defect-free steel ball; This represents the gradient value of the i-th pixel in the image of a defect-free steel ball; The gradient value represents the i-th pixel in the output image corresponding to the image of the defect-free steel ball; || represents the absolute value sign.

[0023] Preferably, obtaining the weights of the gradient loss for each pixel includes:

[0024] Obtain the pixels at the same distance from each pixel in the image of a defect-free steel ball;

[0025] ;

[0026] In the formula, The weights represent the gradient loss of the i-th pixel in the image of a defect-free steel ball; This represents the gradient value of the i-th pixel in the image of a defect-free steel ball; This represents the mean gradient of all pixels in an image of a defect-free steel ball. Represents the preset hyperparameters; represents the standard deviation of the grayscale loss weights of all pixels at the same distance from the i-th pixel in the defect-free steel ball image; exp() represents an exponential function with the natural constant as the base.

[0027] By assigning different learning weights to edges of varying intensities, the detection rate of real defects was improved.

[0028] Preferably, the loss of each pixel in the defect-free steel ball image is obtained by:

[0029] ;

[0030] In the formula, This represents the loss of the i-th pixel in the image of a defect-free steel ball; This represents the grayscale loss of the i-th pixel in the image of a defect-free steel ball; The weight representing the grayscale loss of the i-th pixel in a defect-free image; The weights represent the gradient loss of the i-th pixel in the image of a defect-free steel ball; This represents the gradient loss at the i-th pixel in the image of a defect-free steel ball.

[0031] By combining gradient loss and grayscale loss, the loss of each pixel can be accurately evaluated.

[0032] Preferably, the step of inputting the image of the steel ball to be detected into the model to calculate its loss degree includes:

[0033] The steel ball to be tested is transported to the steel ball carrier through the feeding pipe. The steel ball to be tested is rotated by the carrier rotation module. The photoelectric detection machine collects images of the steel ball to be tested from various angles. The images of the steel ball to be tested from each angle are input into the trained autoencoder to obtain the degree of loss of the images of the steel ball to be tested from each angle.

[0034] Preferably, determining whether the steel ball to be detected has an appearance defect based on the comparison result between the degree of loss and a preset abnormality threshold includes:

[0035] The average loss of all defect-free steel ball images in the training dataset is used as the anomaly threshold. If the loss of the steel ball image to be detected at all angles is less than the anomaly threshold, the steel ball to be detected is sent to the good product channel; if the loss of the steel ball image to be detected at any angle and its output image is greater than the anomaly threshold, the steel ball to be detected is sent to the defective product channel.

[0036] This greatly improves the detection rate of real defects and reduces the risk of missed detection.

[0037] Preferably, obtaining the equidistant pixels of each pixel in the defect-free steel ball image includes:

[0038] The center pixel of the defect-free steel ball image is taken as the center of the steel ball. The distance between each pixel in the defect-free steel ball image and the center of the steel ball is obtained. Several pixels with equal distances are taken as a group of equidistant pixels to obtain the equidistant pixels of each pixel in the defect-free steel ball image.

[0039] Secondly, the present invention provides a steel ball appearance defect detection system based on deep learning, which adopts the following technical solution:

[0040] A deep learning-based steel ball appearance defect detection system includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the aforementioned deep learning-based steel ball appearance defect detection method.

[0041] By adopting the above technical solution, a computer program for detecting steel ball appearance defects based on deep learning is generated and stored in a memory so that it can be loaded and executed by a processor. This allows for the creation of a terminal device based on the memory and processor, making it convenient to use.

[0042] The present invention has the following technical effects: First, it acquires images of defect-free steel balls for autoencoder model training, effectively avoiding the bottleneck caused by the scarcity of defect samples on model performance. Next, it optimizes the autoencoder model by customizing the loss level of the defect-free steel ball images. Firstly, it introduces weighted grayscale loss, enabling the model to reduce its focus on the inherent color difference boundaries of defect-free steel balls during training, concentrating on learning the essential features of smooth regions, thereby avoiding misjudging normal brightness variations as defects. Then, it introduces weighted gradient loss, which, by reducing the learning weight of strong, irrelevant edges such as the boundary between the steel ball and the background, while increasing the learning weight of weak edges on the steel ball surface, greatly improves the detection rate of real defects and reduces the risk of missed defect detection. Attached Figure Description

[0043] Figure 1 This is a flowchart of a deep learning-based method for detecting steel ball appearance defects according to an embodiment of the present invention. Detailed Implementation

[0044] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.

[0045] This invention discloses a deep learning-based method for detecting surface defects in steel balls, referring to... Figure 1 This includes steps S1-S4:

[0046] S1: Collect images of defect-free steel balls to form the training dataset.

[0047] In this embodiment of the invention, several defect-free steel balls are transported to a steel ball carrier through a feeding pipe. Each defect-free steel ball is rotated by a carrier rotation module. A photoelectric detection machine collects images of the defect-free steel balls at different angles to obtain several RGB images of the defect-free steel balls. Each RGB image of the defect-free steel ball is then converted to grayscale to obtain an image of each defect-free steel ball. All the images of the defect-free steel balls are used to form a training dataset.

[0048] S2: Obtain the grayscale loss and weight of each pixel in the defect-free steel ball image, and obtain the gradient loss and weight of each pixel in the defect-free steel ball image.

[0049] It should be noted that appearance defects in the steel ball production process include cracks, scratches, chipping, black spots, and dents. These defects can cause obvious differences in grayscale values ​​in the steel ball image. However, due to the spherical nature of the steel ball surface, factors such as lighting and shooting angle can also cause color differences between different areas in the image. Furthermore, there are color differences between the steel ball area and the background area in the image. These color differences may be confused with the grayscale changes caused by defects, which may lead to missed or false detections when inspecting the appearance defects of steel balls.

[0050] In the steel ball production process, defects are relatively rare, resulting in a limited number of defective steel ball images that can be collected. Traditional image classification algorithms require a sufficient number of positive and negative samples for training. However, due to the scarcity of defective images, conventional image classification algorithms may not be able to effectively identify the appearance defects of steel balls. Therefore, this paper proposes to construct an autoencoder for steel ball appearance defect detection. The autoencoder consists of an encoder and a decoder. Its working principle is to use the encoder to compress an image of a defect-free steel ball, and the decoder to reconstruct the image from the compression result. In this process, the autoencoder only learns the feature representation of defect-free steel balls. Therefore, when the autoencoder attempts to reconstruct an image of a defective steel ball, since it has not learned the defect features, the reconstructed image will differ significantly from the original image. This reconstruction error can be used to determine whether the steel ball is defective. If the reconstruction error is too high, the steel ball is considered to be defective. This method can solve the problem of the limited number of defective steel ball samples and can also effectively avoid the influence of color differences in defect-free steel ball images on defect identification by learning the feature representation of defect-free steel balls.

[0051] It should be further explained that the purpose of this invention is to train the encoder by learning the characteristics of defect-free steel balls, so that when a defect-free steel ball image is input into the trained autoencoder, the reconstruction error between the reconstructed image and the original image is very small, while when a defective steel ball image is input, the reconstruction error between the reconstructed image and the original image is large, thereby recognizing defective steel ball images. Since the loss function in the autoencoder is used to measure the difference between the reconstructed image and the original image, during the training process, the autoencoder will try to minimize the value of the loss function to gradually adjust the parameters so that the reconstructed image is close to the original image. This invention first evaluates the grayscale loss of each pixel in the defect-free steel ball image based on the grayscale difference between the acquired defect-free steel ball image and its reconstructed image.

[0052] In this embodiment of the invention, any defect-free steel ball image in the training dataset is input into the autoencoder to obtain the output image corresponding to the defect-free steel ball image;

[0053] The preset window side length W=5. In other embodiments, the implementer can preset the value of W according to the specific implementation method, and construct a window with each pixel in the defect-free steel ball image as the center. The window is used as the neighborhood window of each pixel, and all pixels in the neighborhood window of each pixel are used as the neighborhood pixels of each pixel in the defect-free steel ball image.

[0054] Obtain the grayscale loss of each pixel in an image of a defect-free steel ball:

[0055] ;

[0056] In the formula, This represents the grayscale loss of the i-th pixel in the image of a defect-free steel ball; This represents the grayscale value of the i-th pixel in the image of a defect-free steel ball; The grayscale value of the i-th pixel in the output image corresponding to the image of the defect-free steel ball is represented by ||; || represents the absolute value sign. The larger the value, the greater the change in grayscale of the pixels before and after the reconstruction of the image, and the greater the grayscale loss of the pixels.

[0057] It should be noted that pixels located at the color difference boundary in a defect-free steel ball image do not necessarily represent defects in the steel ball. If the autoencoder is too sensitive to the grayscale loss of pixels at the color difference decomposition during training, it may cause the model to overfit the grayscale fluctuations in the defect-free steel ball image. Therefore, this invention requires setting the weight of the grayscale loss of pixels located at the color difference boundary as small as possible to reduce the sensitivity of the autoencoder parameter update process to the grayscale fluctuations in the defect-free steel ball image and reduce the impact on the total loss of the entire image.

[0058] Obtain the weights of the grayscale loss for each pixel in a defect-free image:

[0059] ;

[0060] In the formula, The weight representing the grayscale loss of the i-th pixel in a defect-free image; This represents the standard deviation of the gray values ​​of all neighboring pixels of the i-th pixel in a defect-free image. This represents the maximum gray value among all neighboring pixels of the i-th pixel in a defect-free image. This represents the minimum gray value among all neighboring pixels of the i-th pixel in a defect-free image. Representing preset hyperparameters, in this embodiment of the invention, the preset... To ensure the denominator is 0; norm() represents the normalization function;

[0061] This reflects the degree of unevenness in the grayscale distribution of the i-th pixel's neighboring pixels. This represents the local contrast of the i-th pixel, therefore as well as The larger the value, the more likely the i-th pixel is to be at the color difference boundary in the defect-free steel ball image. The weight of the gray loss of the i-th pixel should be smaller to reduce the impact of the gray loss of the i-th pixel on the total loss and reduce the sensitivity of the autoencoder parameter update process to gray fluctuations in the defect-free steel ball image. as well as The smaller the value, the more likely the i-th pixel is to be in the smooth grayscale region of the defect-free steel ball image. Therefore, the weight of the grayscale loss of the i-th pixel should be increased to enhance its influence on the total loss and enable the autoencoder to quickly learn the features of the defect-free steel ball during parameter update.

[0062] It should be noted that the gradient is the rate of change of pixel values ​​in an image, and it usually changes more significantly at the edges. Therefore, by calculating the gradient loss of each pixel in the defect-free steel ball image, the autoencoder can pay more attention to the edge information in the steel ball image during training. This helps the autoencoder learn to better capture the edge features of the defect-free steel ball image during training, thereby improving the accuracy of defect detection.

[0063] It is known that defects such as cracks, scratches, and chipping of steel balls usually appear as obvious strong edges in images. However, weak edges are generated at the color difference boundaries caused by illumination, and these weak edges on the surface of the steel ball are not as obvious as the defective edges. If the autoencoder does not learn the weak edges in the image of a defect-free steel ball sufficiently, the reconstruction error of the autoencoder will be reduced when there are defects on the steel ball to be detected, resulting in missed defects. In addition, strong edges are generated at the color difference boundaries between the steel ball and the background. If the autoencoder is too sensitive to these strong edges, it may misjudge normal color difference boundaries between the steel ball and the background as defects. Therefore, it is necessary to reduce the learning of irrelevant strong edges in the image of a defect-free steel ball by the autoencoder to avoid learning strong edges and causing missed defects.

[0064] Therefore, this invention obtains the weight of the gradient loss of each pixel in the defect-free steel ball image, assigns a smaller weight to the gradient loss of pixels belonging to strong edges to suppress the learning ability of the autoencoder to strong edges, and assigns a larger weight to the gradient loss of pixels belonging to weak edges or smooth regions to guide the autoencoder to fit the weak edge features of the defect-free steel ball image.

[0065] In this embodiment of the invention, the gradient loss of each pixel in the defect-free steel ball image is obtained:

[0066] ;

[0067] In the formula, The gradient loss represents the i-th pixel in the image of a defect-free steel ball; This represents the gradient value of the i-th pixel in the image of a defect-free steel ball; The gradient value represents the i-th pixel in the output image corresponding to the image of the defect-free steel ball; || represents the absolute value sign. The larger the value, the greater the gradient change of the pixels before and after the reconstruction of the image, and the greater the gradient loss of the pixels.

[0068] The center pixel of the defect-free steel ball image is taken as the center of the steel ball. The distance between each pixel in the defect-free steel ball image and the center of the steel ball is obtained. Several pixels with equal distances are taken as a group of equidistant pixels to obtain the equidistant pixels of each pixel in the defect-free steel ball image.

[0069] Obtain the weights of the gradient loss for each pixel in the defect-free steel ball image:

[0070] ;

[0071] In the formula, The weights represent the gradient loss of the i-th pixel in the image of a defect-free steel ball; This represents the gradient value of the i-th pixel in the image of a defect-free steel ball; This represents the mean gradient of all pixels in an image of a defect-free steel ball. Representing preset hyperparameters, in this embodiment of the invention, the preset... In order to make the denominator 0; represents the standard deviation of the grayscale loss weights of all pixels at the same distance from the i-th pixel in the defect-free steel ball image; exp() represents an exponential function with the natural constant as the base.

[0072] as well as The larger the value, the greater the gradient value of the i-th pixel is than the overall level of the image. This means that the i-th pixel is located at the boundary between the steel ball and the background and is a strong edge. It is necessary to suppress the autoencoder's ability to directly copy strong edges and avoid misjudging the normal boundary between the steel ball and the background as a defect. At this time, the smaller the weight of the gradient loss of the i-th pixel. as well as The smaller the value, the smaller the gradient value of the i-th pixel is compared to the overall level of the image. This indicates that the i-th pixel is located at the boundary of color difference caused by illumination or in a smooth gray area. In order to guide the autoencoder to fit the weak edge features of the defect-free steel ball image, the weight of the gradient loss of the i-th pixel should be increased.

[0073] Since the steel ball is spherical, ideally, pixels equidistant from the center of the ball should have consistent grayscale values. However, due to color differences between different regions in an image of a defect-free steel ball, the weights of grayscale loss for pixels equidistant from the center may differ. Therefore, if... The larger the value of , the smaller the weight of the gradient loss of the i-th pixel needs to be to prevent the color difference change from being learned by the autoencoder.

[0074] S3: Obtain the loss of each pixel in the defect-free steel ball image, and obtain the loss level of the defect-free steel ball image based on the loss of each pixel in the defect-free steel ball image; input each defect-free steel ball image and the loss level of each defect-free steel ball image into the autoencoder for training, and obtain the trained autoencoder.

[0075] It should be noted that this invention considers the grayscale loss and gradient loss of each pixel to obtain the loss of each pixel in the defect-free steel ball image. The grayscale loss of each pixel is weighted according to the grayscale loss weight, and the gradient loss of each pixel is weighted according to the gradient loss weight. Finally, the average loss of all pixels in the defect-free steel ball image is used as the loss level of the defect-free steel ball image, and the autoencoder is trained according to the loss level of the defect-free steel ball image.

[0076] In an embodiment of the invention, the loss of each pixel in the defect-free steel ball image is obtained:

[0077] ;

[0078] In the formula, This represents the loss of the i-th pixel in the image of a defect-free steel ball; This represents the grayscale loss of the i-th pixel in the image of a defect-free steel ball; The weight representing the grayscale loss of the i-th pixel in a defect-free image; The weights represent the gradient loss of the i-th pixel in the image of a defect-free steel ball; This represents the gradient loss at the i-th pixel in the image of a defect-free steel ball.

[0079] The degree of loss in obtaining images of defect-free steel balls:

[0080] ;

[0081] In the formula, This represents the degree of loss in an image of a defect-free steel ball; This represents the loss of the i-th pixel in the image of a defect-free steel ball; This represents the number of pixels in an image of a defect-free steel ball.

[0082] The preset number of training iterations U=50 is used to obtain the loss level of each defect-free steel ball image. Each defect-free steel ball image and its loss level are then input into the autoencoder for training. The training stops when the preset number of iterations is reached, resulting in a trained autoencoder.

[0083] S4: Input the image of the steel ball to be detected into the trained autoencoder to perform defect detection.

[0084] It should be noted that after the autoencoder is trained, defects in the steel ball to be tested are detected.

[0085] In this embodiment of the invention, the steel ball to be tested is transported to the steel ball carrier through the feeding pipe, the steel ball to be tested is rotated by the carrier rotation module, and images of the steel ball to be tested at various angles are collected. The images of the steel ball to be tested at various angles are input into the trained autoencoder to obtain the degree of loss of the images of the steel ball to be tested at each angle.

[0086] The average loss of all defect-free steel ball images in the training dataset is used as the anomaly threshold. If the loss of the steel ball image to be detected at all angles is less than the anomaly threshold, the steel ball to be detected is sent to the good product channel; if the loss of the steel ball image to be detected at any angle is greater than the anomaly threshold, the steel ball to be detected is sent to the defective product channel.

[0087] The above are all preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.

Claims

1. A method for detecting surface defects in steel balls based on deep learning, characterized in that, include: Train an autoencoder model based on a training dataset containing only images of defect-free steel balls; During the training of the autoencoder model, the model is optimized by customizing the loss level of the defect-free steel ball image. The loss level includes: obtaining the grayscale loss of each pixel and the weight of the grayscale loss of each pixel; obtaining the gradient loss of each pixel and the weight of the gradient loss of each pixel; calculating the sum of the weighted grayscale loss and the weighted gradient loss for each pixel as the loss of each pixel in the defect-free steel ball image; and taking the average loss of all pixels as the loss level of the defect-free steel ball image. The process of using a trained autoencoder model to detect a steel ball includes inputting an image of the steel ball to be detected into the model to calculate its loss level, and determining whether the steel ball to be detected has an appearance defect based on the comparison result of the loss level and a preset anomaly threshold. The weights for the grayscale loss of each pixel are obtained, including: Obtain the neighboring pixels of each pixel in a defect-free image; In the formula, The weight representing the grayscale loss of the i-th pixel in a defect-free image; This represents the standard deviation of the gray values ​​of all neighboring pixels of the i-th pixel in a defect-free image. This represents the maximum gray value among all neighboring pixels of the i-th pixel in a defect-free image. This represents the minimum gray value among all neighboring pixels of the i-th pixel in a defect-free image. Represents the preset hyperparameters; norm() represents the normalization function; The weights for the gradient loss at each pixel are obtained, including: Obtain the pixels at the same distance from each pixel in the image of a defect-free steel ball; In the formula, The weights represent the gradient loss of the i-th pixel in the image of a defect-free steel ball; This represents the gradient value of the i-th pixel in the image of a defect-free steel ball; This represents the mean gradient of all pixels in an image of a defect-free steel ball. represents the standard deviation of the grayscale loss weights of all pixels at the same distance from the i-th pixel in the defect-free steel ball image; exp() represents an exponential function with the natural constant as the base.

2. The method for detecting steel ball appearance defects based on deep learning according to claim 1, characterized in that, The process of obtaining the grayscale loss for each pixel includes: The output image obtained by inputting the image of the defect-free steel ball into the autoencoder is used as the output image corresponding to the image of the defect-free steel ball. ; In the formula, This represents the grayscale loss of the i-th pixel in the image of a defect-free steel ball; This represents the grayscale value of the i-th pixel in the image of a defect-free steel ball; || represents the grayscale value of the i-th pixel in the output image corresponding to the image of the defect-free steel ball; || represents the absolute value sign.

3. The method for detecting steel ball appearance defects based on deep learning according to claim 1, characterized in that, The process of obtaining the gradient loss for each pixel includes: ; In the formula, The gradient loss represents the i-th pixel in the image of a defect-free steel ball; This represents the gradient value of the i-th pixel in the image of a defect-free steel ball; The gradient value represents the i-th pixel in the output image corresponding to the image of the defect-free steel ball; || represents the absolute value sign.

4. The method for detecting steel ball appearance defects based on deep learning according to claim 1, characterized in that, The loss of each pixel in the defect-free steel ball image is obtained by: ; In the formula, This represents the loss of the i-th pixel in the image of a defect-free steel ball; This represents the grayscale loss of the i-th pixel in the image of a defect-free steel ball; The weight representing the grayscale loss of the i-th pixel in a defect-free image; The weights represent the gradient loss of the i-th pixel in the image of a defect-free steel ball; This represents the gradient loss at the i-th pixel in the image of a defect-free steel ball.

5. The method for detecting steel ball appearance defects based on deep learning according to claim 1, characterized in that, The step of inputting the image of the steel ball to be detected into the model to calculate its loss degree includes: The steel ball to be tested is transported to the steel ball carrier through the feeding pipe. The steel ball to be tested is rotated by the carrier rotation module. The photoelectric detection machine collects images of the steel ball to be tested from various angles. The images of the steel ball to be tested from each angle are input into the trained autoencoder to obtain the degree of loss of the images of the steel ball to be tested from each angle.

6. The method for detecting steel ball appearance defects based on deep learning according to claim 1, characterized in that, The step of determining whether the steel ball to be detected has an appearance defect based on the comparison result between the degree of loss and the preset abnormality threshold includes: The average loss of all defect-free steel ball images in the training dataset is used as the anomaly threshold. If the loss of the steel ball image to be detected at all angles is less than the anomaly threshold, the steel ball to be detected is sent to the good product channel; if the loss of the steel ball image to be detected at any angle and its output image is greater than the anomaly threshold, the steel ball to be detected is sent to the defective product channel.

7. The method for detecting steel ball appearance defects based on deep learning according to claim 1, characterized in that, The step of obtaining the same-distance pixels of each pixel in the defect-free steel ball image includes: The center pixel of the defect-free steel ball image is taken as the center of the steel ball. The distance between each pixel in the defect-free steel ball image and the center of the steel ball is obtained. Several pixels with equal distances are taken as a group of equidistant pixels to obtain the equidistant pixels of each pixel in the defect-free steel ball image.

8. A deep learning-based steel ball appearance defect detection system, characterized in that, include: A processor and a memory, the memory storing computer program instructions that, when executed by the processor, implement a deep learning-based method for detecting steel ball appearance defects according to any one of claims 1-7.

Citation Information

Patent Citations

  • Strip steel scabbing defect detection method based on image processing

    CN115115642A

  • Adhesive tape quality monitoring method and system based on image processing

    CN118657752A