Neodymium-iron-boron magnet surface defect detection method and system

By using a closed concealed image acquisition platform and deep learning model for defect detection on the surface of NdFeB magnets, the problems of low efficiency and accuracy of traditional detection methods are solved, and efficient and accurate non-destructive detection is achieved.

CN119762430AActive Publication Date: 2025-04-04XUZHOU NANFANG YONGCI MATERIAL

Patent Information

Application Number
CN202411761944.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-04-04
Estimated Expiration
2044-12-03

AI Technical Summary

Technical Problem

The surface defect detection of traditional neodymium iron boron magnets relies on manual visual inspection, which is inefficient, highly subjective, and difficult to identify small and concealed defects. Mechanical contact detection is prone to secondary damage.

Method used

Using a closed concealed image acquisition platform, the surface images of NdFeB magnets are captured through industrial cameras, combined with data preprocessing and a convolutional neural network model based on deep learning, image features are extracted and defect detection is performed.

Benefits of technology

It realizes efficient, accurate and lossless surface defect detection of neodymium iron boron magnets, shortens detection time, avoids mechanical damage, reduces product scrap rate, and improves the automation and accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119762430A_ABST
    Figure CN119762430A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of magnetic material detection, in particular to a neodymium iron boron magnet surface defect detection method and system.The method comprises the steps that a closed camera obscura type image acquisition platform is built, and an annular uniform light source, an industrial camera and an objective table are arranged in the closed camera obscura type image acquisition platform; placing the neodymium-iron-boron magnet on an objective table, then controlling the objective table to move according to a set path, and triggering an industrial camera at each acquisition point to shoot a magnet surface image to obtain neodymium-iron-boron magnet surface image data; carrying out data preprocessing on the obtained neodymium iron boron magnet surface image data; extracting surface image features of the neodymium-iron-boron magnet based on a gray-level co-occurrence matrix after data preprocessing is completed; after feature extraction is completed, a neodymium iron boron magnet surface defect detection model based on deep learning is constructed and trained, and after training is completed, neodymium iron boron magnet surface defect detection is conducted. According to the method, the surface defects of the neodymium-iron-boron magnet are accurately detected through a method of combining image detection with machine learning, the product quality is guaranteed, and the automation level of detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of magnetic material detection, and in particular to a method and system for detecting surface defects of a neodymium iron boron magnet. Background Art

[0002] As a high-performance permanent magnetic material, NdFeB magnets are widely used in electronics, automobiles, aerospace and many other fields. However, during its production and processing, due to the influence of raw material characteristics and manufacturing processes (such as sintering, cutting, grinding, electroplating, etc.), cracks, scratches, pits, holes, coating shedding and other defects are prone to appear on the surface. These defects not only affect the appearance quality of the magnet, but are also likely to damage its magnetic properties, mechanical strength and service life. In severe cases, they can also cause failures in the use scenario, such as affecting the stability of electromagnetic induction in electronic equipment.

[0003] Traditional surface defect detection of NdFeB magnets mostly relies on manual visual inspection, which has low detection efficiency, strong subjectivity, easy to miss due to fatigue, and difficult to accurately identify small and hidden defects; some use mechanical contact detection methods, which have certain accuracy but are prone to secondary damage to the magnet surface. With the development of industrial automation and intelligence, the use of non-contact detection technologies such as machine learning to achieve efficient, accurate and non-destructive surface defect detection of NdFeB magnets has become an urgent need in the industry. Summary of the invention

[0004] In view of the above-mentioned technical deficiencies, the present invention provides a method and system for detecting surface defects of NdFeB magnets.

[0005] The present invention is achieved through the following technical solutions: A method for detecting surface defects of a neodymium iron boron magnet is provided, the method comprising the following steps: Step S10: construct a closed dark box image acquisition platform and set a ring-shaped uniform light source, an industrial camera and a stage therein, place the NdFeB magnet on the stage and control the stage to move along a set path, trigger the industrial camera at each acquisition point to capture the surface image of the magnet to obtain the surface image data of the NdFeB magnet; Step S20: performing data preprocessing on the obtained surface image data of the NdFeB magnet; Step S30: After the data preprocessing is completed, the surface image features of the NdFeB magnet are extracted based on the gray level co-occurrence matrix; Step S40: after feature extraction is completed, a surface defect detection model for NdFeB magnets based on deep learning is constructed and trained, and after training is completed, surface defect detection of NdFeB magnets is performed and the detection results are output; Wherein, before the industrial camera captures the magnet surface image in step S10, the focal length and aperture of the camera are automatically adjusted according to the clarity of the presented image, and the moving path of the stage and the acquisition point of the industrial camera are set according to the size specifications of the NdFeB magnet; in addition, the surface image of the NdFeB magnet captured by the industrial camera is a lossless image with a resolution of 2k, and multiple frames of images are captured for different areas of the surface of the NdFeB magnet, including the top surface, bottom surface and side surface of the NdFeB magnet; Among them, in step S40, a surface defect detection model of NdFeB magnet based on deep learning is constructed using an improved convolutional neural network model, and the convergence speed of model training is improved by adding residual links in the network model structure; after the training is completed, surface defect detection of NdFeB magnet is performed, and the output detection results are defective and non-defective; when the output result is defective, the detected defect category is output at the same time and the location of the defect is accurately marked in the image where the defect is detected.

