Defect detection method and device, equipment, storage medium and program product

By generating pixel comparison images and using pixel value differences to determine defect areas, the problem of low accuracy in existing defect detection models is solved, achieving higher detection accuracy.

CN120823218AActive Publication Date: 2025-10-21SHENZHEN XINXINTENG TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511336872.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-18
Publication Date
2025-10-21
Estimated Expiration
2045-09-18

Smart Images

  • Figure CN120823218A_ABST
    Figure CN120823218A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of image processing, and provides a defect detection method and device, equipment, a storage medium and a program product, and the method comprises the steps: carrying out the preliminary defect detection of a detection image through a defect detection model, obtaining a preliminary detection result, generating a pixel comparison image according to the difference between a pixel value in the preliminary detection result and a pixel value as a reference, and obtaining a detection result; the noise data in the first defect area is further reduced, and further defect detection is performed on the first defect area, so that the accuracy of the finally obtained defect detection result is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of image processing technology, and in particular relates to defect detection methods, devices, equipment, storage media and program products. Background Art

[0002] With the development of technology, during the product production process, each sample to be produced is tested, and samples that meet the factory conditions are selected to ensure the quality of the products after leaving the factory. For example, the samples are tested for defects in appearance, whether the parts are complete, and whether the assembly of parts complies with assembly specifications.

[0003] In related technologies, a defect detection model is pre-trained, and a sample image is input into the defect detection model for defect detection. Whether the sample has defects is determined based on the output results.

[0004] However, due to the wide variety of defect types, the pre-trained defect detection model cannot cover all defect types, and due to the limitations of the training samples of the defect detection model, the defect detection ability of the defect detection model is limited, resulting in low accuracy of the defect detection results. Summary of the Invention

[0005] The embodiments of the present application provide a defect detection method, apparatus, equipment, storage medium and program product. After performing defect detection on a detection image using a pre-trained defect detection model to obtain preliminary detection results, a comparison map is generated based on the difference between the pixel values ​​in the defect area in the preliminary detection results and the pixel values ​​in the reference area. The defective part in the detection image is further determined based on the comparison map, thereby improving the accuracy of the defect detection results.

[0006] In a first aspect, an embodiment of the present application provides a defect detection method, the method comprising: Acquire detection images; Performing defect detection on the detection image using a pre-trained defect detection model to obtain a first defect region corresponding to the detection image, wherein the first defect region includes a region corresponding to a defective portion in the detection image, the defect detection model being a neural network model, and a plurality of first pixel points in the first defect region respectively corresponding to first pixel values; Obtaining a second pixel value in a reference area in the inspection image, where the reference area is an area corresponding to a specified position of the first defect area, multiple second pixel points in the reference area respectively correspond to candidate pixel values, and the second pixel value is obtained based on a sorting result of the multiple candidate pixel values; generating a pixel comparison map corresponding to the first defect area based on pixel differences between the plurality of first pixel values ​​and the second pixel value; When the image parameters of the second defect area in the pixel comparison image are determined to meet the preset defect conditions, the second defect area is used as the defect detection result corresponding to the detection image, and the defect detection result is used to indicate that the second defect area is the area corresponding to the defect part in the detection image.

[0007] Optionally, the multiple first pixel values ​​include an i-th first pixel value corresponding to an i-th first pixel point, where i is a positive integer; The generating a pixel comparison map corresponding to the first defect area based on the pixel differences between the plurality of first pixel values ​​and the second pixel value includes: Obtaining a pixel value difference between the i-th first pixel value and the second pixel value as the i-th pixel difference; The pixel comparison map is generated based on the pixel differences respectively corresponding to the multiple first pixel values.

[0008] Optionally, the detection image is a color image, and the i-th first pixel value includes an i-th first sub-value, an i-th second sub-value, and an i-th third sub-value; The obtaining, as the i-th pixel difference, a pixel value difference between the i-th first pixel value and the second pixel value includes: Obtaining a pixel value difference between the i-th first sub-value and the second pixel value as an i-th first difference value; Obtaining a pixel value difference between the i-th second sub-value and the second pixel value as an i-th second difference value; Obtaining a pixel value difference between the i-th third sub-value and the second pixel value as an i-th third difference value; The i-th pixel difference is obtained based on the i-th first difference value, the i-th second difference value, and the i-th third difference value.

[0009] Optionally, after generating the pixel comparison map based on the pixel differences respectively corresponding to the plurality of first pixel values, the method further includes: Obtaining a first weight value, a second weight value, and a third weight value; Obtaining an i-th first product result between the first weight value and the i-th first difference value; Obtaining an i-th second product result between the second weight value and the i-th second difference value; Obtaining an i-th third product result between the third weight value and the i-th third difference value; Obtaining an i-th third pixel value corresponding to the i-th first pixel point based on a sum of the i-th first product result, the i-th second product result, and the i-th third product result; generating a defect comparison map based on the third pixel values ​​respectively corresponding to the plurality of first pixel points; When the image parameters of the second defect area in the pixel comparison image are determined to meet the preset defect condition, taking the second defect area as the defect detection result corresponding to the detection image includes: When the image parameters of the second defect area in the defect comparison image are determined to meet the preset defect conditions, the second defect area is used as the defect detection result corresponding to the detection image.

[0010] Optionally, the preset defect condition includes at least one of a contrast threshold, a pixel number threshold, or an aspect ratio threshold; Before taking the second defect area as the defect detection result corresponding to the detection image, the method further includes: When the contrast of the pixels in the second defect area reaches the contrast threshold, determining that the second defect area meets the preset defect condition; and / or; When the number of pixels in the second defect area reaches the pixel number threshold, determining that the second defect area meets the preset defect condition; and / or; When the ratio between the region length and the region width of the second defect region reaches the aspect ratio threshold, it is determined that the second defect region meets the preset defect condition.

