Defect detection method and device based on machine learning and electronic equipment

By acquiring data from different lighting conditions and angles, combined with image trimming technology, the problem of few training samples and image distortion in AI defect detection is solved, improving detection accuracy and cost-effectiveness.

CN118822979AActive Publication Date: 2024-10-22SUZHOU WEIJING VISION TECHNOLOGY CO LTD

Patent Information

Application Number
CN202410875362.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-02
Publication Date
2024-10-22
Estimated Expiration
2044-07-02

AI Technical Summary

Technical Problem

Existing AI defect detection methods based on deep learning algorithms have problems with few training samples and image distortion in industrial products, resulting in low detection accuracy.

Method used

By obtaining data on industrial products under different lighting conditions and different angles, training samples are added, and the target square template is used for image modification, including image cropping and black pixel filling, to avoid image distortion caused by direct scaling and improve model detection accuracy.

Benefits of technology

It significantly improves the accuracy of defect detection, enhances the training accuracy and application effect of the model, reduces the pressure on the graphics card, and controls the production cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118822979A_ABST
    Figure CN118822979A_ABST
Patent Text Reader

Abstract

The invention provides a defect detection method and device based on machine learning and electronic equipment, and relates to the field of machine learning. The method comprises the following steps: acquiring and preprocessing an industrial product surface normal image and a surface defect image to obtain an industrial product surface image data set; wherein the preprocessing process is to carry out image finishing on an obtained image according to a target square template, and the image finishing comprises image cutting and black pixel supplementing; according to the surface image data set, a defect detection model based on machine learning is trained, the model is a convolutional neural network model, and the architecture of the model comprises a convolutional layer, an activation function and a plurality of pooling layers; industrial product surface images shot in real time are received and preprocessed, and to-be-detected surface images are obtained; and inputting the to-be-detected surface image into the defect detection model based on machine learning, and outputting a defect detection result. According to the invention, limited expansion is carried out on industrial product sample data, and the model detection accuracy is improved by adopting a pixel size limiting mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine learning, and in particular to a defect detection method, device and electronic equipment based on machine learning. Background Art

[0002] Deep learning algorithms have made great breakthroughs in the field of image recognition. Deep learning algorithms represented by convolutional neural networks have achieved excellent results in tasks such as image classification, object detection, and image segmentation. Through multi-layer convolution and pooling operations, convolutional neural networks can effectively extract the characteristic expression of images and realize automatic understanding and recognition of image content. For example, in terms of face recognition and object detection, deep learning algorithms have been able to surpass human levels and provide more convenient and safe technical support for society.

[0003] As a key technology of intelligent manufacturing, AI defect detection is leading industrial production towards the direction of intelligent manufacturing and becoming a new trend of quality control in the intelligent era. At present, machine vision defect technology based on deep learning algorithms is widely used in the quality inspection process in industrial production. The existing AI defect detection methods based on deep learning algorithms have problems with few training samples and distorted images when performing defect detection on industrial products. Specifically, there are few industrial products with defects in production or the identification is difficult, and they cannot be obtained in large quantities, resulting in few training samples. Secondly, based on the different shapes of industrial products, different shooting angles, and different product pictures taken, the model is trained on the graphics card. The product pictures are first scaled to obtain training samples in a standard square template size. The training samples enter the graphics processor and are recognized by the square calculation matrix. Since the picture adopts the scaling form to obtain the target shape, there is image distortion when it is applied, which leads to the low accuracy of the model in subsequent defect detection applications. Summary of the invention

[0004] The purpose of the present invention is to provide a defect detection method, device and electronic equipment based on machine learning, aiming to solve the problem of poor accuracy when performing machine learning on small sample data in industrial production. On the one hand, by acquiring data of industrial products under different lighting conditions and different angles, the training samples are increased; on the other hand, the target shape image is not directly acquired by scaling, which effectively avoids image distortion and improves the model detection accuracy.

[0005] To achieve the above object, the present invention proposes the following technical solutions:

[0006] First, a defect detection method based on machine learning is proposed, comprising the following steps:

[0007] Acquire normal images and defective images of industrial product surfaces and perform preprocessing to obtain an industrial product surface image dataset; wherein the preprocessing process is to perform image trimming on the acquired images according to a target square template, and the image trimming includes image cropping and black pixel filling;

[0008] According to the industrial product surface image dataset, a defect detection model based on machine learning is trained, wherein the defect detection model based on machine learning is a convolutional neural network model, and its architecture includes a convolutional layer, an activation function, and a plurality of pooling layers;

