Product defect detection method, device, equipment and medium

Through the defect detection model trained based on normal sample images and simulated abnormal sample images, the problem of insufficient accuracy of product defect detection in industrial production environments is solved, and the accurate improvement of industrial product abnormal detection is achieved.

CN120013875APending Publication Date: 2025-05-16NINGBO INST OF TECH ZHEJIANG UNIV ZHEJIANG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510024229.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

The existing technology is difficult to accurately detect product defects in an industrial production environment, and lacks support for defective product data, resulting in insufficient detection accuracy.

Method used

The defect detection model obtained by training based on normal sample images and abnormal sample images obtained based on normal sample images simulation, the defect position is positioned on the product images to be detected. The model includes a matching layer and an analysis layer, which uses machine learning and attention mechanisms to match and transform features to determine defect locations.

Benefits of technology

It improves the accuracy of abnormal detection of industrial products, effectively adapts to the complex and changeable abnormal detection needs in the industrial environment, and improves the accuracy of product defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120013875A_ABST
    Figure CN120013875A_ABST
Patent Text Reader

Abstract

The invention provides a product defect detection method and device, equipment and a medium. The method comprises the following steps: acquiring a to-be-detected product image; inputting the product image into a defect detection model to obtain a result image which is output by the defect detection model and is used for positioning a defect position; wherein the defect detection model is obtained through machine learning training based on a normal sample image and an abnormal sample image obtained through simulation based on the normal sample image, and is used for positioning defects on the product image. According to the product defect detection method, device and equipment and the medium provided by the invention, the model is obtained through training based on the normal sample image and the abnormal sample image obtained through simulation based on the normal sample image, and the defect position of the to-be-detected product image is positioned, so that the precision of industrial product anomaly detection can be improved; and complex and changeable anomaly detection requirements in an industrial environment can be effectively met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of industrial production detection technology, and in particular to a product defect detection method, device, equipment and medium. Background Art

[0002] In the production environment of industrial products, due to the strictness of the production process, a large number of products are above the qualified level. Due to the diversity and complexity of abnormal situations in the production environment, different types of defective products may be produced, but the number of products produced is also very small, so it is difficult to cover all potential abnormal scenarios in the data collection stage for defective products. At this time, the data on defective products is difficult to have a greater reference role, making the existing product defect detection methods lack the support of defective product data, and it is difficult to achieve the accuracy of product defect detection. Summary of the invention

[0003] In view of the problems existing in the prior art, the present invention provides a product defect detection method, device, equipment and medium.

[0004] The present invention provides a product defect detection method, comprising: Acquire an image of a product to be inspected; Inputting the product image into a defect detection model to obtain a result image output by the defect detection model that locates the defect position; The defect detection model is a model obtained through machine learning training based on normal sample images and abnormal sample images simulated based on normal sample images, and is used to locate defects on product images.

[0005] According to a product defect detection method provided by the present invention, the defect detection model includes a matching layer. Accordingly, the product image is input into the defect detection model to obtain a result image output by the defect detection model to locate the defect position, including: The product image is input into a matching layer, which extracts image features of the product image. The image features of the product image are matched with image features of normal sample images in a pre-stored normal sample image set to obtain a first difference area in the product image, wherein a matching degree between features of the first difference area and features of the normal sample image reaches a first judgment value, and the first difference area is used as a defect location.

[0006] According to a product defect detection method provided by the present invention, the defect detection module further includes an analysis layer. Accordingly, the product image is input into a defect detection model to obtain a result image output by the defect detection model to locate the defect position, including: The features of the difference area in the product image are input to the analysis layer, and the analysis layer uses the attention mechanism to perform feature transformation on the multi-dimensional feature channel, and the transformed features are matched with the image features of the normal sample images in the pre-stored normal sample image set, and the second difference area in the product image is obtained from the first difference area in the product image, wherein the matching degree between the features of the second difference area and the features of the normal sample image reaches a second judgment value, and the second difference area is used as the defect position.