[0011] Optionally, before performing defect detection on the detection image using a pre-trained defect detection model to obtain a first defect area corresponding to the detection image, the method further includes: Acquire a first sample image, where the first sample image includes a first sample defect portion; Marking the first sample defect portion to obtain a defect label corresponding to the first sample image, where the defect label is used to indicate a position and defect features of the first sample defect portion in the first sample image; generating a first random value based on the defect characteristic; generating a second sample image based on the first random value, wherein the second sample image includes a second defect portion, and the second defect portion is randomly generated based on the first random value; Gradient training is performed on a sample detection model based on the first sample image and the second sample image to obtain the defect detection model.

[0012] In a second aspect, an embodiment of the present application provides a defect detection device, comprising: An acquisition module, used for acquiring a detection image; a detection module, configured to perform defect detection on the detection image using a pre-trained defect detection model to obtain a first defect region corresponding to the detection image, wherein the first defect region includes a region corresponding to a defective portion in the detection image, the defect detection model being a neural network model, and a plurality of first pixel points in the first defect region respectively corresponding to first pixel values; The acquisition module is configured to acquire a second pixel value in a reference area in the inspection image, where the reference area is an area corresponding to a specified position of the first defect area, a plurality of second pixel points in the reference area respectively correspond to candidate pixel values, and the second pixel value is obtained based on a sorting result of the plurality of candidate pixel values; a generating module, configured to generate a pixel comparison map corresponding to the first defect area based on pixel differences between the plurality of first pixel values ​​and the second pixel value; A determination module is used to use the second defect area in the pixel comparison image as the defect detection result corresponding to the detection image when the image parameters of the second defect area are determined to meet the preset defect conditions. The defect detection result is used to indicate that the second defect area is the area corresponding to the defect part in the detection image.

[0013] In a third aspect, an embodiment of the present application provides a computer 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 computer program, the defect detection method described in any one of the first aspects above is implemented.

[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the defect detection method described in any one of the first aspects is implemented.

[0015] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer device, enables the computer device to execute the defect detection method described in any one of the above-mentioned first aspects.

[0016] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.

[0017] The beneficial effects of the technical solutions provided in the embodiments of the present application include at least: A pre-trained defect detection model is used to perform defect detection on a test image to obtain a first defect region in the test image. A pixel comparison map of the first defect region is generated based on the difference between the first pixel value of a pixel point in the first defect region and the second pixel value in the reference region of the test image. Based on the pixel comparison map, a second defect region containing a defective portion in the first defect region is further determined as the defect detection result for the test image. In other words, after performing preliminary defect detection on the test image using the defect detection model to obtain a preliminary detection result, a pixel comparison map is generated based on the difference between the pixel value in the preliminary detection result and the pixel value used as the reference, further reducing noise data in the first defect region. This allows further defect detection of the first defect region, resulting in a more accurate final defect detection result. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0019] Figure 1 This is a flow chart of a defect detection method provided by an embodiment of the present application; Figure 2 This is a flow chart of a defect detection method provided by an embodiment of the present application; Figure 3 This is a schematic diagram of a defect comparison diagram generation method provided by an embodiment of the present application; Figure 4 is a schematic diagram of defect detection results provided by an embodiment of the present application; Figure 5 This is a schematic diagram of a defect label provided by an embodiment of the present application; Figure 6 is a schematic diagram of a second sample image provided in an embodiment of the present application; Figure 7 is a structural diagram of a defect detection device provided in an embodiment of the present application; Figure 8 It is a structural diagram of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0020] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.

[0021] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.

[0022] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0023] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0024] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0025] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

[0026] In related technologies, a defect detection model is pre-trained, sample images are input into the defect detection model for defect detection, and the presence of defects in the sample is determined based on the output results. However, due to the wide variety of defect types, the pre-trained defect detection model cannot cover all defect types. Furthermore, due to the limitations of the training samples for the defect detection model, the defect detection capability of the defect detection model is limited. Furthermore, since noisy data is inevitably present in the defect detection results, the accuracy of the defect detection results is low.

[0027] Based on this, an embodiment of the present application provides a defect detection method, which performs defect detection on a detection image using a pre-trained defect detection model to obtain a first defect region in the detection image, generates a pixel comparison map of the first defect region based on the difference between a first pixel value of a pixel point in the first defect region and a second pixel value in a reference region in the detection image, and further determines a second defect region containing a defective portion in the first defect region based on the pixel comparison map as a defect detection result for the detection image. In other words, after performing preliminary defect detection on the detection image using the defect detection model to obtain a preliminary detection result, a pixel comparison map is generated based on the difference between the pixel value in the preliminary detection result and the pixel value used as a reference, further reducing noise data in the first defect region. This allows further defect detection to be performed on the first defect region, resulting in a higher accuracy of the final defect detection result.

[0028] The defect detection method provided in the embodiment of the present application is described in detail below. For schematic illustration, please refer to Figure 1 , which shows a flow chart of a defect detection method provided by an exemplary embodiment of the present application, the method includes the following steps 110 to 150.

[0029] Step 110: Acquire a detection image.

[0030] Schematically, the detection image is an image obtained by capturing the detection object through an image acquisition device, wherein the image acquisition device includes at least one of a film camera, a digital camera, an industrial camera (for example, an area array camera, a line array camera or a smart camera), a microscopic imaging device (for example, an optical microscope, an electron microscope), an astronomical imaging device (radio telescope), an electromagnetic wave-based image acquisition device (for example, an infrared thermal imager, an X-ray imaging device), a three-dimensional imaging device, a multispectral imaging device, an embedded imaging device (for example, a mobile phone camera, a drone-mounted camera), a light field camera, etc.

[0031] Optionally, the detection image is a single image corresponding to a single detection object; or, the detection image is multiple images corresponding to a single detection object; or, the detection image includes multiple images of multiple detection objects, which is not limited in the embodiments of the present application.

[0032] Optionally, the detection image includes the defective portion, or the detection image does not include the defective portion.