[0006] Preferably, the step of preprocessing the obtained surface image data of the NdFeB magnet in step S20 includes: Grayscale processing: grayscale the acquired NdFeB magnet surface image data to reduce the data volume and computational complexity, and set the channel weights of the red, green and blue channels to W respectively. R , W G and W B For each pixel point P(x,y) in the surface image data of the NdFeB magnet, the calculation formula of its gray value Gray(x,y) is as shown in formula (1): (1) Where R(x,y), G(x,y) and B(x,y) are the pixel values ​​of the pixel point P(x,y) in the red, green and blue channels respectively. After traversing each pixel point in the NdFeB magnet surface image data, the grayscale image corresponding to the NdFeB magnet surface image is obtained; Denoising: Use median filtering to remove image noise and retain edge details. Determine the size of the filter window based on the noise level and detail richness of the image. For each pixel point P(x,y) in the surface image data of the NdFeB magnet, determine the corresponding filter window with it as the center. When the filter window exceeds the boundary, the excess part is processed by zero padding or mirroring. Extract all the pixels in the window to form a set S={P1,P2,...,P n}, where n is the total number of pixels in the window; sort the pixel values ​​in the set S from small to large, and take the middle value after sorting as the new pixel value of the pixel point P(x, y) after filtering. When n is an odd number, the middle value is unique; when n is an even number, take the average of the two middle values; Histogram equalization processing: Scan the grayscale and noise-removed NdFeB magnet surface image, count the frequency of each gray level, and construct a histogram H(k), where k is the gray level and H(k) is the number of pixels with a gray value of k; calculate the cumulative distribution function based on the histogram, as shown in formula (2): (2) Where CDF(k) is the cumulative distribution function, which indicates the cumulative proportion of pixels with grayscale values ​​less than or equal to k. Its value range starts from 0 and gradually increases to 1. i is the index variable used to traverse all grayscale levels from 0 to k. H(i) is the number of pixels with grayscale level i. After calculating CDF(k), grayscale value mapping is performed again to obtain a new grayscale value T(k). The calculation formula is shown in formula (3): (3) Where L is the total number of gray levels, and round is a rounding function. After traversing each pixel in the surface image of the NdFeB magnet, the original gray value Gray(x, y) is replaced by the new gray value T(k) to obtain the surface image of the NdFeB magnet after histogram equalization.

[0007] Preferably, the step of extracting surface image features of NdFeB magnets based on gray level co-occurrence matrix in step S30 includes: Constructing a grayscale co-occurrence matrix: according to the grayscale image of the surface image of the NdFeB magnet obtained in step S20, determine the grayscale level L, distance d and direction θ of the parameters and initialize a two-dimensional array of size L×L as the grayscale co-occurrence matrix A, and all elements in the matrix are initialized to 0; traverse each pixel point in the image to obtain the grayscale value a of the current pixel point, find the corresponding adjacent pixel point according to the distance d and direction θ, and obtain its grayscale value b; add 1 to the elements in the grayscale co-occurrence matrix A, indicating the number of times the pixel pairs with grayscale values ​​of a and b appear at a given distance and direction; after traversing the entire image, divide each element in the grayscale co-occurrence matrix A by the total number of pixel pairs to obtain a normalized grayscale co-occurrence matrix, so that A(a,b) represents the probability of the pixel pairs with grayscale values ​​of a and b appearing; Calculate texture feature parameters: Calculate the energy characteristics and contrast characteristics of the surface image of the NdFeB magnet based on the obtained A(a,b).

[0008] Among them, in the step of calculating the texture feature parameters, the energy features and contrast features of the surface image of the NdFeB magnet are calculated according to the obtained A(a, b), specifically including: Energy feature calculation: Calculate the energy feature according to the energy calculation formula, as shown in formula (4): (4) For the normalized gray-level co-occurrence matrix A, use two layers of nested loops to traverse each element A(a, b) in the matrix; calculate the square of each element A(a, b) 2 , and accumulated into a variable Energy, the final value of the variable Energy is the energy characteristic of the surface image of the NdFeB magnet; Contrast feature calculation: The contrast feature is calculated according to the contrast calculation formula, as shown in formula (5): (5) Also use a nested loop to traverse the gray-level co-occurrence matrix A. For each element A(a,b), calculate (ab) 2 A(a,b) is accumulated into a variable Contrast to obtain the contrast characteristics of the surface image of the NdFeB magnet.

[0009] Preferably, in step S40, a surface defect detection model for NdFeB magnets based on deep learning is constructed and trained, and the steps of constructing and training the model include: Dataset preparation: Obtain existing surface defect image data of different types of NdFeB magnets from the Internet or other historical datasets of NdFeB magnet surface defect images, divide them into training set, validation set and test set in a ratio of 70%:15%:15%, and annotate the corresponding defect types in the training set image data for the model to learn the surface defect characteristics of different types of NdFeB magnets; Determine the loss function and optimizer: Use binary cross entropy as the loss function, use the Adam optimization algorithm as the optimizer, adaptively adjust the learning rate and dynamically update the model parameters. The initial learning rate is set to 0.001 and is adjusted according to the number of training rounds. Model construction: The entire network model includes input layer, convolution layer, pooling layer, residual link layer, fully connected layer and output layer; the input of the input layer is the image data after data preprocessing and feature value extraction; ReLU is used as the activation function in the convolution layer; the pooling layer is set after each convolution layer, and the maximum pooling method is adopted; the residual connection layer is set after the last two convolution layers and before the pooling layer, between the convolution layer and the pooling layer; the fully connected layer is set after the pooling layer, and the feature map output by the pooling layer is flattened and converted into a one-dimensional vector form, and ReLU is selected as the activation function; the output layer is set as the last layer of the entire network model, and according to the corresponding number of surface defect categories of NdFeB magnets, the probability distribution of each defect category is output after Softmax processing, and each value corresponds to the confidence of the defect category. The confidence threshold is set to 0.5. When the confidence is less than 0.5, the output is defect-free, and when the confidence is greater than or equal to 0.5, the output is defective and the defect category is output at the same time; the confidence threshold is dynamically adjusted according to the output result; Model training and verification: After the model is built, set the model parameters, use the divided training set as input to train the model, and use the divided verification set to verify the trained model after each training round; Model evaluation: When overfitting occurs, stop model training and validation operations, and use the divided test set to evaluate the model; Model optimization: Adjust model parameters and retrain according to model evaluation results until the optimal model parameter combination is obtained and the corresponding model version is determined.