[0007] According to a product defect detection method provided by the present invention, an abnormal sample image obtained by simulating a normal sample image includes: Obtaining a foreground mask image according to the normal sample image; the foreground mask image includes a product outline; Obtaining a local abnormality mask image according to the foreground mask image and the random noise image; Obtaining a first fused image according to the local abnormality mask image and the normal sample image, wherein the first fused image indicates that an abnormal point is contained in a product image region; A second fused image is obtained according to the local abnormality mask image, the texture abnormality image and the structural abnormality image, wherein the second fused image represents the position distribution of abnormal points; the texture abnormality image is a texture image in a texture data set, and the structural abnormality image is an image obtained by structurally adjusting the texture abnormality image; A simulated abnormal sample image is obtained according to the first fused image and the second fused image.

[0008] According to a product defect detection method provided by the present invention, obtaining a second fused image according to the local abnormal mask image, the texture abnormal image and the structure abnormal image comprises: Obtaining a texture anomaly fusion image according to the local anomaly mask image and the texture anomaly image; Obtaining a structural abnormality fusion image according to the local abnormality mask image and the structural abnormality image; A preset transparency factor is obtained, and a second fused image is obtained according to the transparency factor, the texture abnormality fused image, and the structure abnormality fused image.

[0009] According to a product defect detection method provided by the present invention, the method further includes building a defect detection model, including: Selecting a first number of normal sample images from the normal sample image set; Performing feature matching on the image features of the first number of normal sample images, the image features of the remaining normal sample images in the normal sample image set, and the image features of each abnormal sample image in the abnormal sample image set obtained by simulation, to obtain a plurality of first matching degrees, and constructing a correspondence between the first judgment value and the normal image features and the abnormal image features based on the first matching degrees; Perform feature transformation on the image features of the remaining normal sample images in the normal sample image set and the image features of each abnormal sample image in the simulated abnormal sample image set on the multi-dimensional feature channel, perform feature matching on the transformed features with the image features of the first number of normal sample images to obtain multiple second matching degrees, and construct a corresponding relationship between the second judgment degree and the normal image features and the abnormal image features based on the second matching degrees.

[0010] The present invention also provides a product defect detection device, comprising: An acquisition module, used for acquiring an image of a product to be inspected; A detection module, used for inputting the product image into a defect detection model to obtain a result image output by the defect detection model and locating the defect position; The defect detection model is a model obtained through machine learning training based on normal sample images and abnormal sample images simulated based on normal sample images, and is used to locate defects on product images.

[0011] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any one of the above-mentioned product defect detection methods is implemented.

[0012] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the computer program implements any of the above-mentioned product defect detection methods.

[0013] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned product defect detection methods.

[0014] The present invention provides a product defect detection method, device, equipment and medium. By training a model based on normal sample images and abnormal sample images simulated based on normal sample images, the defect position of the product image to be inspected is located, which can improve the accuracy of industrial product anomaly detection and effectively adapt to the complex and changeable anomaly detection needs in the industrial environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are 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.

[0016] Figure 1 It is a flow chart of the product defect detection method provided by the present invention.

[0017] Figure 2 It is a schematic diagram of the process of simulating abnormal sample images provided by the present invention.

[0018] Figure 3 It is a structural schematic diagram of the product defect detection device provided by the present invention.

[0019] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0020] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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] Combine the following Figure 1-Figure 4 The product defect detection method, device, equipment and medium of the present invention are described.

[0022] Figure 1 A schematic diagram of a product defect detection method provided by the present invention is shown in FIG. Figure 1 , the method comprises the following steps: Step 11: Obtain the image of the product to be inspected.

[0023] Step 12: Input the product image into the defect detection model to obtain a result image output by the defect detection model that locates the defect position; wherein the defect detection model is a model obtained through machine learning training based on normal sample images and abnormal sample images simulated based on normal sample images, and is used to locate defects on product images.

[0024] In this regard, it should be noted that in the production environment of industrial products, due to the strictness of the production process, a large number of products are above the qualified level. Due to the diversity and complexity of abnormal situations in the production environment, different types of defective products may be produced, but the number of products produced is also very small, so it is difficult to cover all potential abnormal scenarios in the data collection stage for defective products. At this time, the data on defective products is difficult to have a greater reference role, which makes the existing product defect detection methods lack the support of defective product data and it is difficult to achieve the accuracy of product defect detection.