[0033] Optionally, the detection image is a three-channel image (RGB image), which can also be called a color image. In this case, each pixel in the detection image outputs three channel values, namely red (Red, R) channel value, green (Green, G) channel value and blue (Blue, B) channel value. The pixel value of the pixel in the detection image is determined based on the R channel value, G channel value and B channel value.

[0034] Optionally, the detection image is a single-channel image, which may also be called a grayscale image. In this case, each pixel in the detection image outputs a single-channel value as the pixel value of the pixel, which may also be called a grayscale value.

[0035] Step 120 : Perform defect detection on the detection image using a pre-trained defect detection model to obtain a first defect area corresponding to the detection image.

[0036] The first defect area includes an area corresponding to a defective portion in the detection image, the defect detection model is a neural network model, and a plurality of first pixel points in the first defect area respectively correspond to first pixel values.

[0037] Illustratively, the first pixel point refers to the pixel point corresponding to the first defect area.

[0038] Schematically, the detection image is input into the defect detection model, and the defect detection model is used to perform defect detection on the detection image, and the output result is the first defect area of ​​the detection image.

[0039] The first defect area refers to an area corresponding to a defective portion in the detection image.

[0040] Optionally, the defect detection model includes at least one of the following model types: The first type is a classification network, whose output includes whether the image has defects (for example, 0 means no defects, 1 means defects) and the defect category (for example, a: bump; b: scratch); Among them, the classification network includes the residual model ResNet and the composite scaling model (EfficientNet); The second type, object detection network, adds bounding box recognition on the basis of classification to determine the defect area in the detection image; Among them, the target detection network includes Faster R-CNN and multi-scale feature map detection model (Single Shot MultiBox Detector, SSD); The third type is the semantic segmentation network, which traverses the pixels and classifies the pixels in the detection image to generate a mask corresponding to the defect part. The defect boundary is determined based on the mask and the defect area is identified. Among them, the semantic segmentation network includes the encoder-decoder model (U-Net) and the Transformer-based lightweight segmentation model (SegFormer).

[0041] It is worth noting that the above-mentioned defect detection model is only an illustrative example and is not limited to this embodiment of the present application.

[0042] Optionally, the detection image includes one or more first defect areas, where if there are multiple first defect areas, the multiple first defect areas are independent of each other and there is no intersection, or there are at least two first defect areas among the multiple first defect areas that have an intersection. This embodiment of the present application is not limited to this.

[0043] Optionally, the defective parts include appearance defects (bumps, depressions, scratches, shadows, stains, partial missing, dimensions not meeting dimension requirements), component defects (missing components, component data exceeding a quantity threshold, component type not meeting type conditions, component assembly not meeting assembly specifications, etc.), structural defects (internal fractures, presence of air holes, separation between composite material layers, impurities mixed in the material), packaging defects (breakage, deformation, tearing, incorrect labeling, sealing not meeting sealing standards), etc., and the embodiments of the present application are not limited to this.

[0044] Optionally, if the detection image is a multi-channel image, the first pixel value is a red channel value, a green channel value, and a blue channel value; if the detection image is a single-channel image, the first pixel value is a grayscale value.

[0045] Step 130: Obtain a second pixel value in a reference area in the detection image.

[0046] The reference area refers to an area corresponding to a designated position of the first defect area, and multiple second pixel points in the reference area correspond to candidate pixel values ​​respectively, and the second pixel values ​​are obtained based on the sorting results of the multiple candidate pixel values.

[0047] Illustratively, the reference area refers to an area at a specified position of the first defect area, for example, an area adjacent to the first defect area in the detection image.

[0048] Optionally, the reference area may be selected in at least one of the following ways: The first method is to obtain a plurality of pixel points 1 corresponding to the edge position of the first defect area, and determine the coordinate point positions corresponding to the plurality of pixel points 1 in the coordinate system established by the detection image, wherein the pixel coordinate distance between the coordinate point positions and the coordinate point positions is within a predetermined range, and determine the reference area based on the coordinate point positions; The second method is to obtain the area range 1 of the first defect area in the detection image (determined by the coordinate point positions corresponding to the pixel points in the first defect area in the coordinate system established by the detection image), determine the area range 2 according to the area range 1 and the pre-set area rules, and use the area corresponding to the area range 2 as the reference area.

[0049] It is worth noting that the above-mentioned method for selecting the reference area is only an illustrative example and is not limited to this embodiment of the present application.

[0050] In this embodiment, the area adjacent to the first defect area is used as the reference area, that is, pixel point 1 at the edge of the first defect area and pixel point 2 at the edge of the reference area are adjacent.

[0051] Optionally, the neighbor relationship includes at least one of a 4-neighborhood, an 8-neighborhood, a D-neighborhood, or an extended neighborhood.

[0052] Among them, the 4-neighborhood refers to the adjacent pixels located at the four positions above, below, left, and right of the target pixel; the 8-neighborhood refers to the adjacent pixels located at the eight positions above, below, left, right, and four diagonal directions of the target pixel; the D-neighborhood refers to the adjacent pixels in the four diagonal directions of the target pixel; the extended neighborhood refers to defining an M×N rectangular area as the neighborhood with the target pixel as the center, and all pixels in the rectangular area are adjacent pixels of the target pixel.

[0053] Illustratively, the second pixel value is determined according to the pixel value of the pixel point in the reference area.

[0054] Optionally, the second pixel value is obtained by at least one of the following methods: The first method is to arrange the pixel values ​​corresponding to the plurality of second pixel points in the reference area according to a certain arrangement rule (for example, from small to large or from large to small) to obtain a pixel value sequence, and select the pixel value at the middle position from the pixel value sequence as the second pixel value. If the pixel value sequence is an even sequence, the average of the two pixel values ​​at the middle position is selected to obtain the second pixel value. The second method is to calculate the average value of pixel values ​​corresponding to multiple second pixel points in the reference area as the second pixel value; The third method is to perform bubble processing on the pixel values ​​corresponding to multiple pixel points in the reference area to obtain a bubble sequence (for example, removing the maximum pixel value and the minimum pixel value and arranging them in ascending order), and select the pixel value in the middle position from the bubble sequence as the second pixel value. If the bubble sequence is an even sequence, the two pixel values ​​in the middle position are selected to calculate the average value to obtain the second pixel value.