[0010] Among them, the categories of output defects in the model construction step include cracks, scratches, pits and holes. Different defect types correspond to different texture features extracted based on the grayscale co-occurrence matrix. The model judges the defect type existing in the input image by learning the features of different surface defect types of NdFeB magnets. For example, for cracks, it can be judged based on the contrast feature, which usually forms an obvious grayscale difference boundary on the surface. Along the direction of the crack, the grayscale value on one side is different from the grayscale value on the other side. For pitting defects, it can be judged by energy features. The existence of pitting makes the texture uneven and complex, making its energy lower. For scratches, it can be judged by contrast features. The contrast in the direction of the scratch will increase significantly. Due to the obvious grayscale difference on both sides of the scratch, this large grayscale change between adjacent pixels will lead to an increase in contrast, which is in sharp contrast with the surrounding normal area. For holes, it can also be judged based on energy features. The energy of the hole area is low, especially inside the hole, because the grayscale distribution is relatively uniform (usually a darker grayscale value), while at the edge of the hole, the energy will change locally, but overall due to the existence of the hole, the energy of this area is lower than the normal surface.

[0011] Cracks are linear gaps on the surface of magnets. They may be tiny hairline cracks or wider and deeper cracks. The direction and length of the cracks vary. Some may be single straight cracks or complex branching cracks. They are usually caused by internal stress concentration in the material, mechanical damage during processing (such as improper cutting, grinding, etc.), or external impact during use. Scratches appear as linear marks on the surface, which are generally shallower than cracks. The width of the scratches is relatively narrow, and the edges are relatively clear. Scratches may appear alone or multiple scratches may cross each other. They are mainly caused by friction during the production process, collision during transportation, or contact and scratching with other hard objects. Pits are distributed on the surface of the magnet in the form of dots, with different sizes and approximately circular shapes. There may be tiny depressions on the surface of the pitted area, which contrasts with the surrounding normal surface. This may be caused by impurities in the raw materials, residual bubbles during the sintering process, or local problems during the electroplating process. Holes are obvious hollow areas formed on the surface of the magnet. The size and depth vary depending on the specific situation. The edges of the holes may be relatively regular or irregular. They may be formed during the manufacturing process, such as the powder metallurgy molding process, due to uneven powder filling, or during the sintering process, when substances evaporate and leave gaps.

[0012] In addition, to achieve the above-mentioned purpose, the present invention also proposes a surface defect detection system for NdFeB magnets, the surface defect detection system for NdFeB magnets comprising: Platform construction and data acquisition module: used to build a closed dark box image acquisition platform and set up a ring-shaped uniform light source, an industrial camera and a stage in it. After placing the NdFeB magnet on the stage, the stage is controlled to move along the set path, and the industrial camera is triggered at each acquisition point to capture the surface image of the magnet to obtain the surface image data of the NdFeB magnet; NdFeB magnet surface image data preprocessing module: used for preprocessing the obtained NdFeB magnet surface image data; NdFeB magnet surface image data feature extraction module: used to extract NdFeB magnet surface image features based on gray level co-occurrence matrix after data preprocessing; NdFeB magnet surface defect detection model training and application module: used to build and train a NdFeB magnet surface defect detection model based on deep learning after feature extraction is completed. After training, NdFeB magnet surface defect detection is performed and the detection results are output; Before the industrial camera in the platform construction and data acquisition module takes an image of the magnet surface, the focal length and aperture of the camera are automatically adjusted according to the clarity of the presented image, and the moving path of the stage and the collection points of the industrial camera are set according to the size specifications of the NdFeB magnet; in addition, the surface image of the NdFeB magnet taken by the industrial camera is a lossless image with a resolution of 2k, and multiple frames of images are taken for different areas of the surface of the NdFeB magnet, including the top surface, bottom surface and side surface of the NdFeB magnet; The NdFeB magnet surface defect detection model based on deep learning is constructed in the NdFeB magnet surface defect detection model training and application module, and adopts an improved convolutional neural network model. By adding residual links in the network model structure, the convergence speed of model training is improved; after the training is completed, the surface defect detection of the NdFeB magnet is carried out, and the output detection results are defective and non-defective; when the output result is defective, the detected defect category is output at the same time, and the position where the defect occurs is accurately marked in the image where the defect is detected.

[0013] In addition, to achieve the above-mentioned purpose, the present invention also proposes a NdFeB magnet surface defect detection device, which includes: a memory, a processor, and programs such as a NdFeB magnet surface defect detection algorithm based on deep learning stored in the memory and run on the processor. The programs such as the NdFeB magnet surface defect detection algorithm based on deep learning are steps to implement a NdFeB magnet surface defect detection method as described above.

[0014] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer program product, which includes programs such as a surface defect detection algorithm for NdFeB magnets based on deep learning. When the programs such as the surface defect detection algorithm for NdFeB magnets based on deep learning are executed by a processor, a surface defect detection method for NdFeB magnets as described above is implemented.