[0025] To this end, the present invention takes enriching the detection data of product defects as the starting point to construct a defect detection model that can accurately detect product defects. The model uses a large number of normal sample images of qualified products and a large number of abnormal sample images of defective products as training data, and is obtained through machine learning training. Since there are very few defective products in industrial products, the present invention simulates abnormal sample images based on normal sample images, so that the abnormal sample images of defective products can be enriched. In other words, a simulated image is obtained based on a normal sample image, and the simulated image can reflect the images of defective products obtained in a large number of potential abnormal scenarios.

[0026] In the present invention, an image of a product to be inspected is obtained, and the image of the product is input into a defect detection model to obtain a result image output by the defect detection model that locates the defect position. Since the defect detection model is a model for locating defects on a product image, which is obtained through machine learning training based on a normal sample image and an abnormal sample image simulated based on the normal sample image. Therefore, the model has the support of defective product data and can accurately detect product defects.

[0027] The product defect detection method provided by the present invention obtains a model by training based on normal sample images and abnormal sample images simulated based on normal sample images, and locates the defect position of the product image to be detected, which can improve the accuracy of industrial product anomaly detection and effectively adapt to the complex and changeable anomaly detection needs in the industrial environment.

[0028] In a further method of the above method, the process of building a defect detection model is mainly explained as follows: A first number of normal sample images are selected from the normal sample image set.

[0029] Feature matching is performed on the image features of a first number of normal sample images, the image features of the remaining normal sample images in the normal sample image set, and the image features of each abnormal sample image in the simulated abnormal sample image set to obtain multiple first matching degrees, and a correspondence between the first judgment value and the normal image features and the abnormal image features is constructed based on the first matching degrees.

[0030] Perform feature transformation on the image features of the remaining normal sample images in the normal sample image set and the image features of each abnormal sample image in the simulated abnormal sample image set on the multi-dimensional feature channel, perform feature matching on the transformed features with the image features of the first number of normal sample images to obtain multiple second matching degrees, and construct a corresponding relationship between the second judgment degree and the normal image features and the abnormal image features based on the second matching degrees.

[0031] In this regard, it should be noted that, in the present invention, first, a large number of normal sample images collected are collected into an image set, and n normal sample images are randomly selected from the normal sample image set. An encoder is used to extract the features of the n normal sample images and store them in a database, which is regarded as a memory bank, and these feature information is recorded as memory information.

[0032] Subsequently, the Euclidean distance (L2 distance) between the image features of the remaining normal sample images in the normal sample image set, the features of each abnormal sample image in the simulated abnormal sample image set and the features of all image sample features in the memory library is calculated to quantify the difference information between the remaining normal sample images and abnormal sample images and the normal sample images in the memory library.

[0033] Where N is the number of sample images in the memory bank. For N different difference information DI, the minimum sum of all elements in each sample image is used as the standard to obtain the best difference information between MI (normal sample images in the memory bank) and II (the remaining normal sample images and abnormal sample images) .

[0034] Where i∈[1,N], the best difference information It contains the differences between the remaining normal sample images and the abnormal sample images and the sample images in the memory bank that are most similar to them. The larger the difference value at a certain position, the greater the probability that an abnormality will occur in the area of ​​the sample image corresponding to that position.

[0035] In the present invention, since the image features of the remaining normal sample images in the normal sample image set and the image features of each abnormal sample in the simulated abnormal sample image set are matched with the features of all image samples in the memory library, the difference value can be used as the matching degree.

[0036] To this end, the image features of the first number of normal sample images are feature matched with the image features of the remaining normal sample images in the normal sample image set and the image features of each abnormal sample image in the abnormal sample image set obtained by simulation, and multiple first matching degrees are obtained. Based on the first matching degrees, a correspondence relationship between the first judgment value and the normal image features and the abnormal image features is constructed. The correspondence relationship is used to determine whether there is a difference between different image features and normal image features. In other words, if the matching degree obtained for different image features at different positions on the product image reaches the corresponding judgment value, the position can be marked as a possible defect position.