[0055] It is worth noting that the above-mentioned method for obtaining the second pixel value is only an illustrative example and is not limited to this embodiment of the present application.

[0056] Illustratively, since the second pixel value is obtained from a plurality of pixel values ​​in the reference area, and the reference area does not belong to the defective area, the second pixel value can be considered as a pixel value belonging to a non-defective portion.

[0057] Optionally, the second pixel value is a grayscale value; or, the second pixel value is a grayscale value obtained by weighted fusion of three channel values; or, the second pixel value includes three channel values, which is not limited in this embodiment of the present application.

[0058] Step 140 : generating a pixel comparison map corresponding to the first defective area based on pixel differences between the plurality of first pixel values ​​and the second pixel values.

[0059] Schematically, the pixel difference refers to the pixel difference between the first pixel value and the second pixel value, which expresses the contrast between the first pixel point and the second pixel point. If the pixel difference is larger, the contrast is more obvious. Therefore, if the pixel difference is larger, the probability that the first pixel point belongs to the defective part is higher.

[0060] Schematically, there is a corresponding pixel difference between each first pixel value and the second pixel value, that is, each first pixel point corresponds to a pixel difference. Therefore, a pixel comparison map is formed based on the pixel differences corresponding to multiple first pixel points.

[0061] Schematically, the pixel contrast image is a single-channel image, or the pixel contrast image is a three-channel image.

[0062] Step 150 : When the image parameters of the second defective area in the pixel comparison image are determined to meet the preset defect conditions, the second defective area is used as the defect detection result corresponding to the detection image.

[0063] The defect detection result is used to indicate that the second defect area is an area corresponding to the defective part in the detection image.

[0064] Illustratively, the second defect area refers to an area corresponding to the defective portion in the final detection image.

[0065] Schematically, the defect detection result is used to indicate the position of the defective part in the detection image, the area corresponding to the defective part, the defect shape corresponding to the defective part, etc.

[0066] Optionally, the image parameters include the absolute value of the pixel difference corresponding to each pixel in the second defect area (representing a comparison diagram of the pixel points), the number of pixels in the second defect area (representing the area of ​​the second defect area), or the ratio between the length and width of the second defect area.

[0067] Optionally, the first defect region and the second defect region are the same, or the first defect region and the second defect region are different, which is not limited in the embodiment of the present application.

[0068] The defect detection method provided in an embodiment of the present application performs defect detection on a detection image using a pre-trained defect detection model to obtain a first defect region in the detection image, generates a pixel comparison map of the first defect region based on the difference between a first pixel value of a pixel point in the first defect region and a second pixel value in a reference region in the detection image, and further determines a second defect region containing a defective portion in the first defect region based on the pixel comparison map as a defect detection result for the detection image. In other words, after performing preliminary defect detection on the detection image using the defect detection model to obtain a preliminary detection result, a pixel comparison map is generated based on the difference between the pixel value in the preliminary detection result and the pixel value used as a reference, further reducing noise data in the first defect region. This allows further defect detection of the first defect region, resulting in a higher accuracy of the final defect detection result.

[0069] The following is a detailed description of the defect detection method. For schematic illustration, please refer to Figure 2 , which shows a flow chart of a defect detection method provided by an exemplary embodiment of the present application, that is, step 140 also includes steps 141 and 142, and step 150 also includes step 151, such as Figure 2 As shown, the method includes the following steps.

[0070] Step 141 : Obtain the pixel value difference between the i-th first pixel value and the second pixel value as the i-th pixel difference.

[0071] Among them, the multiple first pixel values ​​include the i-th first pixel value corresponding to the i-th first pixel point, and i is a positive integer.

[0072] Schematically, taking the i-th first pixel point in the first defect area as an example, the i-th first pixel point corresponds to the i-th first pixel value.

[0073] If the i-th first pixel value corresponds to a first grayscale value and the second pixel value corresponds to a second grayscale value, then the i-th pixel difference is the grayscale difference between the first grayscale value and the second grayscale value.

[0074] In some embodiments, the detection image is a color image, and the i-th first pixel value includes the i-th first sub-value, the i-th second sub-value and the i-th third sub-value; the pixel value difference between the i-th first sub-value and the second pixel value is obtained as the i-th first difference; the pixel value difference between the i-th second sub-value and the second pixel value is obtained as the i-th second difference; the pixel value difference between the i-th third sub-value and the second pixel value is obtained as the i-th third difference; the i-th pixel difference is obtained based on the i-th first difference, the i-th second difference and the i-th third difference.

[0075] In this embodiment, the detection image is taken as a color image as an example, that is, each pixel in the detection image outputs three channel values. Therefore, the i-th first pixel value includes a red channel value (i-th first sub-value), a green channel value (i-th second sub-value) and a blue channel value (i-th third sub-value).

[0076] In this embodiment, in one case, if the second pixel value is a grayscale value obtained after grayscale conversion based on the three-channel color value, then the first difference between the red channel value and the second pixel value is calculated, the second difference between the green channel value and the second pixel value is calculated, and the third difference between the blue channel value and the second pixel value is calculated. The numerical fusion result between the first difference, the second difference and the third difference is used as the i-th pixel value, for example: the average value between the first difference, the second difference and the third difference is calculated, or the weighted average value between the first difference, the second difference and the third difference is calculated.