[0015] The advantages and effects of the present invention are: The present invention proposes a method and system for detecting surface defects of NdFeB magnets, which use image detection combined with machine learning to accurately detect tiny and hidden defects on the surface of NdFeB magnets. Through automated image acquisition and fast algorithm processing, the detection time of surface defects of NdFeB magnets is greatly shortened. At the same time, through non-contact optical acquisition and processing, mechanical damage to NdFeB magnets is avoided, product integrity is guaranteed, and product scrap rate is reduced, thereby realizing automated, efficient and accurate surface defect detection of NdFeB magnets, reducing manual operation links and reducing labor costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0017] Figure 1 The present invention is a flow chart of a method for detecting surface defects of NdFeB magnets.

[0018] Figure 2 The present invention is a schematic diagram of the structure of a surface defect detection system for NdFeB magnets.

[0019] Figure 3 The present invention is a schematic block diagram of the structure of an electronic device for detecting surface defects of a NdFeB magnet. DETAILED DESCRIPTION

[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0021] The present invention provides a method for detecting surface defects of NdFeB magnets. Figure 1 As shown, the following steps are included: Step S10: Build a closed darkbox image acquisition platform and set a ring-shaped uniform light source, an industrial camera and a stage in it. The central axis of the ring-shaped light source coincides with the optical axis of the camera and is perpendicular to the plane of the stage. After placing the NdFeB magnet on the stage, control the stage to move along the set path, and trigger the industrial camera at each acquisition point to capture the surface image of the magnet to obtain the surface image data of the NdFeB magnet.

[0022] Before the industrial camera takes the image of the magnet surface, it will automatically adjust the focal length and aperture of the camera according to the clarity of the presented image, and set the moving path of the stage and the collection points of the industrial camera according to the size specifications of the NdFeB magnet; in addition, the surface image of the NdFeB magnet taken by the industrial camera is a lossless image with a resolution of 2k. If RAW and other image formats are used, multiple frames of images can be taken of different areas of the surface of the NdFeB magnet, including the top, bottom and side surfaces of the NdFeB magnet, to ensure that the surface details are fully recorded.

[0023] Step S20: performing data preprocessing on the obtained surface image data of the NdFeB magnet.

[0024] Specifically, the step of preprocessing the obtained surface image data of the NdFeB magnet in step S20 includes: Grayscale processing: grayscale the acquired NdFeB magnet surface image data to reduce the data volume and computational complexity, and set the channel weights of the red, green and blue channels to W respectively. R , W G and W B , for example, setting W R =0.299, W G =0.587, W B =0.114, for each pixel point P(x,y) in the surface image data of the NdFeB magnet, the calculation formula of its gray value Gray(x,y) is shown in formula (1): (1) Where R(x,y), G(x,y) and B(x,y) are the pixel values ​​of the pixel point P(x,y) in the red, green and blue channels respectively. After traversing each pixel point in the NdFeB magnet surface image data, the grayscale image corresponding to the NdFeB magnet surface image is obtained; Denoising: Use median filtering to remove image noise and retain edge details. Determine the size of the filter window based on the noise level and detail richness of the image. For example, the size of the filter window is set to 3×3. For each pixel point P(x,y) in the surface image data of the NdFeB magnet, determine the corresponding filter window with it as the center. When the filter window exceeds the boundary, the excess part is processed by zero padding or mirroring. Extract all the pixel points in the window to form a set S={P1,P2,...,P n}, where n is the total number of pixels in the window. For example, when the size of the filter window is set to 3×3, the value of n is 9. Sort the pixel values ​​in the set S from small to large, and take the middle value after sorting as the new pixel value of the pixel point P(x, y) after filtering. When n is an odd number, the middle value is unique; when n is an even number, take the average of the two middle values. Histogram equalization processing: Scan the grayscale and noise-removed NdFeB magnet surface image, count the frequency of each grayscale level, the grayscale value range is 0 to 255, and construct a histogram H(k), where k is the grayscale level and H(k) is the number of pixels with a grayscale value of k; calculate the cumulative distribution function based on the histogram, as shown in formula (2): (2) Where CDF(k) is the cumulative distribution function, which indicates the cumulative proportion of pixels with grayscale values ​​less than or equal to k. Its value range starts from 0 and gradually increases to 1. i is the index variable used to traverse all grayscale levels from 0 to k. H(i) is the number of pixels with grayscale level i. After calculating CDF(k), grayscale value mapping is performed again to obtain a new grayscale value T(k). The calculation formula is shown in formula (3): (3) Where L is the total number of gray levels, and round is a rounding function. After traversing each pixel in the surface image of the NdFeB magnet, the original gray value Gray(x, y) is replaced by the new gray value T(k) to obtain the surface image of the NdFeB magnet after histogram equalization.

[0025] Step S30: After the data preprocessing is completed, the surface image features of the NdFeB magnet are extracted based on the gray level co-occurrence matrix.

[0026] Specifically, the step of extracting the surface image features of the NdFeB magnet based on the gray level co-occurrence matrix in step S30 includes: Constructing a grayscale co-occurrence matrix: according to the grayscale image of the surface image of the NdFeB magnet obtained in step S20, determine the grayscale level L, distance d and direction θ of the parameters and initialize a two-dimensional array of size L×L as the grayscale co-occurrence matrix A, and all elements in the matrix are initialized to 0; traverse each pixel point in the image to obtain the grayscale value a of the current pixel point, find the corresponding adjacent pixel point according to the distance d and direction θ, and obtain its grayscale value b; add 1 to the elements in the grayscale co-occurrence matrix A, indicating the number of times the pixel pairs with grayscale values ​​of a and b appear at a given distance and direction; after traversing the entire image, divide each element in the grayscale co-occurrence matrix A by the total number of pixel pairs to obtain a normalized grayscale co-occurrence matrix, so that A(a,b) represents the probability of the pixel pairs with grayscale values ​​of a and b appearing; Calculate texture feature parameters: Calculate the energy characteristics and contrast characteristics of the surface image of the NdFeB magnet based on the obtained A(a,b).