[0009] Receiving a surface image of an industrial product taken in real time, preprocessing the surface image of the industrial product, and obtaining a surface image to be detected;

[0010] The surface image to be inspected is input into the defect detection model based on machine learning, and the defect detection result is output.

[0011] Furthermore, the process of obtaining the surface defect image of the industrial product is as follows:

[0012] Acquire an industrial product surface image, and use a target detection algorithm to identify defects in the industrial product surface image, wherein the industrial product surface image includes industrial product surface images of the same industrial product under different lighting conditions;

[0013] For any defect identified by the target detection algorithm, a target classification algorithm is used to classify the defect and add a class label;

[0014] Among them, the target detection algorithm identifies defects in the surface image of the industrial product, including determining the number and location of the defects, and the identification process is: each surface image of the industrial product under different lighting conditions is filtered by an image filtering algorithm, binarized by threshold filtering, and denoised by a morphological transformation method in turn to obtain the defects of the industrial product under each lighting condition; the industrial product image under each lighting condition is sheared to obtain several defective images containing at least one defect; several defective images are correspondingly spliced ​​under the same pixel conditions to obtain an industrial product defective image; for the industrial product defective image, a standard template frame is used to identify and select each defect.

[0015] Furthermore, the process of preprocessing the normal image of the industrial product surface and the defective image of the industrial product surface is as follows:

[0016] According to the pixel size of the image to be processed, selecting one of the first square template and the second square template as the target square template; wherein the pixel size of the first square template is greater than the pixel size of the second square template;

[0017] The image is placed within the pixel size of the target square template, the portion of the image that exceeds the pixel size of the target square template is cropped, and the portion of the image that is missing within the pixel size of the target square template is filled with black pixels until the pixel size of the image is equal to the pixel size of the target square template.

[0018] Furthermore, the process of receiving the real-time captured surface image of the industrial product and preprocessing the surface image of the industrial product to obtain the surface image to be detected is:

[0019] The surface image of the industrial product is subjected to filtering processing, threshold filtering binarization processing and morphological transformation method noise reduction processing in sequence by using an image filtering algorithm to obtain a processed image; wherein, for any industrial product, at least the surface image of the industrial product under two lighting conditions is photographed in real time;

[0020] According to the pixel size of the surface image to be detected required by the model, the processed image is image trimmed in pixel size.

[0021] Furthermore, the process of identifying and selecting each defect using a standard template frame is as follows:

[0022] For any two adjacent defects, calculate the minimum distance L between the two defects;

[0023] Determine the relationship between the minimum distance and the first distance threshold L1 and the second distance threshold L2, and determine the defect selection method according to the relationship; wherein L1>L2;

[0024] When L≥L1, the standard template frame is used to identify and select one of the defects;

[0025] When L1>L≥L2, two defects are respectively framed by an irregular curve, and the two defects after framed do not overlap;

[0026] When L2>L, the standard template frame clustering frame is used to select the two defects as one defect class.

[0027] Further, when the target square template is the first square template, the preprocessed image is reduced to a pixel size of the second square template.

[0028] In the second aspect, a defect detection device based on machine learning is proposed, comprising:

[0029] An acquisition module is used to acquire normal images and defective images of industrial product surfaces and perform preprocessing to obtain an industrial product surface image dataset; wherein the preprocessing process is to perform image trimming on the acquired images according to a target square template, and the image trimming includes image cropping and black pixel filling;

[0030] A training module, used to train a defect detection model based on machine learning according to the industrial product surface image dataset, wherein the defect detection model based on machine learning is a convolutional neural network model, and its architecture includes a convolutional layer, an activation function, and a plurality of pooling layers;

[0031] A receiving module, used for receiving a surface image of an industrial product taken in real time, preprocessing the surface image of the industrial product, and obtaining a surface image to be detected;

[0032] The defect detection module is used to input the surface image to be detected into the defect detection model based on machine learning and output the defect detection result.

[0033] Furthermore, the execution unit of the acquisition module for acquiring the surface defect image of the industrial product includes:

[0034] An acquisition and recognition unit is used to acquire an industrial product surface image and use a target detection algorithm to identify defects in the industrial product surface image, wherein the industrial product surface image includes industrial product surface images of the same industrial product under different lighting conditions;

[0035] A defect classification unit, for classifying any defect identified by the target detection algorithm using a target classification algorithm and attaching a class label to the defect;