[0077] In this embodiment, in one case, if the second pixel value is a grayscale value obtained after grayscale conversion based on the three-channel color value, it is first converted into the grayscale value corresponding to the i-th first pixel point based on the fusion result between the red channel value, the green channel value and the blue channel value, for example: calculating the average value between the red channel value, the green channel value and the blue channel value, or calculating the weighted average value between the red channel value, the green channel value and the blue channel value; calculating the pixel difference between the fusion result and the second pixel value to obtain the i-th pixel difference, please refer to Formula 1 for details.

[0078] Formula 1: C = I - G m Where C represents the pixel difference, I represents the first pixel value, G m Represents the second pixel value.

[0079] In this embodiment, in one case, if the second pixel value also includes three-channel pixel values, the first difference between the red channel value in the first pixel value and the red channel value in the second pixel value is calculated, the second difference between the green channel value in the first pixel value and the green channel value in the second pixel value is calculated, and the third difference between the blue channel value in the first pixel value and the blue channel value in the second pixel value is calculated. The pixel value in the pixel comparison map is composed of the first difference, the second difference and the third difference, that is, the pixel comparison map is a three-channel image.

[0080] In this embodiment, in one case, if the second pixel value also includes a three-channel pixel value, a first difference between the red channel value in the first pixel value and the red channel value in the second pixel value is calculated, a second difference between the green channel value in the first pixel value and the green channel value in the second pixel value is calculated, and a third difference between the blue channel value in the first pixel value and the blue channel value in the second pixel value is calculated. The numerical fusion result between the first difference, the second difference and the third difference is used as the pixel value in the pixel comparison map, for example: the average value between the first difference, the second difference and the third difference is calculated, or the weighted average value between the first difference, the second difference and the third difference is calculated.

[0081] Step 142: Generate a pixel comparison map based on the pixel differences corresponding to the plurality of first pixel values.

[0082] Illustratively, the pixel differences corresponding to the plurality of first pixel values ​​are used as pixel values ​​in the pixel comparison map, thereby generating the pixel comparison map.

[0083] In some embodiments, a first weight value, a second weight value, and a third weight value are obtained; the i-th first product result between the first weight value and the i-th first difference value is obtained; the i-th second product result between the second weight value and the i-th second difference value is obtained; the i-th third product result between the third weight value and the i-th third difference value is obtained; based on the sum of the i-th first product result, the i-th second product result, and the i-th third product result, the i-th third pixel value corresponding to the i-th first pixel point is obtained; and based on the third pixel values ​​corresponding to multiple first pixel points, a defect comparison map is generated.

[0084] In this embodiment, further, if each pixel value in the pixel comparison map outputs three-channel values, a first weight value, a second weight value and a third weight value are generated in advance, and the i-th first product result between the first weight value and the i-th first difference is obtained; the i-th second product result between the second weight value and the i-th second difference is obtained; the i-th third product result between the third weight value and the i-th third difference is obtained; based on the sum of the i-th first product result, the i-th second product result and the i-th third product result, the i-th third pixel value corresponding to the i-th first pixel point is obtained. For details, please refer to Formula 2.

[0085] Formula 2: C1 = 0.299·C_R + 0.587·C_G + 0.114·C_B Among them, C1 represents the pixel value in the defect comparison image, C_R represents the red channel value corresponding to the pixel value in the pixel comparison image, C_G represents the green channel value corresponding to the pixel value in the pixel comparison image, C_B represents the blue channel value corresponding to the pixel value in the pixel comparison image, 0.299 is the first weight value, 0.587 is the second weight value, and 0.114 is the third weight value.

[0086] Schematically, the defect comparison map is more consistent with the pre-set visual perception than the pixel comparison map, because the defect comparison map can more clearly determine the area corresponding to the defective part.

[0087] For illustration, please refer to Figure 3 , which shows a schematic diagram of a defect comparison diagram generation method provided by an exemplary embodiment of the present application, such as Figure 3 As shown, the first defect area 310 is currently displayed, and a defect comparison map 320 is obtained according to the above method. According to the first defect area 310 and the defect comparison map 320 , it can be seen that the defect portion is clearer in the defect comparison map 320 than in the first defect portion 310 .

[0088] Step 151 : When the image parameters of the second defect area in the defect comparison image are determined to meet the preset defect conditions, the second defect area is used as the defect detection result corresponding to the detection image.

[0089] In some embodiments, the preset defect condition includes at least one of a contrast threshold, a pixel number threshold, or an aspect ratio threshold; when the contrast of the pixels in the second defect area reaches the contrast threshold, the second defect area is determined to meet the preset defect condition; and / or; when the number of pixels in the second defect area reaches the pixel number threshold, the second defect area is determined to meet the preset defect condition; and / or; when the ratio between the area length and the area width of the second defect area reaches the aspect ratio threshold, the second defect area is determined to meet the preset defect condition.

[0090] In this embodiment, a contrast threshold, a pixel number threshold and an aspect ratio threshold are set. If the contrast of the pixels in the second defect area in the defect comparison image reaches the contrast threshold, the second defect area is determined to meet the preset defect condition. If the number of pixels in the second defect area in the defect comparison image reaches the pixel number threshold, the second defect area is determined to meet the preset defect condition. If the ratio between the area length and the area width of the second defect area in the defect comparison image reaches the aspect ratio threshold, the second defect area is determined to meet the preset defect condition.

[0091] For illustration, please refer to Figure 4 , which shows a schematic diagram of defect detection results provided by an exemplary embodiment of the present application, such as Figure 4 As shown, the current inspection image displays defect inspection results, including defect portion 410 , defect portion 420 , and defect portion 430 .

[0092] Illustratively, the defect detection method implemented in the present application can be executed by a terminal device, so the final defect detection result is displayed on the terminal device. When the terminal device processes the defect detection task, a parameter setting interface 440 is displayed in the device interface of the terminal device, which is used to configure the parameters of the defect detection requirements, such as: detection model, downsampling value, smoothing blur, low contrast threshold, high contrast threshold and area threshold, etc. After setting the parameters, the defect detection result corresponding to the detection image is automatically displayed on the terminal device.