[0027] Among them, in the step of calculating the texture feature parameters, the energy features and contrast features of the surface image of the NdFeB magnet are calculated according to the obtained A(a, b), specifically including: Energy feature calculation: Calculate the energy feature according to the energy calculation formula, as shown in formula (4): (4) For the normalized gray-level co-occurrence matrix A, use two layers of nested loops to traverse each element A(a, b) in the matrix; calculate the square of each element A(a, b) 2 , and accumulated into a variable Energy, the final value of the variable Energy is the energy characteristic of the surface image of the NdFeB magnet; Contrast feature calculation: The contrast feature is calculated according to the contrast calculation formula, as shown in formula (5): (5) Also use a nested loop to traverse the gray-level co-occurrence matrix A. For each element A(a,b), calculate (ab) 2 A(a,b) is accumulated into a variable Contrast to obtain the contrast characteristics of the surface image of the NdFeB magnet.

[0028] Step S40: After feature extraction is completed, a surface defect detection model for NdFeB magnets based on deep learning is constructed and trained. After training is completed, surface defect detection of NdFeB magnets is performed and the detection results are output.

[0029] In step S40, a surface defect detection model for NdFeB magnets based on deep learning is constructed using an improved convolutional neural network model. By adding residual links to the network model structure, the convergence speed of model training is improved. After the training is completed, surface defect detection of NdFeB magnets is performed, and the output detection results are defective and non-defective. When the output result is defective, the detected defect category is output at the same time and the location of the defect is accurately marked in the image where the defect is detected.

[0030] Specifically, in step S40, a surface defect detection model for NdFeB magnets based on deep learning is constructed and trained. The steps of constructing and training the model include: Dataset preparation: Obtain existing surface defect image data of different types of NdFeB magnets from the Internet or other historical datasets of NdFeB magnet surface defect images, divide them into training set, validation set and test set in a ratio of 70%:15%:15%, and annotate the corresponding defect types in the training set image data for the model to learn the surface defect characteristics of different types of NdFeB magnets; Determine the loss function and optimizer: Use binary cross entropy as the loss function, use the Adam optimization algorithm as the optimizer, adaptively adjust the learning rate and dynamically update the model parameters. The initial learning rate is set to 0.001 and is adjusted according to the number of training rounds. Model construction: The entire network model includes input layer, convolution layer, pooling layer, residual link layer, fully connected layer and output layer; the input of the input layer is the image data after data preprocessing and feature value extraction; ReLU is used as the activation function in the convolution layer; the pooling layer is set after each convolution layer, and the maximum pooling method is adopted; the residual connection layer is set after the last two convolution layers and before the pooling layer, between the convolution layer and the pooling layer; the fully connected layer is set after the pooling layer, and the feature map output by the pooling layer is flattened and converted into a one-dimensional vector form, and ReLU is selected as the activation function; the output layer is set as the last layer of the entire network model, and according to the corresponding number of surface defect categories of NdFeB magnets, the probability distribution of each defect category is output after Softmax processing, and each value corresponds to the confidence of the defect category. The confidence threshold is set to 0.5. When the confidence is less than 0.5, the output is defect-free, and when the confidence is greater than or equal to 0.5, the output is defective and the defect category is output at the same time; the confidence threshold is dynamically adjusted according to the output result; Model training and verification: After the model is built, set the model parameters, use the divided training set as input to train the model, and use the divided verification set to verify the trained model after each training round; Model evaluation: When overfitting occurs, stop model training and validation operations, and use the divided test set to evaluate the model; Model optimization: Adjust model parameters and retrain according to model evaluation results until the optimal model parameter combination is obtained and the corresponding model version is determined.

[0031] Among them, the categories of output defects in the model construction step include cracks, scratches, pits and holes. Different defect types correspond to different texture features extracted based on the grayscale co-occurrence matrix. The model judges the defect type existing in the input image by learning the features of different surface defect types of NdFeB magnets. For example, for cracks, it can be judged based on the contrast feature, which usually forms an obvious grayscale difference boundary on the surface. Along the direction of the crack, the grayscale value on one side is different from the grayscale value on the other side. For pitting defects, it can be judged by energy features. The existence of pitting makes the texture uneven and complex, making its energy lower. For scratches, it can be judged by contrast features. The contrast in the direction of the scratch will increase significantly. Due to the obvious grayscale difference on both sides of the scratch, this large grayscale change between adjacent pixels will lead to an increase in contrast, which is in sharp contrast with the surrounding normal area. For holes, it can also be judged based on energy features. The energy of the hole area is low, especially inside the hole, because the grayscale distribution is relatively uniform (usually a darker grayscale value), while at the edge of the hole, the energy will change locally, but overall due to the existence of the hole, the energy of this area is lower than the normal surface.

[0032] Cracks are linear gaps on the surface of magnets. They may be tiny hairline cracks or wider and deeper cracks. The direction and length of the cracks vary. Some may be single straight cracks or complex branching cracks. They are usually caused by internal stress concentration in the material, mechanical damage during processing (such as improper cutting, grinding, etc.), or external impact during use. Scratches appear as linear marks on the surface, which are generally shallower than cracks. The width of the scratches is relatively narrow, and the edges are relatively clear. Scratches may appear alone or multiple scratches may cross each other. They are mainly caused by friction during the production process, collision during transportation, or contact and scratching with other hard objects. Pits are distributed on the surface of the magnet in the form of dots, with different sizes and approximately circular shapes. There may be tiny depressions on the surface of the pitted area, which contrasts with the surrounding normal surface. This may be caused by impurities in the raw materials, residual bubbles during the sintering process, or local problems during the electroplating process. Holes are obvious hollow areas formed on the surface of the magnet. The size and depth vary depending on the specific situation. The edges of the holes may be relatively regular or irregular. They may be formed during the manufacturing process, such as the powder metallurgy molding process, due to uneven powder filling, or during the sintering process, when substances evaporate and leave gaps.