[0036] Among them, the acquisition and recognition unit adopts the target detection algorithm to identify the defects in the surface image of the industrial product, including determining the number of defects and the location of the defects. The recognition process is: each surface image of the industrial product under different lighting conditions is filtered by an image filtering algorithm, binarized by threshold filtering, and denoised by a morphological transformation method to obtain the defects of the industrial product under each lighting condition; the industrial product image under each lighting condition is sheared to obtain several defective pictures containing at least one defect; several defective pictures are correspondingly spliced ​​under the same pixel conditions to obtain an industrial product defective image; for the industrial product defective image, a standard template frame is used to identify and select each defect.

[0037] Furthermore, the process of using the standard template frame to identify and select each defect in the acquisition and identification unit is as follows:

[0038] For any two adjacent defects, calculate the minimum distance L between the two defects;

[0039] Determine the relationship between the minimum distance and the first distance threshold L1 and the second distance threshold L2, and determine the defect selection method according to the relationship; wherein L1>L2;

[0040] When L≥L1, the standard template frame is used to identify and select one of the defects;

[0041] When L1>L≥L2, two defects are respectively framed by an irregular curve, and the two defects after framed do not overlap;

[0042] When L2>L, the standard template frame clustering frame is used to select the two defects as one defect class.

[0043] In a third aspect, an electronic device is proposed, comprising a computer program, wherein the computer program is stored in a computer-readable storage medium; when a processor of the electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of the above method.

[0044] It can be seen from the above technical solutions that the technical solutions of the present invention have the following beneficial effects:

[0045] The present invention discloses a defect detection method, device and electronic device based on machine learning, and the method includes: obtaining a normal image of an industrial product surface and a defect image of an industrial product surface and performing preprocessing to obtain an industrial product surface image data set; wherein the preprocessing process is to perform image trimming on the acquired image according to a target square template, including image cropping and black pixel filling, and the image modification using this scheme can effectively ensure the morphological characteristics of the defect, and the image of the target square template size will not be distorted due to size scaling; according to the industrial product surface image data set, training a defect detection model based on machine learning, the model is a convolutional neural network model, and its architecture includes a convolutional layer, an activation function and a plurality of pooling layers; receiving a real-time captured industrial product surface image and performing preprocessing to obtain a surface image to be detected; inputting the surface image to be detected into a defect detection model based on machine learning, and outputting a defect detection result. The present invention increases the defect image sample data by limited expansion of the industrial product image, and at the same time uses a pixel size limit method to ensure the authenticity of the training sample, thereby improving the accuracy of defect detection from two aspects: improving the accuracy of the training model and providing more product images.

[0046] Specifically, the defect sample data is increased by obtaining pictures of industrial products under different lighting conditions for processing to detect more defects that cannot be detected under white light conditions. On the other hand, defect samples are increased by separately cropping and identifying different defects, thereby increasing training samples during training. For image size, the target square template detected by the model is used to limit the size of the sample image and the image to be detected from the pixel size, and the target size image is obtained by cropping or filling black pixels to avoid the phenomenon of image distortion caused by direct size scaling; using more accurate model training samples and more realistic defect images can significantly improve the accuracy of defect detection of industrial products by the present invention; at the same time, since the image is processed into a regular square target size at the beginning of training, in actual production, the length and width of the target size image can be directly reduced proportionally without affecting the image feature recognition, so the pressure on the graphics card can be reduced by inputting small-size images that truly reflect the defect features, and the enterprise does not need to purchase expensive graphics cards with high computing power, thereby achieving enterprise production cost control.

[0047] It should be appreciated that all combinations of the foregoing concepts, as well as additional concepts described in greater detail below, may be considered to be part of the inventive subject matter of the present disclosure, provided such concepts are not mutually inconsistent.

[0048] The foregoing and other aspects, embodiments and features of the present invention can be more fully understood from the following description in conjunction with the accompanying drawings. Other additional aspects of the present invention, such as the features and / or beneficial effects of the exemplary embodiments, will be apparent from the following description or learned from the practice of the specific embodiments according to the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] The accompanying drawings are not intended to be drawn to scale. In the accompanying drawings, each identical or nearly identical component shown in various figures may be represented by the same reference numeral. For clarity, not every component is labeled in each figure. Embodiments of various aspects of the present invention will now be described by way of example and with reference to the accompanying drawings, in which:

[0050] Figure 1 This is a flow chart of the defect detection method based on machine learning disclosed in this embodiment;