[0037] Accordingly, in order to enhance the ability to detect abnormal areas in product images, the image features are enhanced, and semantic and detail features are injected into the image features of the remaining normal sample images in the normal sample image set and the image features of each abnormal sample image in the abnormal sample image set obtained by simulation on the multi-dimensional feature channel to complete the feature transformation, and then the transformed features are feature matched with the image features of the first number of normal sample images to obtain multiple second matching degrees, and the corresponding relationship between the second judgment degree and the normal image features and the abnormal image features is constructed based on the second matching degrees. This corresponding relationship is used to determine whether there is a difference between different image features and normal image features. In other words, if the matching degree obtained for different image features at different positions on the product image reaches the corresponding judgment value, the position can be marked as a possible defect position.

[0038] The further method of the present invention can further enhance the feature expression ability and spatial information capture ability of the model, thereby improving the accuracy and precision of anomaly detection, and can learn the ability of global structure and detail information, thereby more effectively capturing the characteristics of abnormal areas.

[0039] In a further method of the above method, the processing process of inputting the product image into the defect detection model to obtain the result image output by the defect detection model to locate the defect position is explained as follows: The defect detection module includes a matching layer, the product image is input into the matching layer, the image features of the product image are extracted by the matching layer, the image features of the product image are feature matched with the image features of the normal sample images in the pre-stored normal sample image set, and the first difference area in the product image is obtained, wherein the matching degree between the features of the first difference area and the features of the normal sample image reaches a first judgment value, and the first difference area is used as the defect position. That is to say, the product image is input into the matching layer, the image features of the product image are extracted by the matching layer, the image features of the product image are feature matched with the image features of the normal sample images in the pre-stored normal sample image set, and the matching degree between the features of the first difference area and the features of the normal sample image is determined. Then, based on the correspondence between the first judgment value and the normal image features and the abnormal image features, the difference area whose matching degree reaches the first judgment value is determined as the defect position.

[0040] In order to better detect defects in product images, it is necessary to strengthen the features. To this end, the defect detection module also includes an analysis layer, which inputs the features of the difference area in the product image into the analysis layer, and the analysis layer uses an attention mechanism to perform feature transformation on the multi-dimensional feature channel, and performs feature matching on the transformed features with the image features of the normal sample image in the pre-stored normal sample image set, and obtains the second difference area in the product image from the first difference area in the product image, wherein the matching degree between the features of the second difference area and the features of the normal sample image reaches the second judgment value, and the second difference area is used as the defect position. In other words, the transformed features are matched with the image features of the normal sample image in the pre-stored normal sample image set to determine the matching degree between the features of the first difference area and the features of the normal sample image. Then, based on the correspondence between the second judgment value and the normal image features and the abnormal image features, the difference area whose matching degree reaches the second judgment value is determined as the defect position. Since the enhancement is based on the features of the first difference area, the second difference area in the product image is actually obtained from the first difference area in the product image.

[0041] A further method of the above method mainly explains the processing process of the abnormal sample image obtained by simulating the normal sample image, as follows: A foreground mask image is obtained according to the normal sample image; the foreground mask image contains the product outline; A local abnormality mask image is obtained according to the foreground mask image and the random noise image; Obtaining a first fused image according to the local abnormality mask image and the normal sample image, wherein the first fused image indicates that an abnormal point is contained in a product image region; A second fused image is obtained according to the local abnormality mask image, the texture abnormality image and the structural abnormality image, wherein the second fused image represents the position distribution of the abnormal points; the texture abnormality image is a texture image in the texture data set, and the structural abnormality image is an image obtained by structurally adjusting the texture abnormality image; A simulated abnormal sample image is obtained according to the first fused image and the second fused image.

[0042] In this regard, it should be noted that see Figure 2 , according to the normal sample image I (such as capsule image) input into the SAM model for accurate segmentation, and finally the obtained mask image is binarized to generate the final foreground mask image M I , the foreground mask image contains the product outline.