[0033] In addition, by collecting more training data, especially data from categories where the model performs poorly, you can also use data augmentation techniques (such as rotation, scaling, flipping, etc.) to increase the diversity of training data, further train the model, and improve the model's detection capabilities.

[0034] In addition, the present invention also proposes a surface defect detection system for NdFeB magnets, please refer to Figure 2 The surface defect detection system of NdFeB magnets comprises: Platform construction and data acquisition module: used to build a closed dark box image acquisition platform and set up a ring-shaped uniform light source, an industrial camera and a stage in it. After placing the NdFeB magnet on the stage, the stage is controlled to move along the set path, and the industrial camera is triggered at each acquisition point to capture the surface image of the magnet to obtain the surface image data of the NdFeB magnet; NdFeB magnet surface image data preprocessing module: used for preprocessing the obtained NdFeB magnet surface image data; NdFeB magnet surface image data feature extraction module: used to extract NdFeB magnet surface image features based on gray level co-occurrence matrix after data preprocessing; NdFeB magnet surface defect detection model training and application module: used to build and train a NdFeB magnet surface defect detection model based on deep learning after feature extraction is completed. After training, NdFeB magnet surface defect detection is performed and the detection results are output; Among them, before the industrial camera in the platform construction and data acquisition module takes the image of the magnet surface, the focal length and aperture of the camera will be automatically adjusted according to the clarity of the presented image, and the moving path of the stage and the collection point of the industrial camera will be set according to the size specifications of the NdFeB magnet; In addition, the surface image of the NdFeB magnet taken by the industrial camera is a lossless image with a resolution of 2k, and multiple frames of images are taken for different areas of the surface of the NdFeB magnet, including the top, bottom and side surfaces of the NdFeB magnet; Among them, the NdFeB magnet surface defect detection model based on deep learning is constructed in the NdFeB magnet surface defect detection model training and application module. The improved convolutional neural network model is used to improve the convergence speed of model training by adding residual links in the network model structure. After the training is completed, the surface defect detection of NdFeB magnets is carried out, and the output detection results are defective and non-defective. When the output result is defective, the detected defect category is output at the same time and the location of the defect is accurately marked in the image where the defect is detected.

[0035] The present application provides a surface defect detection system for NdFeB magnets, which adopts a surface defect detection method for NdFeB magnets in the above embodiment, and can solve the technical problems of low efficiency and low accuracy of the traditional surface defect detection method for NdFeB magnets. Compared with the prior art, the beneficial effects of the surface defect detection system for NdFeB magnets provided by the present application are the same as the beneficial effects of the surface defect detection method for NdFeB magnets provided by the above embodiment, and the other technical features of the surface defect detection system for NdFeB magnets are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0036] The present application provides a surface defect detection device for NdFeB magnets, the surface defect detection device for NdFeB magnets comprising: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a surface defect detection method for NdFeB magnets in the above-mentioned embodiment 1.

[0037] Reference below Figure 3 , which shows a schematic diagram of the structure of a NdFeB magnet surface defect detection device suitable for implementing the embodiment of the present application. A NdFeB magnet surface defect detection device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 3 The NdFeB magnet surface defect detection device shown is only an example and should not bring any limitation to the function and scope of use of the embodiments of the present application.

[0038] Figure 3The surface defect detection device of a NdFeB magnet shown may include a processing system 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage system 1003 to a random access memory (RAM) 1004. Various programs and data required for the operation of a surface defect detection device of a NdFeB magnet are also stored in RAM 1004. The processing system 1001, ROM 1002, and RAM 1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: an input system 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output system 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage system 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication system 1009. The communication system 1009 can allow a NdFeB magnet surface defect detection device to communicate wirelessly or wired with other devices to exchange data. Although a NdFeB magnet surface defect detection device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.

[0039] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication system, or installed from a storage system 1003, or installed from a ROM 1002. When the computer program is executed by the processing system 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0040] The present application provides a NdFeB magnet surface defect detection device, which adopts a NdFeB magnet surface defect detection method in the above embodiment, and can solve the technical problems of low efficiency and low accuracy of the traditional NdFeB magnet surface defect detection method. Compared with the prior art, the beneficial effects of the NdFeB magnet surface defect detection device provided by the present application are the same as the beneficial effects of the NdFeB magnet surface defect detection method provided by the above embodiment, and the other technical features of the NdFeB magnet surface defect detection device are the same as the features disclosed in the previous embodiment method, which will not be repeated here.

[0041] The various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0042] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned method for detecting surface defects of NdFeB magnets.

[0043] The computer program product provided by the present application can solve the technical problems of low efficiency and low accuracy of the traditional NdFeB magnet surface defect detection method. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the NdFeB magnet surface defect detection method provided by the above embodiment, which will not be repeated here.