[0051] Figure 2 This is a flow chart for obtaining an image of a surface defect of an industrial product disclosed in this embodiment;

[0052] Figure 3 The flowchart for identifying and selecting each defect using a standard template frame disclosed in this embodiment;

[0053] Figure 4 This is a flow chart of preprocessing normal and defective images of industrial product surfaces disclosed in this embodiment;

[0054] Figure 5 The flowchart of obtaining the image of the surface to be detected disclosed in this embodiment;

[0055] Figure 6 is a structural block diagram of a defect detection device based on machine learning disclosed in this embodiment;

[0056] Figure 7 A structural block diagram of an electronic device disclosed in this embodiment. DETAILED DESCRIPTION

[0057] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment 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. Unless otherwise defined, the technical terms or scientific terms used herein should be the common meaning understood by people with general skills in the field to which the present invention belongs.

[0058] The words "first", "second" and similar words used in the patent application specification and claims of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, unless the context clearly indicates otherwise, the singular form of "a", "an" or "the" and other similar words do not indicate a quantitative limitation, but indicate the existence of at least one. "Include" or "comprises" and other similar words mean that the elements or objects appearing before "include" or "comprises" include the features, wholes, steps, operations, elements and / or components listed after "include" or "comprises", and do not exclude the existence or addition of one or more other features, wholes, steps, operations, elements, components and / or their collections.

[0059] When performing defect detection on industrial products based on the existing AI defect detection method based on deep learning algorithm, there are problems such as few training samples and distorted images, resulting in low detection accuracy of the defect detection model finally trained. The present invention aims to address the above problems and propose a defect detection method, device and electronic device based on machine learning, which improves the accuracy of the trained detection model by increasing training samples and improving image accuracy.

[0060] The following is a further detailed introduction to the machine learning-based defect detection method, device and electronic device disclosed in the present invention in conjunction with the specific embodiments shown in the accompanying drawings.

[0061] Combination Figure 1As shown, the defect detection method based on machine learning disclosed in the embodiment includes the following steps:

[0062] Step S102, acquiring normal images of industrial product surfaces and defective images of industrial product surfaces and performing preprocessing to obtain an industrial product surface image dataset; wherein the preprocessing process is to perform image trimming on the acquired images according to a target square template, and the image trimming includes image cropping and black pixel filling;

[0063] The industrial product surface image dataset is used as a sample database for model training. The purpose of preprocessing the acquired normal images and surface defect images of industrial products is to retain the learning degree to the greatest extent. At the same time, in order to solve the problem of image distortion caused by the current defect detection model directly scaling the image to obtain the target size to meet the application requirements of the image processor, the scheme uses the long truncation and short padding method to trim the image to be processed to the target size to solve the image distortion problem sent to the image processor.

[0064] Specifically, the process of obtaining the surface defect image of the industrial product is as follows: Figure 2 The steps shown include: step S202, obtaining an industrial product surface image, and using a target detection algorithm to identify defects in the industrial product surface image, wherein the industrial product surface image includes industrial product surface images of the same industrial product under different lighting conditions; because the causes of defects are different, some defects cannot be completely detected under white light conditions, so the scheme detects various defects by taking images of industrial products under different lighting conditions; different lighting conditions such as white light, binary stripe light, color light, corrugated light, Gray code structured light, etc.

[0065] Among them, the target detection algorithm identifies the defects in the surface image of the industrial product, including determining the number and location of the defects. The identification process is: the surface images of the industrial products under different lighting conditions are filtered by the image filtering algorithm, binarized by threshold filtering, and denoised by the morphological transformation method in turn to obtain the defects of the industrial products under various lighting conditions; wherein, the image filtering algorithm performs filtering by using a high-pass filtering algorithm to perform filtering to clarify the location of the defects in the image, and the main purpose of using the morphological transformation method for denoising is to remove the background noise of the image; the surface images of the industrial products under various lighting conditions after the shearing process are The industrial product image is obtained to obtain several defect images containing at least one defect; several defect images are correspondingly spliced ​​under the same pixel conditions to obtain an industrial product defect image, that is, the industrial product image is segmented according to the defect positions detected under different lighting conditions and then assembled on the same image to summarize the defects; for the industrial product defect image, a standard template frame is used to identify and select each defect to further increase the defect sample data; step S204, for any defect identified by the target detection algorithm, a target classification algorithm is used to classify the defect and add a class label so that the common features of various defects can be accurately learned during model training. Optionally, when the different lighting conditions selected include the lighting conditions of Gray code structured light, image decoding is performed before filtering the captured image.