[0093] The following is a detailed description of the training process of the defect detection model.

[0094] In some embodiments, a first sample image is obtained, the first sample image includes a first sample defect portion; the first sample defect portion is labeled to obtain a defect label corresponding to the first sample image, the defect label is used to indicate the position and defect characteristics of the first sample defect portion in the first sample image; a first random value is generated based on the defect characteristics; a second sample image is generated based on the first random value, the second sample image includes a second sample defect portion, and the second sample defect portion is randomly generated based on the first random value; and a sample detection model is gradient trained based on the first sample image and the second sample image to obtain a defect detection model.

[0095] In this embodiment, the defects in the sample image are preliminarily marked using traditional image processing algorithms, and a marked image with defect location and feature information is generated to generate defect labels. Figure 5 , which shows a schematic diagram of a defect label provided by an exemplary embodiment of the present application, such as Figure 5 As shown, a first sample image 500 is currently acquired, and a first sample defect portion 510 in the first sample image is marked to obtain a defect label corresponding to the first sample defect portion 510 , wherein the defect label includes the length, width, pixel value, etc. corresponding to the first sample defect portion 510 .

[0096] In this embodiment, to address the problem of insufficient real defect samples, a normal distribution random algorithm and other random algorithms are used to generate defect images. During the generation process, key features of the defect, such as contrast, shape, length and width, are made to take on normally distributed random values, thereby creating a wide variety of defect samples. Among them, the random algorithm refers to the use of random algorithms (such as data perturbation, generative adversarial networks (GANs), autoencoders, genetic algorithms, etc.) to adjust or simulate the features of the original samples to generate image samples with defect features. For an illustration, please refer to Figure 6 , which shows a schematic diagram of a second sample image provided by an exemplary embodiment of the present application, such as Figure 6 As shown, a plurality of second sample images are currently generated by a random algorithm, including a second sample defect portion 610 , a second sample defect portion 620 and a second sample defect portion 630 .

[0097] Finally, the sample detection model is trained based on the defect label, the first sample image and the second sample image to obtain the defect detection model. Figure 1 The samples are used as training data and input into the sample defect model for training, so that the model can learn various characteristics and patterns of defects, and finally obtain a defect detection model with defect recognition capability.

[0098] The defect detection method provided in an embodiment of the present application performs defect detection on a detection image using a pre-trained defect detection model to obtain a first defect region in the detection image, generates a pixel comparison map of the first defect region based on the difference between a first pixel value of a pixel point in the first defect region and a second pixel value in a reference region in the detection image, and further determines a second defect region containing a defective portion in the first defect region based on the pixel comparison map as a defect detection result for the detection image. In other words, after performing preliminary defect detection on the detection image using the defect detection model to obtain a preliminary detection result, a pixel comparison map is generated based on the difference between the pixel value in the preliminary detection result and the pixel value used as a reference, further reducing noise data in the first defect region. This allows further defect detection of the first defect region, resulting in a higher accuracy of the final defect detection result.

[0099] This application can be applied to the defect detection of most screen types, such as mobile phone screens, tablet screens, laptop screens, watch screens, car central control screens, etc.

[0100] The present application includes the following beneficial effects: (1) Defect maps are generated using a normal distribution random algorithm and other random algorithms. The generated defects have normally distributed random values ​​in key features such as contrast, shape, length and width, thereby creating a wide variety of defect samples. This innovation effectively solves the problem of insufficient real defect samples in actual production and the impact of too few samples on model training and detection accuracy. It provides a rich and diverse training data for the defect detection model and improves the model's ability to identify different types of defects.

[0101] (2) Traditional algorithms are used to annotate defects in images, replacing the tedious work of manual annotation. This greatly reduces the workload and time cost of annotation, improves the efficiency of the defect detection process, and ensures that image data with annotated information can be provided quickly and accurately for subsequent model training and detection.

[0102] (3) The secondary screening algorithm re-examines and screens the defect detection results obtained by the defect detection model. This process can accurately identify and eliminate misjudged defects, effectively avoiding the over-killing phenomenon that may occur in the defect detection model during the defect detection process, improving the accuracy and reliability of the detection results, and making the final output defect detection results more in line with actual production needs and quality control standards.

[0103] For illustration, please refer to Figure 7 , which shows a schematic diagram of a defect detection device provided by an exemplary embodiment of the present application, wherein the defect detection device may specifically include the following modules: An acquisition module 710 is used to acquire a detection image; a detection module 720 configured to perform defect detection on the detection image using a pre-trained defect detection model to obtain a first defect region corresponding to the detection image, wherein the first defect region includes a region corresponding to a defective portion in the detection image, the defect detection model being a neural network model, and a plurality of first pixels in the first defect region respectively corresponding to first pixel values; The acquisition module 710 is configured to acquire a second pixel value in a reference area in the inspection image, where the reference area is an area corresponding to a specified position of the first defect area, and a plurality of second pixel points in the reference area respectively correspond to candidate pixel values, where the second pixel value is obtained based on a ranking result of the plurality of candidate pixel values; A generating module 730 is configured to generate a pixel comparison map corresponding to the first defect area based on pixel differences between the plurality of first pixel values ​​and the second pixel value; Determination module 740 is used to use the second defect area in the pixel comparison image as the defect detection result corresponding to the detection image when the image parameters of the second defect area are determined to meet the preset defect conditions. The defect detection result is used to indicate that the second defect area is the area corresponding to the defect part in the detection image.

[0104] Optionally, the multiple first pixel values ​​include an i-th first pixel value corresponding to an i-th first pixel point, where i is a positive integer; The generating module 730 is configured to obtain a pixel value difference between the i-th first pixel value and the second pixel value as the i-th pixel difference; and generate the pixel comparison map based on the pixel differences respectively corresponding to the multiple first pixel values.