[0044] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for detecting surface defects of NdFeB magnets, characterized in that: The method comprises the following steps: Step S10: construct a closed dark box image acquisition platform and set a ring-shaped uniform light source, an industrial camera and a stage therein, place the NdFeB magnet on the stage and control the stage to move along a set path, trigger the industrial camera at each acquisition point to capture the surface image of the magnet to obtain the surface image data of the NdFeB magnet; Step S20: performing data preprocessing on the obtained surface image data of the NdFeB magnet; Step S30: After the data preprocessing is completed, the surface image features of the NdFeB magnet are extracted based on the gray level co-occurrence matrix; Step S40: after feature extraction is completed, a surface defect detection model for NdFeB magnets based on deep learning is constructed and trained, and after training is completed, surface defect detection of NdFeB magnets is performed and the detection results are output; Before the industrial camera captures the magnet surface image in step S10, the focal length and aperture of the camera are automatically adjusted according to the clarity of the presented image, and the moving path of the stage and the acquisition point of the industrial camera are set according to the size specifications of the NdFeB magnet; in addition, the surface image of the NdFeB magnet captured by the industrial camera is a lossless image with a resolution of 2k, and multiple frames of images are captured for different areas of the surface of the NdFeB magnet, including the top surface, bottom surface and side surface of the NdFeB magnet; In the step S40, a surface defect detection model for NdFeB magnets based on deep learning is constructed using an improved convolutional neural network model, and a residual link is added to the network model structure to improve the convergence speed of model training; after the training is completed, surface defect detection of NdFeB magnets is performed, and the output detection results are defective and non-defective; when the output result is defective, the detected defect category is output at the same time, and the location of the defect is accurately marked in the image where the defect is detected.

2. A method for detecting surface defects of NdFeB magnets according to claim 1, characterized in that: The step of preprocessing the obtained surface image data of the NdFeB magnet in step S20 includes: Grayscale processing: grayscale the acquired NdFeB magnet surface image data to reduce the data volume and computational complexity, and set the channel weights of the red, green and blue channels to W respectively. R , W G and W B For each pixel point P(x,y) in the surface image data of the NdFeB magnet, the calculation formula of its gray value Gray(x,y) is as shown in formula (1): (1) Where R(x,y), G(x,y) and B(x,y) are the pixel values ​​of the pixel point P(x,y) in the red, green and blue channels respectively. After traversing each pixel point in the NdFeB magnet surface image data, the grayscale image corresponding to the NdFeB magnet surface image is obtained; Denoising: Use median filtering to remove image noise and retain edge details. Determine the size of the filter window based on the noise level and detail richness of the image. For each pixel point P(x,y) in the surface image data of the NdFeB magnet, determine the corresponding filter window with it as the center. When the filter window exceeds the boundary, the excess part is processed by zero padding or mirroring. Extract all the pixels in the window to form a set S={P1,P2,...,P n }, where n is the total number of pixels in the window; sort the pixel values ​​in the set S from small to large, and take the middle value after sorting as the new pixel value of the pixel point P(x, y) after filtering. When n is an odd number, the middle value is unique; when n is an even number, take the average of the two middle values; Histogram equalization processing: Scan the grayscale and noise-removed NdFeB magnet surface image, count the frequency of each gray level, and construct a histogram H(k), where k is the gray level and H(k) is the number of pixels with a gray value of k; calculate the cumulative distribution function based on the histogram, as shown in formula (2): (2) Where CDF(k) is the cumulative distribution function, which indicates the cumulative proportion of pixels with grayscale values ​​less than or equal to k. Its value range starts from 0 and gradually increases to 1. i is the index variable used to traverse all grayscale levels from 0 to k. H(i) is the number of pixels with grayscale level i. After calculating CDF(k), grayscale value mapping is performed again to obtain a new grayscale value T(k). The calculation formula is shown in formula (3): (3) Where L is the total number of gray levels, and round is a rounding function. After traversing each pixel in the surface image of the NdFeB magnet, the original gray value Gray(x, y) is replaced by the new gray value T(k) to obtain the surface image of the NdFeB magnet after histogram equalization.

3. A method for detecting surface defects of NdFeB magnets according to claim 1, characterized in that: The step of extracting the surface image features of the NdFeB magnet based on the gray level co-occurrence matrix in step S30 includes: Constructing a grayscale co-occurrence matrix: according to the grayscale image of the surface image of the NdFeB magnet obtained in step S20, determine the grayscale level L, distance d and direction θ of the parameters and initialize a two-dimensional array of size L×L as the grayscale co-occurrence matrix A, and all elements in the matrix are initialized to 0; traverse each pixel point in the image to obtain the grayscale value a of the current pixel point, find the corresponding adjacent pixel point according to the distance d and direction θ, and obtain its grayscale value b; add 1 to the elements in the grayscale co-occurrence matrix A, indicating the number of times the pixel pairs with grayscale values ​​of a and b appear at a given distance and direction; after traversing the entire image, divide each element in the grayscale co-occurrence matrix A by the total number of pixel pairs to obtain a normalized grayscale co-occurrence matrix, so that A(a,b) represents the probability of the pixel pairs with grayscale values ​​of a and b appearing; Calculate texture feature parameters: Calculate the energy characteristics and contrast characteristics of the surface image of the NdFeB magnet based on the obtained A(a,b).

4. A method for detecting surface defects of NdFeB magnets according to claim 3, characterized in that: The step of calculating the texture feature parameters calculates the energy feature and contrast feature of the surface image of the NdFeB magnet according to the obtained A(a, b), specifically including: Energy feature calculation: Calculate the energy feature according to the energy calculation formula, as shown in formula (4): (4) For the normalized gray-level co-occurrence matrix A, use two layers of nested loops to traverse each element A(a, b) in the matrix; calculate the square of each element A(a, b) 2 , and accumulated into a variable Energy, the final value of the variable Energy is the energy characteristic of the surface image of the NdFeB magnet; Contrast feature calculation: The contrast feature is calculated according to the contrast calculation formula, as shown in formula (5): (5) Also use a nested loop to traverse the gray-level co-occurrence matrix A. For each element A(a,b), calculate (ab) 2 A(a,b) is accumulated into a variable Contrast to obtain the contrast characteristics of the surface image of the NdFeB magnet.