[0066] In this embodiment, in order to facilitate the acquisition of defect samples and to more accurately classify defects, the above process of using a standard template frame to identify and select each defect is implemented as follows: Figure 3 As shown, it includes: step S302, for any two adjacent defects, calculating the minimum distance L between the two defects; step S304, judging the relationship between the minimum distance and the first distance threshold L1 and the second distance threshold L2, and determining the selection method of the defect according to the relationship; wherein, L1>L2; when L≥L1, using the standard template frame to identify and select one of the defects respectively; of course, if there is only one defect in the identified image, directly use the standard template frame to select it after identification; when L1>L≥L2, using an irregular curve to select the two defects respectively, and the two defects after selection do not overlap; when L2>L, using the standard template frame to cluster and select the two defects as one defect class.

[0067] Step S104, training a defect detection model based on machine learning according to the industrial product surface image dataset, wherein the defect detection model based on machine learning is a convolutional neural network model, and its architecture includes a convolutional layer, an activation function, and a plurality of pooling layers;

[0068] Step S106, receiving the surface image of the industrial product taken in real time, preprocessing the surface image of the industrial product, and obtaining the surface image to be detected;

[0069] The process of preprocessing industrial product surface images is different from the process of building industrial product surface image datasets. This preprocessing aims to obtain better surface images to be tested for defect identification and sizes that meet model requirements, thereby improving model detection speed. Figure 4 As shown, the process of preprocessing the surface image of the industrial product to obtain the surface image to be detected includes: step S402, filtering the surface image of the industrial product in turn using an image filtering algorithm, threshold filtering binarization processing and morphological transformation method noise reduction processing to obtain a processed image; wherein, for any industrial product, at least the surface image of the industrial product under two lighting conditions is photographed in real time; step S404, according to the pixel size of the surface image to be detected required by the model, the pixel size of the processed image is trimmed; the image modification process adopts the same process as the process of obtaining the industrial product surface image data set, mainly performing image cropping and black pixel filling.

[0070] Step S108, inputting the surface image to be inspected into the defect detection model based on machine learning, and outputting the defect detection result.

[0071] As an optional implementation, Figure 5 As shown, the process of preprocessing the normal image and the defective image of the industrial product surface includes: step S502, according to the pixel size of the image to be processed, selecting one of the first square template and the second square template as the target square template; wherein the pixel size of the first square template is larger than the pixel size of the second square template, such as the pixel size of the first square template is 1024×1024, and the pixel size of the second square template is 512×512; step S504, placing the image within the pixel size of the target square template, cropping the portion of the image that exceeds the pixel size of the target square template, and filling black pixels for the portion of the image that is missing within the pixel size of the target square template, until the pixel size of the image is equal to the pixel size of the target square template.

[0072] In order to retain the learning degree of defects, a first square template with a large pixel size is used for defects with larger areas to retain the defects to the greatest extent. Therefore, in order to facilitate model training, when the target square template is the first square template, the preprocessed image is reduced to the pixel size of the second square template. Optionally, when the defect size exceeds the largest square template, a square selection box is directly constructed around the edge of the defect, and the square selection box is reduced to the pixel size of the second square template for model training, that is, the pixel size required for training; in this way, the solution can fully retain the morphological characteristics of the defect without changing the authenticity of the image.

[0073] Since the image is processed into a regular square target size at the beginning of training, in actual production, the length and width of the target-sized image can be directly reduced proportionally without affecting the image feature recognition. Therefore, by inputting small-sized images that truly reflect defect features, the graphics card pressure during model training and application can be reduced. Enterprises do not need to purchase expensive graphics cards with high computing power to quickly identify defects, thereby controlling their production costs and time costs.

[0074] At the same time, when the machine learning-based defect detection model outputs the defect detection results, it selects a square template that can completely surround the defect according to the pixel size of the defect to mark the defect location and indicate the defect size.

[0075] As an optional implementation, when applying a machine learning-based defect detection model to identify defects, the defects are first screened, and defects that do not affect the application of industrial products are screened out, and only defects that affect the application of industrial products are marked; the specific screening method is: all defects identified by the model are marked with square templates, and the pixel size of the defects in each square template is counted; the ratio of the pixel size of the defects in each square template to the pixel size of the standard defect template is calculated; the size of the ratio and the standard defect threshold is determined, and the defect is marked when the ratio is not less than the standard defect threshold; wherein the standard defect threshold is the ratio of the pixel size of the smallest defect that affects the application of industrial products to the pixel size of the standard defect template, such as 0.2. The above method can effectively filter smaller defects and ensure product yield in industrial product quality supervision.