[0105] Optionally, the detection image is a color image, and the i-th first pixel value includes an i-th first sub-value, an i-th second sub-value, and an i-th third sub-value; The generation module 730 is used to obtain the pixel value difference between the i-th first sub-value and the second pixel value as the i-th first difference; obtain the pixel value difference between the i-th second sub-value and the second pixel value as the i-th second difference; obtain the pixel value difference between the i-th third sub-value and the second pixel value as the i-th third difference; and obtain the i-th pixel difference based on the i-th first difference, the i-th second difference and the i-th third difference.

[0106] Optionally, a generation module 730 is used to obtain a first weight value, a second weight value and a third weight value; obtain the i-th first product result between the first weight value and the i-th first difference value; obtain the i-th second product result between the second weight value and the i-th second difference value; obtain the i-th third product result between the third weight value and the i-th third difference value; obtain the i-th third pixel value corresponding to the i-th first pixel point based on the sum of the i-th first product result, the i-th second product result and the i-th third product result; generate a defect comparison map based on the third pixel values ​​corresponding to the multiple first pixel points respectively; if the image parameters of the second defect area in the defect comparison map are determined to meet the preset defect conditions, the second defect area is used as the defect detection result corresponding to the detection image.

[0107] Optionally, the preset defect condition includes at least one of a contrast threshold, a pixel number threshold, or an aspect ratio threshold; The generation module 730 is used to determine that the second defect area meets the preset defect condition when the contrast of the pixels in the second defect area reaches the contrast threshold; and / or; determine that the second defect area meets the preset defect condition when the number of pixels in the second defect area reaches the pixel number threshold; and / or; determine that the second defect area meets the preset defect condition when the ratio between the area length and the area width of the second defect area reaches the aspect ratio threshold.

[0108] Optionally, the acquisition module 710 is configured to acquire a first sample image, where the first sample image includes a first sample defect portion; Marking the first sample defect portion to obtain a defect label corresponding to the first sample image, where the defect label is used to indicate a position and defect features of the first sample defect portion in the first sample image; generating a first random value based on the defect characteristic; generating a second sample image based on the first random value, wherein the second sample image includes a second sample defect portion, and the second sample defect portion is randomly generated based on the first random value; Gradient training is performed on a sample detection model based on the first sample image, the defect label, and the second sample image to obtain the defect detection model.

[0109] The defect detection device provided in an embodiment of the present application performs defect detection on a detection image using a pre-trained defect detection model to obtain a first defect region in the detection image, generates a pixel comparison map of the first defect region based on the difference between a first pixel value of a pixel point in the first defect region and a second pixel value in a reference region in the detection image, and further determines a second defect region containing a defective portion in the first defect region based on the pixel comparison map as a defect detection result for the detection image. In other words, after performing preliminary defect detection on the detection image using the defect detection model to obtain a preliminary detection result, a pixel comparison map is generated based on the difference between the pixel value in the preliminary detection result and the pixel value used as a reference, further reducing noise data in the first defect region. This allows further defect detection of the first defect region, resulting in a higher accuracy of the final defect detection result.

[0110] See also Figure 8 , shows a schematic diagram of the structure of the computer device provided in the embodiment of the present application. Figure 8 As shown, the computer device 1000 of this embodiment includes: at least one processor 1010 ( Figure 8Only one is shown in the figure) a processor, a memory 1020, and a computer program 1021 stored in the memory 1020 and executable on at least one processor 1010. When the processor 1010 executes the computer program 1021, the steps in the above-mentioned defect detection method embodiment are implemented.

[0111] The computer device 1000 may be a desktop computer, a notebook computer, a PDA, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 1010 and a memory 1020. Those skilled in the art will appreciate that Figure 8 This is merely an example of the computer device 1000 and does not constitute a limitation on the computer device 1000 . The computer device 1000 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the computer device 1000 may also include input and output devices, network access devices, etc.

[0112] The processor 1010 may be a central processing unit (CPU), or may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor or any conventional processor.

[0113] In some embodiments, the memory 1020 may be an internal storage unit of the computer device 1000, such as a hard drive or memory of the computer device 1000. In other embodiments, the memory 1020 may also be an external storage device of the computer device 1000, such as a plug-in hard drive, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. equipped on the computer device 1000. Furthermore, the memory 1020 may include both an internal storage unit of the computer device 1000 and an external storage device. The memory 1020 is used to store an operating system, application programs, a boot loader, data, and other programs, such as the program code of a computer program. The memory 1020 may also be used to temporarily store data that has been output or is about to be output.

[0114] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0115] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

[0116] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0117] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer equipment and methods can be implemented in other ways. For example, the apparatus / computer equipment embodiments described above are merely schematic. For example, the division of modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of the apparatus or unit, which can be electrical, mechanical or other forms.

[0118] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0119] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0120] If the integrated module / unit is implemented as a software functional unit and sold or used as a standalone product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application can implement all or part of the process steps in the above-mentioned method embodiments by using a computer program to instruct the relevant hardware. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. Computer-readable media can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, removable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunications signals, and software distribution media. It should be noted that the content included in computer-readable media can be appropriately increased or decreased based on the requirements of legislation and patent practice in a jurisdiction. For example, in some jurisdictions, based on legislation and patent practice, computer-readable media does not include electrical carrier signals and telecommunications signals.

[0121] The present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiments when executing.

[0122] The above embodiments are intended only to illustrate the technical solutions of the present application and are not intended to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein with equivalents; and such modifications or replacements do not deviate from the spirit and scope of the technical solutions of the various embodiments of the present application and should be included within the scope of protection of the present application.

Claims