5. A method for detecting surface defects of NdFeB magnets according to claim 1, characterized in that: In step S40, a surface defect detection model for NdFeB magnets based on deep learning is constructed and trained. The steps of constructing and training the model include: Dataset preparation: Obtain existing surface defect image data of different types of NdFeB magnets, divide them into training set, validation set and test set in a ratio of 70%:15%:15%, and annotate the corresponding defect types in the training set image data for the model to learn the surface defect characteristics of different types of NdFeB magnets; Determine the loss function and optimizer: Use binary cross entropy as the loss function, use the Adam optimization algorithm as the optimizer, adaptively adjust the learning rate and dynamically update the model parameters. The initial learning rate is set to 0.001 and is adjusted according to the number of training rounds. Model construction: The entire network model includes input layer, convolution layer, pooling layer, residual connection layer, fully connected layer and output layer; the input of the input layer is the training set with the corresponding defect type marked in the image data; ReLU is used as the activation function in the convolution layer; the pooling layer is set after each convolution layer, using the maximum pooling method; the residual connection layer is set after the last two convolution layers and before the pooling layer, between the convolution layer and the pooling layer; the fully connected layer is set after the pooling layer, and the feature map output by the pooling layer is flattened and converted into a one-dimensional vector form, using ReLU As the activation function; the output layer is set at the last layer of the entire network model. According to the corresponding number of surface defect categories of NdFeB magnets, the probability distribution of each defect category is output after Softmax processing. Each value corresponds to the confidence of the defect category. The confidence threshold is set to 0.

5. When the confidence is less than 0.5, the output is defect-free. When the confidence is greater than or equal to 0.5, the output is defective and the defect category is output at the same time. The defect category is the defect category with the highest probability value in the probability distribution of each defect category output; the confidence threshold is dynamically adjusted according to the output result; Model training and verification: After the model is built, set the model parameters, use the divided training set as input to train the model, and use the divided verification set to verify the trained model after each training round; Model evaluation: When overfitting occurs, stop model training and validation operations, and use the divided test set to evaluate the model; Model optimization: Adjust model parameters and retrain according to model evaluation results until the optimal model parameter combination is obtained and the corresponding model version is determined.

6. A method for detecting surface defects of NdFeB magnets according to claim 5, characterized in that: The categories of defects output in the model building step include cracks, scratches, pits and holes. Different defect types correspond to different texture features extracted based on the grayscale co-occurrence matrix. The model determines the defect type existing in the input image by learning the features of different surface defect types of NdFeB magnets.

7. A surface defect detection system for NdFeB magnets, characterized in that: The surface defect detection system of NdFeB magnets comprises: Platform construction and data acquisition module: used to build a closed dark box image acquisition platform and set up a ring-shaped uniform light source, an industrial camera and a stage in it. After placing the NdFeB magnet on the stage, the stage is controlled to move along the set path, and the industrial camera is triggered at each acquisition point to capture the surface image of the magnet to obtain the surface image data of the NdFeB magnet; NdFeB magnet surface image data preprocessing module: used for preprocessing the obtained NdFeB magnet surface image data; NdFeB magnet surface image data feature extraction module: used to extract NdFeB magnet surface image features based on gray level co-occurrence matrix after data preprocessing; NdFeB magnet surface defect detection model training and application module: used to build and train a NdFeB magnet surface defect detection model based on deep learning after feature extraction is completed. After training, NdFeB magnet surface defect detection is performed and the detection results are output; Before the industrial camera in the platform construction and data acquisition module takes an image of the magnet surface, the focal length and aperture of the camera are automatically adjusted according to the clarity of the presented image, and the moving path of the stage and the collection points of the industrial camera are set according to the size specifications of the NdFeB magnet; in addition, the surface image of the NdFeB magnet taken by the industrial camera is a lossless image with a resolution of 2k, and multiple frames of images are taken for different areas of the surface of the NdFeB magnet, including the top surface, bottom surface and side surface of the NdFeB magnet; The NdFeB magnet surface defect detection model based on deep learning is constructed in the NdFeB magnet surface defect detection model training and application module, and adopts an improved convolutional neural network model. By adding residual links in the network model structure, the convergence speed of model training is improved; after the training is completed, the surface defect detection of the NdFeB magnet is carried out, and the output detection results are defective and non-defective; when the output result is defective, the detected defect category is output at the same time, and the position where the defect occurs is accurately marked in the image where the defect is detected.

8. A surface defect detection device for NdFeB magnets, characterized in that: The NdFeB magnet surface defect detection device comprises: A memory, a processor, and a NdFeB magnet surface defect detection program stored in the memory and executable on the processor, wherein the NdFeB magnet surface defect detection program, when executed by the processor, implements a NdFeB magnet surface defect detection method as described in any one of claims 1 to 6.

9. A computer program product, characterized in that The computer program product includes a NdFeB magnet surface defect detection program, and when the NdFeB magnet surface defect detection program is executed by a processor, a NdFeB magnet surface defect detection method as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Surface defect identification method for strong magnetic neodymium-iron-boron magnet

    CN117078688A

  • Neodymium-iron-boron magnet surface treatment data management system

    CN117274408A

  • System and method for detecting defects of neodymium iron boron blank product

    CN118583876A

  • Automated optical inspection method using deep learning and apparatus, computer program for performing the method, computer-readable storage medium storing the computer program,and deep learning system thereof

    US20190197679A1

Cited By

  • A method and system for detecting edge collapse of a neodymium iron boron magnetic steel sheet based on polarized light

    CN122597412A

  • A method and system for detecting edge collapse of a neodymium iron boron magnetic steel sheet based on polarized light

    CN122597412B