[0076] The defect detection method based on machine learning disclosed in the above-mentioned embodiment, on the one hand, obtains data of industrial products under different lighting conditions and different angles, increases defect training samples after preprocessing and improves the defect detection rate; on the other hand, it adopts the method of cutting off the long and compensating the short to realize the size of the target shape image used by the model, avoids directly obtaining the target shape image by scaling, and avoids photo distortion caused by image scaling. It not only improves the training accuracy of the model from the time of model training, but also can output more accurate detection results due to the input of more realistic images to be detected.

[0077] In an embodiment of the present application, an electronic device is also provided, including a computer program, wherein the computer program is stored in a computer-readable storage medium; when a processor of the electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of the above-mentioned defect detection method based on machine learning. Taking an electronic device running on a computer as an example, Figure 7 As shown, the electronic device may include one or more (only one is shown in the figure) processors (the processor may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory for storing data, and a transmission device for communication functions. A person skilled in the art can understand that Figure 7 The structure shown is for illustration only and does not limit the structure of the above-mentioned electronic device.

[0078] The above program can be run in the processor, or it can be stored in the memory, that is, in the computer-readable medium, which includes permanent and non-permanent, removable and non-removable media. Information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include temporary computer-readable media, such as modulated data signals and carrier waves. These computer programs can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are performed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in a block or multiple blocks may be implemented by different modules corresponding to different method steps.

[0079] In this embodiment, such a device or system is provided, which can be called a defect detection device based on machine learning, such as Figure 6As shown, it includes: an acquisition module, which is used to acquire normal images of industrial product surfaces and defective images of industrial product surfaces and perform preprocessing to obtain an industrial product surface image data set; wherein the preprocessing process is to perform image trimming on the acquired image according to a target square template, and the image trimming includes image cropping and black pixel filling; a training module, which is used to train a defect detection model based on machine learning according to the industrial product surface image data set, and the defect detection model based on machine learning is a convolutional neural network model, and its architecture includes a convolutional layer, an activation function and multiple pooling layers; a receiving module, which is used to receive an industrial product surface image taken in real time, preprocess the industrial product surface image, and obtain a surface image to be detected; a defect detection module, which is used to input the surface image to be detected into the defect detection model based on machine learning, and output a defect detection result.

[0080] The steps of the device for implementing the machine learning-based defect detection method disclosed in the above embodiment have been described and will not be repeated here.

[0081] For example, the acquisition module acquires the execution unit of the surface defect image of the industrial product, including: an acquisition and recognition unit, which is used to acquire the surface image of the industrial product and use the target detection algorithm to identify defects in the surface image of the industrial product, wherein the surface image of the industrial product includes the surface images of the same industrial product under different lighting conditions; a defect classification unit, which is used to classify any defect identified by the target detection algorithm and attach a class label to the defect by using the target classification algorithm; wherein the acquisition and recognition unit uses the target detection algorithm to identify defects in the surface image of the industrial product, including determining the number and location of the defects, and the recognition process is: each of the surface images of the industrial product under different lighting conditions is filtered by an image filtering algorithm, binarized by threshold filtering, and denoised by a morphological transformation method in turn to obtain the defects of the industrial product under each lighting condition; the industrial product image under each lighting condition is sheared to obtain a plurality of defect images containing at least one defect; a plurality of defect images are correspondingly spliced ​​under the same pixel conditions to obtain an industrial product defect image; for the industrial product defect image, a standard template frame is used to identify and select each defect.

[0082] For another example, the process of using the standard template frame to identify and select each defect in the acquisition and identification unit is: for any two adjacent defects, calculate the minimum distance L between the two defects; determine the relationship between the minimum distance and the first distance threshold L1 and the second distance threshold L2, and determine the selection method of the defect based on the relationship; wherein, L1>L2; when L≥L1, use the standard template frame to identify and select one defect respectively; when L1>L≥L2, use an irregular curve to select two defects respectively, and the two defects after selection do not overlap; when L2>L, use the standard template frame to cluster and select the two defects as one defect class.

[0083] For another example, the execution unit of the acquisition module for preprocessing the normal image and the defective image of the industrial product surface includes: a selection unit, which is used to select one of the first square template and the second square template as the target square template according to the pixel size of the image to be processed; wherein the pixel size of the first square template is larger than the pixel size of the second square template; a first image retouching unit, which is used to place the image within the pixel size of the target square template, crop the portion of the image that exceeds the pixel size of the target square template, and fill in black pixels for the portion of the image that is missing within the pixel size of the target square template, until the pixel size of the image is equal to the pixel size of the target square template. Furthermore, when the selection unit selects the first square template as the target square template, the image retouching unit is also used to reduce the preprocessed image to the pixel size of the second square template to meet the image size requirement of model training.

[0084] For another example, the receiving module receives the surface image of an industrial product taken in real time, pre-processes the surface image of the industrial product, and obtains an execution unit for the surface image to be detected, including: an image processing unit, which is used to filter the surface image of the industrial product using an image filtering algorithm, perform threshold filtering binarization processing, and morphological transformation method noise reduction processing in sequence to obtain a processed image; wherein, for any industrial product, at least the surface image of the industrial product under two lighting conditions is taken in real time; a second image retouching unit, which is used to perform pixel size image retouching on the processed image according to the pixel size of the surface image to be detected required by the model.

[0085] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. The computer program is used to execute the above method.

[0086] The defect detection method, device and electronic device based on machine learning disclosed in the present invention increase defect sample data by adjusting different lighting conditions of industrial products and segmenting defects, and ensure the authenticity of the defect sample data by limiting the pixel size, so as to obtain an industrial product surface image data set that can accurately reflect the defects of industrial products; and then use the limited but accurate defect sample data in the data set to train a more accurate defect detection model, and finally achieve an improvement in the overall detection rate of defect detection; compared with the defect detection rate of 60%-70% in the prior art, this solution can increase the defect detection rate to more than 80%, and while significantly improving the defect detection rate, the solution can also stabilize the yield of industrial products and control the production cost of the enterprise.

[0087] Avoid the phenomenon of image distortion caused by direct size scaling; use of more accurate model training samples and more realistic defect images can significantly improve the accuracy of defect detection of industrial products by the present invention without increasing the application cost.

[0088] Although the present invention has been disclosed as above with preferred embodiments, it is not intended to limit the present invention. A person with ordinary knowledge in the technical field to which the present invention belongs may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be determined by the definition of the claims.

Claims

1. A defect detection method based on machine learning, characterized in that: The steps include: Acquire normal images and defective images of industrial product surfaces and perform preprocessing to obtain a dataset of industrial product surface images; wherein the preprocessing process is to perform image trimming on the acquired images according to a target square template, and the image trimming includes image cropping and black pixel filling; According to the industrial product surface image dataset, a defect detection model based on machine learning is trained, wherein the defect detection model based on machine learning is a convolutional neural network model, and its architecture includes a convolutional layer, an activation function, and a plurality of pooling layers; Receiving a surface image of an industrial product taken in real time, preprocessing the surface image of the industrial product, and obtaining a surface image to be detected; The surface image to be inspected is input into the defect detection model based on machine learning, and the defect detection result is output.

2. The defect detection method based on machine learning according to claim 1, characterized in that: The process of obtaining the surface defect image of the industrial product is as follows: Acquire an industrial product surface image, and use a target detection algorithm to identify defects in the industrial product surface image, wherein the industrial product surface image includes industrial product surface images of the same industrial product under different lighting conditions; For any defect identified by the target detection algorithm, a target classification algorithm is used to classify the defect and add a class label; Among them, the target detection algorithm identifies defects in the surface image of the industrial product, including determining the number and location of the defects, and the identification process is: each surface image of the industrial product under different lighting conditions is filtered by an image filtering algorithm, binarized by threshold filtering, and denoised by a morphological transformation method in turn to obtain the defects of the industrial product under each lighting condition; the industrial product image under each lighting condition is sheared to obtain several defective images containing at least one defect; several defective images are correspondingly spliced ​​under the same pixel conditions to obtain an industrial product defective image; for the industrial product defective image, a standard template frame is used to identify and select each defect.

3. The defect detection method based on machine learning according to claim 1, characterized in that: The process of preprocessing the normal image of the industrial product surface and the defective image of the industrial product surface is as follows: According to the pixel size of the image to be processed, selecting one of the first square template and the second square template as the target square template; wherein the pixel size of the first square template is greater than the pixel size of the second square template; The image is placed within the pixel size of the target square template, the portion of the image that exceeds the pixel size of the target square template is cropped, and the portion of the image that is missing within the pixel size of the target square template is filled with black pixels until the pixel size of the image is equal to the pixel size of the target square template.

4. The defect detection method based on machine learning according to claim 1, characterized in that: The process of receiving the real-time captured surface image of the industrial product, preprocessing the surface image of the industrial product, and obtaining the surface image to be detected is as follows: The surface image of the industrial product is subjected to filtering processing, threshold filtering binarization processing and morphological transformation method noise reduction processing in sequence by using an image filtering algorithm to obtain a processed image; wherein, for any industrial product, at least the surface image of the industrial product under two lighting conditions is photographed in real time; According to the pixel size of the surface image to be detected required by the model, the processed image is image trimmed in pixel size.

5. The defect detection method based on machine learning according to claim 2, characterized in that: The process of using the standard template frame to identify and select each defect is as follows: For any two adjacent defects, calculate the minimum distance L between the two defects; Determine the relationship between the minimum distance and the first distance threshold L1 and the second distance threshold L2, and determine the defect selection method according to the relationship; wherein L1>L2; When L≥L1, the standard template frame is used to identify and select one of the defects; When L1>L≥L2, two defects are respectively framed by an irregular curve, and the two defects after framed do not overlap; When L2>L, the standard template frame clustering frame is used to select the two defects as one defect class.

6. The defect detection method based on machine learning according to claim 3, characterized in that: When the target square template is the first square template, the preprocessed image is reduced to a pixel size of the second square template.

7. A defect detection device based on machine learning, characterized in that: include: An acquisition module is used to acquire normal images and defective images of industrial product surfaces and perform preprocessing to obtain an industrial product surface image dataset; wherein the preprocessing process is to perform image trimming on the acquired images according to a target square template, and the image trimming includes image cropping and black pixel filling; A training module, used to train a defect detection model based on machine learning according to the industrial product surface image dataset, wherein the defect detection model based on machine learning is a convolutional neural network model, and its architecture includes a convolutional layer, an activation function, and a plurality of pooling layers; A receiving module, used for receiving a surface image of an industrial product taken in real time, preprocessing the surface image of the industrial product, and obtaining a surface image to be detected; The defect detection module is used to input the surface image to be detected into the defect detection model based on machine learning and output the defect detection result.

8. The defect detection device based on machine learning according to claim 7, characterized in that: The execution unit of the acquisition module acquiring the surface defect image of the industrial product includes: An acquisition and recognition unit is used to acquire an industrial product surface image and use a target detection algorithm to identify defects in the industrial product surface image, wherein the industrial product surface image includes industrial product surface images of the same industrial product under different lighting conditions; A defect classification unit, for classifying any defect identified by the target detection algorithm using a target classification algorithm and attaching a class label to the defect; Among them, the acquisition and recognition unit adopts the target detection algorithm to identify the defects in the surface image of the industrial product, including determining the number of defects and the location of the defects. The recognition process is: each surface image of the industrial product under different lighting conditions is filtered by an image filtering algorithm, binarized by threshold filtering, and denoised by a morphological transformation method to obtain the defects of the industrial product under each lighting condition; the industrial product image under each lighting condition is sheared to obtain several defective pictures containing at least one defect; several defective pictures are correspondingly spliced ​​under the same pixel conditions to obtain an industrial product defective image; for the industrial product defective image, a standard template frame is used to identify and select each defect.

9. The defect detection device based on machine learning according to claim 8, characterized in that: The process of using the standard template frame to identify and select each defect in the acquisition recognition unit is as follows: For any two adjacent defects, calculate the minimum distance L between the two defects; Determine the relationship between the minimum distance and the first distance threshold L1 and the second distance threshold L2, and determine the defect selection method according to the relationship; wherein L1>L2; When L≥L1, the standard template frame is used to identify and select one of the defects; When L1>L≥L2, two defects are respectively framed by an irregular curve, and the two defects after framed do not overlap; When L2>L, the standard template frame clustering frame is used to select the two defects as one defect class.

10. An electronic device, characterized in that: The method comprises a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Magnetic shoe surface defect detection system and method

    CN110599470A

  • Object defect detection method and device

    CN113096130A

  • Surface microdefect detection method and device based on convolutional neural network

    CN114119554A

  • Refined detection method for sawtooth welding defects

    CN114972285A

  • Ceramic substrate appearance defect intelligent identification method based on target detection

    CN115456944A

Cited By

  • Self-supervised structured light illumination super-resolution microscopic image noise reduction

    CN120689236A