[0043] Generate random 2D Perlin noise P, then binarize it through threshold T to get the processed noise image M P . Then compare it with the segmented foreground mask image M I Multiply them together to get the local abnormal mask image M. The formula is as follows: Then, by inverting the mask image get , and compare it with the normal sample image Perform element-by-element multiplication to obtain the foreground image with abnormal areas (ie the first fused image).

[0044] The obtained local anomaly mask image With texture abnormal image S and structural abnormal image I n Through the element-wise fusion operation, a background image S with abnormal areas is generated. ’ (i.e., the second fused image). The present invention introduces a transparency factor in this process to balance the fusion of the original image and the noise image, so that the simulated abnormal pattern is closer to the real abnormality. Therefore, the background image S with the abnormal area ’ Generated by the following formula: in, is the transparency factor.

[0045] The texture anomaly image S comes from the DTD texture dataset and is used to simulate texture anomalies; the structural anomaly image I n The image I is obtained by randomly adjusting (including mirror symmetry, rotation, brightness, saturation and hue) to simulate structural abnormalities. In order to further simulate structural abnormalities, the image I after preliminary processing is evenly divided into 4×8 grids and randomly arranged to obtain a disordered image .

[0046] A simulated abnormal sample image is obtained according to the first fused image and the second fused image. Through this abnormal simulation strategy, simulated abnormal samples can be obtained from two perspectives: structure and texture, and a large number of abnormal areas can be generated on the segmented target foreground, thereby maximizing the similarity between the simulated abnormal samples and the real abnormal samples.

[0047] The product defect detection device provided by the present invention is described below. The product defect detection device described below and the product defect detection method described above can be referenced to each other.

[0048] Figure 3 A schematic diagram of the structure of a product defect detection device provided by the present invention is shown. Figure 3 , the device comprises an acquisition module 31 and a detection module 32, wherein: An acquisition module 31 is used to acquire an image of a product to be detected; The detection module 32 is used to input the product image into the defect detection model to obtain a result image output by the defect detection model to locate the defect position; Among them, the defect detection model is a model obtained through machine learning training based on normal sample images and abnormal sample images simulated based on normal sample images, and is used to locate defects on product images.

[0049] Since the principle of the device of the embodiment of the present invention is the same as that of the method of the above embodiment, a more detailed explanation is omitted here.

[0050] It should be noted that, in the embodiments of the present invention, relevant functional modules may be implemented by a hardware processor.

[0051] The product defect detection device provided by the present invention obtains a model by training based on normal sample images and abnormal sample images simulated based on normal sample images, and locates the defect position of the product image to be detected, which can improve the accuracy of industrial product anomaly detection and effectively adapt to the complex and changeable anomaly detection needs in the industrial environment.

[0052] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device may include: a processor 41 (processor), a communication interface 42 (Communications Interface), a memory 43 (memory) and a communication bus 44, wherein the processor 41, the communication interface 42, and the memory 43 communicate with each other through the communication bus 44. The processor 41 may call the logic instructions in the memory 43 to execute the product defect detection method, which includes: obtaining a product image to be detected; inputting the product image into a defect detection model to obtain a result image output by the defect detection model to locate the defect position; wherein the defect detection model is a model obtained by machine learning training based on a normal sample image and an abnormal sample image simulated based on the normal sample image, and is used to locate defects on the product image.

[0053] In addition, the logic instructions in the above-mentioned memory 43 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0054] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the product defect detection method provided by the above-mentioned methods, which includes: obtaining a product image to be inspected; inputting the product image into a defect detection model to obtain a result image output by the defect detection model that locates the defect position; wherein the defect detection model is a model obtained by machine learning training based on normal sample images and abnormal sample images simulated based on normal sample images, and is used to locate defects on product images.

[0055] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the product defect detection method provided by the above-mentioned methods, the method comprising: acquiring an image of a product to be inspected; inputting the product image into a defect detection model to obtain a result image output by the defect detection model that locates the defect position; wherein the defect detection model is a model obtained by machine learning training based on normal sample images and abnormal sample images simulated based on normal sample images, and is used to locate defects on product images.