1. A defect detection method, characterized in that: The method comprises: Acquire detection images; Performing defect detection on the detection image using a pre-trained defect detection model to obtain a first defect region corresponding to the detection image, wherein the first defect region includes a region corresponding to a defective portion in the detection image, the defect detection model being a neural network model, and a plurality of first pixel points in the first defect region respectively corresponding to first pixel values; Obtaining a second pixel value in a reference area in the inspection image, where the reference area is an area corresponding to a specified position of the first defect area, multiple second pixel points in the reference area respectively correspond to candidate pixel values, and the second pixel value is obtained based on a sorting result of the multiple candidate pixel values; generating a pixel comparison map corresponding to the first defect area based on pixel differences between the plurality of first pixel values ​​and the second pixel value; When the image parameters of the second defect area in the pixel comparison image are determined to meet the preset defect conditions, the second defect area is used as the defect detection result corresponding to the detection image, and the defect detection result is used to indicate that the second defect area is the area corresponding to the defect part in the detection image.

2. The method according to claim 1, characterized in that The multiple first pixel values ​​include an i-th first pixel value corresponding to an i-th first pixel point, where i is a positive integer; The generating a pixel comparison map corresponding to the first defect area based on the pixel differences between the plurality of first pixel values ​​and the second pixel value includes: Obtaining a pixel value difference between the i-th first pixel value and the second pixel value as the i-th pixel difference; The pixel comparison map is generated based on the pixel differences respectively corresponding to the multiple first pixel values.

3. The method according to claim 2, characterized in that The detection image is a color image, and the i-th first pixel value includes the i-th first sub-value, the i-th second sub-value, and the i-th third sub-value; The obtaining, as the i-th pixel difference, a pixel value difference between the i-th first pixel value and the second pixel value includes: Obtaining a pixel value difference between the i-th first sub-value and the second pixel value as an i-th first difference value; Obtaining a pixel value difference between the i-th second sub-value and the second pixel value as an i-th second difference value; Obtaining a pixel value difference between the i-th third sub-value and the second pixel value as an i-th third difference value; The i-th pixel difference is obtained based on the i-th first difference value, the i-th second difference value, and the i-th third difference value.

4. The method according to claim 3, characterized in that After generating the pixel comparison map based on the pixel differences corresponding to the plurality of first pixel values, the method further includes: Obtaining a first weight value, a second weight value, and a third weight value; Obtaining an i-th first product result between the first weight value and the i-th first difference value; Obtaining an i-th second product result between the second weight value and the i-th second difference value; Obtaining an i-th third product result between the third weight value and the i-th third difference value; Obtaining an i-th third pixel value corresponding to the i-th first pixel point based on a sum of the i-th first product result, the i-th second product result, and the i-th third product result; generating a defect comparison map based on the third pixel values ​​respectively corresponding to the plurality of first pixel points; When the image parameters of the second defect area in the pixel comparison image are determined to meet the preset defect condition, taking the second defect area as the defect detection result corresponding to the detection image includes: When the image parameters of the second defect area in the defect comparison image are determined to meet the preset defect conditions, the second defect area is used as the defect detection result corresponding to the detection image.

5. The method according to any one of claims 1 to 4, characterized in that: The preset defect condition includes at least one of a contrast threshold, a pixel number threshold, or an aspect ratio threshold; Before taking the second defect area as the defect detection result corresponding to the detection image, the method further includes: When the contrast of the pixels in the second defect area reaches the contrast threshold, determining that the second defect area meets the preset defect condition; and / or; When the number of pixels in the second defect area reaches the pixel number threshold, determining that the second defect area meets the preset defect condition; and / or; When the ratio between the region length and the region width of the second defect region reaches the aspect ratio threshold, it is determined that the second defect region meets the preset defect condition.

6. The method according to any one of claims 1 to 4, characterized in that: Before performing defect detection on the detection image using a pre-trained defect detection model to obtain a first defect area corresponding to the detection image, the method further includes: Acquire a first sample image, where the first sample image includes a first sample defect portion; Marking the first sample defect portion to obtain a defect label corresponding to the first sample image, where the defect label is used to indicate a position and defect features of the first sample defect portion in the first sample image; generating a first random value based on the defect characteristic; generating a second sample image based on the first random value, wherein the second sample image includes a second defect portion, and the second defect portion is randomly generated based on the first random value; Gradient training is performed on a sample detection model based on the first sample image and the second sample image to obtain the defect detection model.

7. A defect detection device, characterized in that: The device comprises: An acquisition module, used for acquiring a detection image; a detection module, configured to perform defect detection on the detection image using a pre-trained defect detection model to obtain a first defect region corresponding to the detection image, wherein the first defect region includes a region corresponding to a defective portion in the detection image, the defect detection model being a neural network model, and a plurality of first pixel points in the first defect region respectively corresponding to first pixel values; The acquisition module is configured to acquire a second pixel value in a reference area in the inspection image, where the reference area is an area corresponding to a specified position of the first defect area, a plurality of second pixel points in the reference area respectively correspond to candidate pixel values, and the second pixel value is obtained based on a sorting result of the plurality of candidate pixel values; a generating module, configured to generate a pixel comparison map corresponding to the first defect area based on pixel differences between the plurality of first pixel values ​​and the second pixel value; A determination module is used to use the second defect area in the pixel comparison image as the defect detection result corresponding to the detection image when the image parameters of the second defect area are determined to meet the preset defect conditions. The defect detection result is used to indicate that the second defect area is the area corresponding to the defect part in the detection image.

8. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the defect detection method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the defect detection method according to any one of claims 1 to 6 is implemented.

10. A computer program product, characterized in that The invention comprises a computer program, which enables the defect detection method according to any one of claims 1 to 6 to be performed when the computer program is executed.

Citation Information

Patent Citations

  • Defect region detection method and device

    CN106097361A

  • Screen defect detection method and device, equipment and storage medium

    CN113781396A

  • Defect detection method and apparatus, electronic device, storage medium and program product

    WO2025098001A1

  • Defect detection method, defect detection apparatus, and storage medium

    WO2025139026A1

  • Image detection method and apparatus, electronic device, and storage medium

    WO2025139960A1