[0056] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0057] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0058] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A product defect detection method, characterized in that: include: Acquire an image of a product to be inspected; Inputting the product image into a defect detection model to obtain a result image output by the defect detection model that locates the defect position; The defect detection model is a model obtained through machine learning training based on normal sample images and abnormal sample images simulated based on normal sample images, and is used to locate defects on product images.

2. The product defect detection method according to claim 1, characterized in that: The defect detection model includes a matching layer. Accordingly, the product image is input into the defect detection model to obtain a result image output by the defect detection model and locating the defect position, including: The product image is input into a matching layer, which extracts image features of the product image. The image features of the product image are matched with image features of normal sample images in a pre-stored normal sample image set to obtain a first difference area in the product image, wherein a matching degree between features of the first difference area and features of the normal sample image reaches a first judgment value, and the first difference area is used as a defect location.

3. The product defect detection method according to claim 2, characterized in that: The defect detection module further includes an analysis layer. Accordingly, the product image is input into the defect detection model to obtain a result image output by the defect detection model to locate the defect position, including: The features of the difference area in the product image are input to the analysis layer, and the analysis layer uses the attention mechanism to perform feature transformation on the multi-dimensional feature channel, and the transformed features are matched with the image features of the normal sample images in the pre-stored normal sample image set, and the second difference area in the product image is obtained from the first difference area in the product image, wherein the matching degree between the features of the second difference area and the features of the normal sample image reaches a second judgment value, and the second difference area is used as the defect position.

4. The product defect detection method according to claim 1, characterized in that: The abnormal sample images simulated based on the normal sample images include: Obtaining a foreground mask image according to the normal sample image; the foreground mask image includes a product outline; Obtaining a local abnormality mask image according to the foreground mask image and the random noise image; Obtaining a first fused image according to the local abnormality mask image and the normal sample image, wherein the first fused image indicates that an abnormal point is contained in a product image region; A second fused image is obtained according to the local abnormality mask image, the texture abnormality image and the structural abnormality image, wherein the second fused image represents the position distribution of abnormal points; the texture abnormality image is a texture image in a texture data set, and the structural abnormality image is an image obtained by structurally adjusting the texture abnormality image; A simulated abnormal sample image is obtained according to the first fused image and the second fused image.

5. The product defect detection method according to claim 4, characterized in that: The step of obtaining a second fused image according to the local abnormality mask image, the texture abnormality image and the structural abnormality image comprises: Obtaining a texture anomaly fusion image according to the local anomaly mask image and the texture anomaly image; Obtaining a structural abnormality fusion image according to the local abnormality mask image and the structural abnormality image; A preset transparency factor is obtained, and a second fused image is obtained according to the transparency factor, the texture abnormality fused image, and the structure abnormality fused image.

6. The product defect detection method according to claim 1, characterized in that: The method also includes constructing a defect detection model, including: Selecting a first number of normal sample images from the normal sample image set; Performing feature matching on the image features of the first number of normal sample images, the image features of the remaining normal sample images in the normal sample image set, and the image features of each abnormal sample image in the abnormal sample image set obtained by simulation, to obtain a plurality of first matching degrees, and constructing a correspondence between the first judgment value and the normal image features and the abnormal image features based on the first matching degrees; Perform feature transformation on the image features of the remaining normal sample images in the normal sample image set and the image features of each abnormal sample image in the simulated abnormal sample image set on the multi-dimensional feature channel, perform feature matching on the transformed features with the image features of the first number of normal sample images to obtain multiple second matching degrees, and construct a corresponding relationship between the second judgment degree and the normal image features and the abnormal image features based on the second matching degrees.

7. A product defect detection device, characterized in that: include: An acquisition module, used for acquiring an image of a product to be inspected; A detection module, used for inputting the product image into a defect detection model to obtain a result image output by the defect detection model and locating the defect position; The defect detection model is a model obtained through machine learning training based on normal sample images and abnormal sample images simulated based on normal sample images, and is used to locate defects on product images.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the product defect detection method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the product defect detection method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the product defect detection method according to any one of claims 1 to 6 is implemented.