Defect detection method and device, computer device and computer readable storage medium

By combining dimensionality reduction processing of high-resolution images with coarse and fine detection networks, the problem of high hardware resource requirements in the detection of minute defects in high-resolution images is solved, and low-cost and efficient detection is achieved.

CN123181401APending Publication Date: 2026-11-27SHENZHEN SMARTMORE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611460707.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-18
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies for high-resolution image detection require high hardware resources, making it difficult to achieve efficient identification of minute defects at low cost.

Method used

By performing dimensionality reduction on high-resolution images and using a coarse detection network for preliminary screening across the entire region, high-resolution detailed inspection is performed only on candidate defect areas, reducing redundant calculations in defect-free background areas.

Benefits of technology

While ensuring the accuracy of identifying minute defects, the requirements for hardware performance have been significantly reduced, achieving low-cost, high-resolution image small defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123181401A_ABST
    Figure CN123181401A_ABST
Patent Text Reader

Abstract

The application relates to a defect detection method and device, computer equipment and a computer readable storage medium. The method comprises the following steps: acquiring a first image of a to-be-tested article; the first image is a high-resolution image; performing dimension reduction processing on the first image to obtain a second image; the second image is a low-resolution image; performing defect detection on the second image through a trained rough detection network to obtain a first defect detection result; determining a candidate defect region image in the first image according to the first defect detection result; performing defect detection on the candidate defect region image through a trained fine detection network to obtain a second defect detection result; and determining a target defect detection result corresponding to the to-be-tested article according to the second defect detection result, the first defect detection result and the first image. According to the application, low-cost small defect detection of a high-resolution image can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of defect detection technology, and in particular to a defect detection method, apparatus, computer equipment, and computer-readable storage medium. Background Technology

[0002] With the continuous improvement of precision requirements in industrial manufacturing, surface defect detection has become a core aspect of quality control for products such as PCBs, display panels, semiconductor wafers, and precision structural components. Currently, industrial inspection scenarios commonly employ high-resolution industrial cameras to capture product surface images, with single image resolutions often reaching 4090×3000 pixels or higher. However, the pixel size of real, minute defects is only tens to hundreds of pixels, and the defect area occupies a very small proportion of the entire image. This places higher demands on the detail recognition capabilities and deployment adaptability of defect detection technologies.

[0003] Currently, high-resolution defect detection often uses networks such as HRNet for detection. By maintaining a high-resolution feature path throughout the process, it can mitigate the detail collapse caused by downsampling and achieve image defect recognition. This solution can balance detection accuracy and operating efficiency in conventional resolution scenarios. However, when faced with ultra-high resolution input in industrial scenarios, the peak value of the network memory will increase significantly with the increase of input resolution, which is difficult for edge hardware to handle, and the deployment cost and hardware threshold will increase significantly.

[0004] Therefore, how to achieve small defect detection in high-resolution images at low cost has become an urgent problem to be solved. Summary of the Invention

[0005] Therefore, it is necessary to provide a defect detection method, apparatus, computer equipment, and computer-readable storage medium to address the aforementioned technical problems, which can achieve low-cost detection of small defects in high-resolution images.

[0006] Firstly, this application provides a defect detection method, including: Acquire the first image of the item to be tested; the first image is a high-resolution image. The first image is subjected to dimensionality reduction processing to obtain the second image; the second image is a low-resolution image. The first defect detection result is obtained by performing defect detection on the second image using a trained coarse detection network. Based on the first defect detection result, determine the candidate defect region image in the first image; The candidate defect region image is detected by a trained fine inspection network to obtain a second defect detection result; Based on the second defect detection result, the first defect detection result, and the first image, determine the target defect detection result corresponding to the item to be tested.

[0007] Secondly, this application provides a defect detection device, comprising: The acquisition module is used to acquire a first image of the item to be tested; the first image is a high-resolution image. The dimension reduction module is used to perform dimension reduction processing on the first image to obtain the second image; the second image is a low-resolution image. The first defect detection module is used to perform defect detection on the second image through a trained coarse detection network to obtain a first defect detection result; and to determine candidate defect region images in the first image based on the first defect detection result. The second defect detection module is used to perform defect detection on the candidate defect region image through a trained fine detection network to obtain the second defect detection result; based on the second defect detection result, the first defect detection result and the first image, the target defect detection result corresponding to the item to be tested is determined.

[0008] Thirdly, this application provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in the method described above.

[0009] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-described method.

[0010] Fifthly, this application provides a computer program product comprising a computer program that, when executed by a processor, implements the steps of the method described above.

[0011] The aforementioned defect detection method, apparatus, computer equipment, and computer-readable storage medium reduce the dimensionality of a high-resolution first image to obtain a low-resolution second image. A coarse detection network is then used to perform a preliminary global screening, eliminating the need for complete inference on the entire high-resolution image and significantly reducing the computational load of global inference. Next, only high-resolution sub-images (i.e., candidate defect region images) are extracted from the candidate defect regions obtained from the coarse detection and fed into a fine detection network for refined identification. This avoids redundant high-precision calculations on defect-free background regions. While ensuring the accuracy of identifying minute defects, this method effectively reduces the requirements for hardware performance and enables low-cost detection of small defects in high-resolution images. Attached Figure Description

[0012] Figure 1 An application environment diagram of a defect detection method provided in this application embodiment; Figure 2 A flowchart illustrating a defect detection method provided in an embodiment of this application; Figure 3A schematic diagram of the composition of a coarse detection network provided in an embodiment of this application; Figure 4 A schematic diagram of the detection process of a defect detection method provided in an embodiment of this application; Figure 5 A structural block diagram of a defect detection device provided in an embodiment of this application; Figure 6 An internal structural diagram of a computer device provided in an embodiment of this application; Figure 7 An internal structural diagram of another computer device provided in an embodiment of this application; Figure 8 This is an internal structural diagram of a computer-readable storage medium provided in an embodiment of this application. Detailed Implementation

[0013] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0014] The following explains some of the technical terms or phrases used in this application: Real-time object detection backbone network: refers to the basic object detection network designed for edge devices, represented by YOLO, RT-DETR, D-FINE, etc., which balances inference speed and detection accuracy, and is used to complete the extraction, localization and classification of object features in images.

[0015] Mirror padding: an image boundary expansion method that uses the edge pixels of the image as the axis of symmetry to mirror and copy the edge pixels to fill the empty areas outside the image, maintaining texture continuity and avoiding the introduction of false pixels that interfere with defect identification.

[0016] TensorRT Inference Engine: A deep learning inference acceleration tool that optimizes neural network models by performing layer fusion, precision quantization, and other optimizations, accelerating forward inference of models on edge devices and reducing latency.

[0017] Kernel cache and video memory buffer: Pre-allocated and reused memory space for computing core cache and image data storage during the model inference stage, avoiding repeated creation and release of storage resources and reducing memory scheduling overhead.

[0018] The defect detection method provided in this application embodiment can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a communication network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located in the cloud or on other network servers. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.

[0019] It should be explained that the terminal 102 or the server 104 can execute any of the implementation methods described in the defect detection method provided in the embodiments of this application, and will not be repeated here.

[0020] The computer device described in the embodiments of this application may include at least one of terminal 102 or server 104.

[0021] Please see Figure 2 This application provides a flowchart of a defect detection method, which includes the following steps: S101. Obtain the first image of the object to be tested; the first image is a high-resolution image.

[0022] The items to be tested are products that require surface defect inspection, such as PCBs, display panels, semiconductor wafers, aircraft engine blades, and precision structural components.

[0023] Specifically, a high-resolution image acquisition device can be used to acquire an image of the object under test, resulting in a high-resolution first image X_orig. For example, the size of the first image X_orig can be 4090×3000, 8192×4096, or other high-resolution specifications. The high-resolution image acquisition device can include any of the following: industrial camera, line scan camera, area array imager, etc.

[0024] S102. Perform dimensionality reduction processing on the first image to obtain the second image; the second image is a low-resolution image.

[0025] Specifically, a preset dimensionality reduction method can be used to process the first image to obtain a low-resolution second image X_low. For example, the size of the second image X_low can be 640×640, 960×960, or 1280×1280. The preset dimensionality reduction method can include any of the following: proportional scaling, interpolation method (e.g., bilinear interpolation method, nearest neighbor interpolation method), etc.

[0026] In addition, during the dimensionality reduction process, the image scaling ratio, fill offset, and original image boundary information are retained simultaneously, providing a basis for subsequent mapping of the coarse and fine detection box coordinates back to the coordinate system of the original image (i.e., the first image).

[0027] S103. Perform defect detection on the second image using the trained coarse detection network to obtain the first defect detection result.

[0028] Please see Figure 3 , Figure 3 This is a schematic diagram illustrating the composition of a coarse detection network provided in an embodiment of this application. The trained coarse detection network includes: an uncertainty detection head and a first detection network; the first defect detection result includes: *a* coarse detection boxes, *a* category confidence scores, and *a* uncertainty parameters; where *a* is a positive integer; the trained coarse detection network is used to perform defect detection on a second image to obtain the first defect detection result, which includes: S11. Perform coarse detection on the second image using the first detection network to obtain first defect detection data; the first defect detection data includes: a coarse detection boxes and a class confidence scores; each coarse detection box corresponds to a class confidence score; S12. Using the uncertainty detection head, determine the a uncertainty parameters corresponding to the a coarse detection boxes respectively.

[0029] The first detection network can be YOLO26-N, RF-DETR-Nano, RT-DETR, D-FINE, or other real-time object detection backbone networks. It is used to perform object detection on the low-resolution second image and output coarse detection boxes and category confidence scores for candidate defects. The uncertainty detection head is a branch prediction module connected in parallel or cascade with the first detection network. It performs calculations based on the image features extracted by the first detection network and is used to predict the uncertainty parameter σ corresponding to the regression of each coarse detection box position. i .

[0030] Specifically, the second image can be input into the first detection network. The first detection network extracts image features and performs defect target recognition, outputting the coarse detection box Bi and category confidence pi for each candidate defect i identified by the network. All candidate defects are initially screened using a coarse detection candidate threshold, and a candidate defects with confidence greater than the coarse detection candidate threshold are selected. Thus, a coarse detection boxes and corresponding a category confidence scores are obtained. The coarse detection candidate threshold is a preset low value used to retain potential defect candidates with low confidence for subsequent calculation of trigger scores. The coarse detection candidate threshold can be 0.15. i is an integer greater than or equal to 1 and less than or equal to a. The coarse detection box is used to represent the defect location range. The category confidence score is used to represent the degree of confidence that the corresponding coarse detection box belongs to the corresponding defect category.

[0031] In some embodiments, the Top-K candidate defects method can also be used, selecting the K candidate defects with the highest confidence ranking from all candidate defects output by the first detection network as a candidate defects.

[0032] Then, by reusing the image features extracted by the first detection network through the uncertainty detection head, the variable v is predicted. i Then by v i Restored to σ i , where v i =log(σ i ²); σ i =exp(v i / 2); v i σ is an intermediate variable output by the uncertainty detection head. i Let be the positioning uncertainty vector (i.e. uncertainty parameter) corresponding to the i-th coarse detection box, which represents the degree of uncertainty of the coarse detection network in predicting the location of the defect boundary.

[0033] In this way, the first detection network completes the localization and classification of defect candidate targets, and the uncertainty detection head simultaneously outputs the localization uncertainty parameters; it can quantify the localization reliability of the coarse inspection results, provide a basis for subsequent adaptive cropping of candidate regions, distinguish between small defects with clear boundaries and those with blurred boundaries, and help improve the rationality of the selection of fine inspection regions.

[0034] S104. Based on the first defect detection result, determine the candidate defect region image in the first image.

[0035] In some embodiments, the candidate defect region image includes b defect region images; b is a natural number less than or equal to a; determining the candidate defect region image in the first image based on the first defect detection result includes: S21. Based on the first preset calculation formula, a category confidence levels, and a uncertainty parameters, determine a trigger scores; S22. Determine b target trigger scores that are greater than the preset trigger score from among a trigger scores; S23. Determine b coarse detection frames that correspond to b target trigger scores in a coarse detection frames; S24. Based on the b coarse inspection boxes and the first image, determine b cropping region images; S25. Normalize the size of the b cropped region images to obtain b defect region images.

[0036] The first preset calculation formula and the preset trigger score can both be preset in advance or left as default.

[0037] Specifically, the first preset calculation formula can be: ; Where Ui represents the i-th trigger score; α represents the preset first weight coefficient, used to balance the proportions of the confidence term and the uncertainty term; p i σ represents the confidence level of the i-th category; i Denotes the i-th uncertainty parameter; ||σ i ||2 represents σ i The L2 norm characterizes the overall positioning uncertainty of the coarse detection box; ε represents the mean of the L2 norm of all candidate boxes in the current image; ε is a very small constant to prevent the denominator from being 0; by substituting the confidence score of each of the a category confidence scores and its corresponding uncertainty parameter into the first preset calculation formula, a trigger scores are obtained.

[0038] In some embodiments, if the number of candidate boxes in the current image is 0, the fine inspection triggering logic is not executed, and the output of the coarse inspection network is directly used as the target defect detection result.

[0039] In some embodiments, if the number of candidate boxes in the current image is 1, the L2 norm of the unique candidate box itself can be directly used as the parameter. Or, you can also Set to the default value.

[0040] In some embodiments, the weight coefficient α ranges from 0 to 1; for example, α can be 0.5, with two features fused with equal weight; of course, α can also take other values. When α is biased towards 1, the algorithm triggers detailed inspection more based on confidence; when α is biased towards 0, it triggers detailed inspection more based on the uncertainty of positioning.

[0041] Next, we can determine b target trigger scores that are greater than the preset trigger score among the a trigger scores. The preset trigger score τ can be determined based on the validation set calibration. For example, τ can be set to 0.45.

[0042] Then, b coarse detection boxes corresponding to b target trigger scores can be determined from a coarse detection boxes. Specifically, the b category confidence scores corresponding to the b target trigger scores in the a category confidence scores can be obtained, and the b coarse detection boxes corresponding to these b category confidence scores can be determined. Next, b cropped region images can be determined based on the b coarse detection boxes and the first image. Finally, the size of the b cropped region images can be normalized to obtain b defect region images. Specifically, the b cropped region images are scaled to a uniform preset size H_f×W_f. For example, bilinear interpolation can be used to complete the scaling. If the cropped region exceeds the boundary of the original image (i.e., the first image), the image is pre-filled with mirror fill or constant fill to obtain the b defect region images.

[0043] It should be explained that during the size normalization process, the scaling ratio and coordinate offset information are saved simultaneously for use in the inverse mapping of the fine inspection box coordinates.

[0044] In this way, the trigger score is calculated by class confidence and uncertainty parameters, and the coarse detection boxes that need to be finely examined are adaptively selected based on the trigger score. Only the selected candidate regions are cropped from the original image and normalized before being sent to the fine detection network. There is no need to perform fine reasoning on the entire high-resolution image, avoiding redundant calculations in a large number of defect-free background areas. While ensuring the accuracy of detecting minor defects, resource consumption is effectively reduced.

[0045] In some embodiments, determining b cropping region images based on b coarse detection boxes and a first image includes: S31. Obtain the first coarse detection box and its corresponding first uncertainty parameter; the first coarse detection box is any one of the b coarse detection boxes; S32. Determine the center coordinates, width, and height of the corresponding region of the first coarse detection box in the first image, and obtain the first center coordinates, the width of the first coarse detection box, and the height of the first coarse detection box; S33. Determine the first cutting radius based on the second preset calculation formula, the width of the first coarse inspection frame, the height of the first coarse inspection frame, the first uncertainty parameter, and the preset minimum cutting radius; S34. Based on the first cropping radius and the first center coordinates, crop the first image to obtain the cropping region image corresponding to the first coarse detection box.

[0046] The second preset calculation formula and the preset minimum cutting radius can both be preset in advance or left as default.

[0047] Specifically, first, the second center coordinates of the first coarse detection box in the second image are obtained. Based on the image scaling ratio, fill offset, and original image boundary information during the dimensionality reduction process, the second center coordinates are mapped to the coordinate system of the original image (i.e., the first image) to obtain the first center coordinates. Similarly, based on the aforementioned image scaling ratio and fill offset, the width and height of the first coarse detection box are calculated using coordinate system mapping to obtain the width and height of the first coarse detection box in the first image. An example is provided below: Assume the size of the first image (high resolution) is 8192×4096; The second image size is obtained by dimensionality reduction and scaling: 1280×1280. The horizontal scaling ratio is scale=1280 / 8192=0.15625. After scaling the image along its long side, vertical padding exists both vertically and vertically; the corresponding vertical padding offset is recorded.

[0048] Assume the second center coordinates of the first coarse detection box in the second image are: (x_low=640, y_low=500).

[0049] Inverse mapping calculation: The x-coordinate of the center of the original image is x_orig = x_low / scale; The ordinate needs to be adjusted by removing the fill offset and then divided by the scaling factor to obtain the first center coordinates (x_orig, y_orig), which are the coordinates of the center point of the first coarse detection box in the first image.

[0050] It should be explained that if there is no padding offset in the dimensionality reduction process, the coordinate mapping can be completed solely based on the scaling ratio.

[0051] Then, based on the second preset calculation formula, the first uncertainty parameter, and the preset minimum cutting radius, the first cutting radius is determined, wherein the second preset calculation formula can be: Pi = max(r_min, β × max(wi) orig ,hi orig ),γ×||σ i ||2) Where Pi represents the clipping radius of the i-th coarse detection box; r_min represents the preset minimum clipping radius; β represents the preset second weighting coefficient; γ represents the preset third weighting coefficient; wi orig Hi represents the width of the coarse detection box mapped from the i-th coarse detection box to the first image. orig This represents the height of the coarse detection box mapped to the first image by the i-th coarse detection box. Then, the first uncertainty parameter, the preset minimum cropping radius, the width of the first coarse detection box, and the height of the first coarse detection box can be substituted into the second preset calculation formula to calculate the first cropping radius.

[0052] In some embodiments, the second weighting coefficient β can be 1.5, which is used to control the influence of the size of the coarse inspection frame itself on the cutting radius. The larger β is, the larger the basic cutting area is allocated for large-sized defects.

[0053] In some embodiments, the third weighting coefficient γ can be 1, which is used to control the extent to which the positioning uncertainty expands the clipping radius. The higher the uncertainty of the coarse detection positioning, the larger the value of γ, and the larger the clipping radius becomes, thus obtaining more surrounding context information.

[0054] Finally, the first image can be cropped based on the first cropping radius and the first center coordinates to obtain the cropping region image corresponding to the first coarse detection box.

[0055] In this way, the cropping center is obtained by mapping the center coordinates of the coarse detection box on the low-resolution image back to the original image, and the cropping radius is adaptively solved by combining the minimum cropping radius, the size of the coarse detection box and the positioning uncertainty, thereby completing the cropping of the original image region. This ensures that the cropping region can completely cover the defect subject and has basic context, and can also automatically expand the sampling range for defects with ambiguous positioning and difficult boundary determination, effectively avoiding the loss of context for minor defects.

[0056] In some embodiments, cropping the first image based on a first cropping radius and a first center coordinate to obtain a cropping region image corresponding to a first coarse detection box includes: S41. Determine the first cutting area based on the first cutting radius and the first center coordinates; S42. When the first cropping region does not exceed the image boundary of the first image, crop the first image according to the first cropping region to obtain the cropping region image corresponding to the first coarse detection box; or... When the first cropping region exceeds the image boundary of the first image, the first image is cropped according to the preset cropping method and the first cropping region to obtain the cropping region image corresponding to the first coarse check box; the preset cropping method is used to process the out-of-bounds region when the cropping region exceeds the image boundary so that the cropped region image obtained meets the preset cropping requirements.

[0057] The preset cropping method and preset cropping requirements can be preset in advance or left as default. A preset cropping requirement could be that the cropped area image has no pixel gaps or missing pixels.

[0058] Specifically, the first center coordinates are used as the center point of the region, and a square range is defined by the first clipping radius to generate the corresponding first clipping region.

[0059] It should be explained that the first clipping area is not limited to a square; it can also be a circle, a regular polygon, or other shapes, and can be flexibly selected according to the shape of the workpiece to be tested and the defect characteristics. Among them, the square clipping area has simple pixel access logic and lower computational overhead, making it more suitable for real-time inference scenarios of edge devices.

[0060] Next, the positional relationship between the first cropping region and the boundary of the first image can be verified. When the first cropping region does not exceed the image boundary of the first image, the first image is cropped according to the first cropping region to obtain the cropping region image corresponding to the first coarse detection box. Specifically, the pixel content corresponding to the first cropping region in the first image can be directly extracted to obtain the cropping region image corresponding to the first coarse detection box. Alternatively, when the first cropping region exceeds the image boundary of the first image, the first image is cropped according to a preset cropping method and the first cropping region to obtain the cropping region image corresponding to the first coarse detection box. The preset cropping method includes any of the following: boundary cropping, mirror padding, constant padding, etc.

[0061] In some embodiments, if the preset cropping method is boundary cropping, an intersection operation is performed on the first cropping region and the boundary of the first image to remove the range exceeding the image boundary, retaining only the valid pixel region inside the first image as the final cropped image. This method requires no additional pixel padding and has minimal computational overhead, but the size of the cropped sub-image will change. It can be subsequently scaled to a fixed size through a normalization step to adapt to the fine detection network input.

[0062] In some embodiments, if the preset cropping method is mirror padding, the edge pixels of the image are mirrored and copied in reverse with the first image edge as the axis of symmetry to fill in the missing pixels in the first cropping area that extend beyond the original image boundary, forming a cropping area image of full size. This method can simulate continuous surface textures, avoids the artificial introduction of abnormal pixels, and is suitable for workpiece inspection scenarios with minute defects and continuous textures.

[0063] In some embodiments, if the preset cropping method is constant padding, a fixed pixel constant (e.g., grayscale value 128) is selected to fill the empty positions of the first cropping region that exceed the boundary of the first image, thereby obtaining a cropped image of full size. This method is logically simple and has a fast computation speed, making it suitable for low-latency inference scenarios on edge devices; constant pixels do not introduce false textures and will not interfere with defect recognition.

[0064] In this way, by directly cropping the image when the cropping area does not exceed the original image boundary, and using multiple filling strategies to complete the image when the cropping area exceeds the original image boundary, a complete cropped sub-image can be stably output, ensuring that subsequent size normalization is executed smoothly and avoiding the impact of missing boundary pixels on the fine inspection network's ability to identify minor defects.

[0065] S105. Defect detection is performed on the candidate defect region image using the trained fine inspection network to obtain the second defect detection result.

[0066] In some embodiments, a second defect detection result is obtained by performing defect detection on the candidate defect region image using a trained fine-detection network, including: S51. Defect detection is performed on b defect region images using the trained fine detection network to obtain b defect detection results; each defect detection result includes a set of fine detection boxes and its corresponding category confidence set. S52. Determine the b coordinate transformation parameters corresponding to the b defect region images; S53. Based on b coordinate transformation parameters, determine the coordinate set corresponding to each fine inspection box in the first image in the b defect detection results, and obtain b coordinate sets; S54. Based on b coordinate sets and b defect detection results, determine the second defect detection result.

[0067] Among them, the fine-detection network can be a target detection network used for high-resolution local sub-image defect fine-grained identification. It can fully extract the subtle texture features of the sub-image and output accurate fine-detection boxes and class confidence scores; for example, lightweight detection models such as YOLO-Nano, RT-DETR-Nano, and D-FINE-Nano.

[0068] Specifically, b defect region images are input into the trained fine inspection network. The fine inspection network independently performs forward inference on each image, extracts local features of the image, completes defect localization and classification, and outputs b defect detection results.

[0069] In some embodiments, all trigger area images within a single image that meet the fine inspection triggering conditions are uniformly resized and normalized to a fixed size; then, the normalized sub-images (i.e., b defect area images) are batched to form an inference batch, which is then sent to the fine inspection network for batch inference. Each sub-image within the batch is calculated separately to obtain b defect detection results. This improves inference efficiency.

[0070] It should be noted that each set of detail boxes can be empty, or it can include at least one detail box B. i f Correspondingly, the set of category confidence scores can be empty, or it can include at least one category confidence score p. i f .

[0071] It should be explained that the fine inspection network does not reuse the low-resolution features extracted by the coarse inspection network, but instead re-extracts and processes features for high-resolution defect area images. During the deployment phase, the fine inspection network and the coarse inspection network can be two independent models, each building its own inference engine. They can reuse the inference runtime, memory pool, and GPU memory buffer to avoid redundant resource allocation and reduce resource overhead on edge devices.

[0072] Then, we can determine the b coordinate transformation parameters corresponding to the b defect region images. Specifically, each coordinate transformation parameter includes the cropping start coordinates, scaling ratio, left padding offset, and upper padding offset. We can obtain the coordinate information of each image in the b defect region images during normalization, and obtain the corresponding cropping offset and scaling ratio, thus obtaining b cropping offsets and b scaling ratios, which are also the b coordinate transformation parameters. Next, based on the b coordinate transformation parameters, we can determine the coordinate set corresponding to each fine detection box in the first image in the b defect detection results, obtaining b coordinate sets. Specifically, for each fine detection box, we can first obtain the first coordinate set of the fine detection box in its corresponding defect region image, and then perform inverse transformation on the first coordinate set according to its corresponding coordinate transformation parameters: First, perform the inverse scaling operation to restore the first coordinate set in the normalized sub-image (i.e., the defect area image) to the coordinate system of the unscaled cropped area image, thus obtaining the second coordinate set; Secondly, the coordinates in the second coordinate set are corrected based on the left offset and the upper offset of the padding, and the third coordinate set of the fine inspection box in the cropping area in the first image is calculated. Finally, using the center coordinates of the cropped area as a reference, the third coordinate set is mapped to the first image coordinate system to obtain the coordinate set corresponding to the fine detection box on the first image. It should be noted that the coordinates of the four vertices of the fine detection box follow the same conversion rule. The coordinate conversion formula for a single vertex is as follows: x_orig=x_f / s_f-pad_left+x_crop; y_orig=y_f / s_f-pad_top+y_crop; Where x_f and y_f are the horizontal and vertical coordinates of the vertex of the fine inspection box in the defect region image, respectively; x_orig and y_orig are the horizontal and vertical coordinates of the vertex after it is mapped to the first image, respectively; s_f is the scaling ratio of the defect region image; pad_left is the left offset of the padding; pad_top is the top offset of the padding; and x_crop and y_crop are the horizontal and vertical coordinates of the cropping starting point of the cropping region in the first image, respectively.

[0073] Repeating this process b times yields b coordinate sets. Then, the second defect detection result can be directly composed of the b coordinate sets and the b defect detection results, or the b coordinate sets can be added to the corresponding defect detection results in the b defect detection results to obtain the second defect detection result.

[0074] In this way, the fine-detection network performs inference on the defect area image, extracts subtle textures, and outputs high-precision fine-detection bounding boxes and category confidence scores. Then, coordinate transformation parameters are used to perform inverse coordinate mapping of the fine-detection bounding boxes, uniformly transforming them to the original image coordinate system, and fusing them to obtain the second defect detection result. This approach fully leverages the detail advantages of high-resolution images, corrects localization errors in the coarse detection stage, and achieves unified aggregation of detection results in the original image coordinate system, effectively improving the accuracy of localization and classification of minute defects.

[0075] S106. Based on the second defect detection result, the first defect detection result, and the first image, determine the target defect detection result corresponding to the item to be tested.

[0076] Specifically, the confidence scores of each of the *a* categories in the first defect detection result can be compared with a preset confidence threshold to identify all category confidence scores greater than the preset threshold, resulting in *c* category confidence scores; where *c* is a positive integer less than or equal to *a*. The *c* coarse detection boxes corresponding to the *a* category confidence scores are then determined. The *c* category confidence scores, *c* coarse detection boxes, and the fine detection boxes and category confidence scores in the second defect detection result are deduplicated to obtain the target defect detection result. Specifically, the core deduplication strategy is: if the regions of coarse and fine detection boxes overlap, priority is given to retaining the category confidence scores of the fine detection boxes and discarding the corresponding coarse detection boxes. The specific deduplication process is as follows: First, all coarse and fine check boxes are placed into the same candidate box set; Secondly, calculate the intersection-over-union (IoU) ratio between candidate boxes to determine whether the candidate boxes point to the same defect; Next, a preset deduplication strategy is used to filter redundant boxes, and the final target defect detection results are output.

[0077] The preset deduplication strategy can include any of the following: Non-maximum suppression (NMS), Soft non-maximum suppression (Soft-NMS), Weighted box fusion (WBF), etc.

[0078] In some embodiments, the deduplication process may also be as follows: For coarse check boxes that do not trigger detailed inspection, the coarse check box and its category confidence are directly retained and used in subsequent result processing. For candidate regions that trigger detailed inspection and output valid detailed inspection boxes, the detailed inspection boxes and their category confidence scores are used first to replace the corresponding coarse inspection boxes. For candidate regions that trigger fine inspection but fail to output valid fine inspection boxes, you can choose to roll back and retain the original coarse inspection box or discard the candidate region, depending on the actual situation. Then, perform a deduplication operation on all boxes to be processed. Any one of NMS, Soft-NMS or WBF can be used to remove duplicate detection boxes, and finally obtain the target defect detection result.

[0079] In some embodiments, the preset deduplication strategy can be NMS, with an IoU threshold set (e.g., 0.5). All candidate boxes are sorted from highest to lowest confidence; fine-grained detection results are retained first. The detection box with the highest confidence is selected, and the remaining candidate boxes are traversed. When the IoU of two boxes exceeds the IoU threshold, they are determined to be the same defect. If a pair of overlapping boxes are a coarse detection box and a fine detection box respectively, the coarse detection box is directly removed; if they are both coarse detection boxes or both are fine detection boxes, the box with the lower confidence is removed. This process is repeated until the traversal is complete, and the target defect detection result is obtained. For example, assuming there is a set of overlapping candidate boxes, the class confidence of the coarse detection box is 0.72, the class confidence of the fine detection box is 0.89, and the IoU = 0.6 > 0.5, then the fine detection box is retained first, and the coarse detection box is removed.

[0080] In some embodiments, the preset deduplication strategy can be Soft-NMS, which sets an IoU threshold and does not directly delete overlapping candidate boxes, but instead reduces the class confidence of the overlapping boxes. When a coarse detection box overlaps with a fine detection box, the class confidence of the fine detection box remains unchanged, while the class confidence of the coarse detection box is attenuated. The coarse detection box is removed when its class confidence falls below a preset confidence threshold. This method does not directly delete candidate targets and is suitable for scenarios with densely distributed small defects, reducing the probability of missed detections. For example, suppose a coarse detection box has a confidence of 0.68 and overlaps with a fine detection box. The confidence of the coarse detection box is attenuated; if the attenuated confidence falls below a preset confidence threshold, the coarse detection box is removed, and the fine detection results are retained.

[0081] In some embodiments, the preset deduplication strategy can be WBF (Wide-Bounds Field), which collects a set of overlapping candidate boxes and calculates a new fused detection box and a fusion confidence score by weighting the coordinates and category confidence scores of all boxes. When both coarse and fine detection boxes exist in the overlapping area, the fine detection box with the higher confidence score is given greater weight. Finally, the fused box is used as the output. This method further optimizes the positioning accuracy and is suitable for detection scenarios with extremely high positioning accuracy requirements, such as semiconductor wafers and display panels.

[0082] It should be noted that the preset reliability threshold can be pre-set or set to the default value. The preset reliability threshold can be 0.8.

[0083] Please see Figure 4 , Figure 4 The diagram below illustrates the detection process of a defect detection method provided in this application embodiment; the specific detection process is as follows: First, the original high-resolution image X_orig is acquired. Then, downsampling is performed on X_orig to obtain a low-resolution image X_low. Next, the low-resolution image X_low is input into a trained coarse detection network for inference. The coarse detection network outputs the coarse detection box Bi, category confidence pi, and localization variance σ corresponding to each candidate defect.i (i.e., uncertainty parameters). Next, based on the category confidence pi and location variance σ of the candidate defect... i Calculate the trigger score Ui and the adaptive clipping radius Pi to complete the candidate defect branch determination: For candidate defects that do not meet the fine-check triggering conditions (i.e., Ui≤τ, and pi>δ; where δ represents the preset confidence threshold), they are marked as high-confidence coarse check boxes that have not been triggered and are directly retained in the subsequent result fusion stage; For candidate defects that meet the fine-detection trigger condition (i.e., Ui > τ), variance-aware cropping is performed on the original high-resolution image X_orig based on the cropping radius Pi, resulting in a cropped sub-image Xi. HR Next, cut out the sub-image Xi. HR The data is fed into a trained fine-detection network for inference, and the fine-detection bounding box Bi in the subgraph coordinate system is output. f confidence level pi of detailed examination category f Then, based on the coordinate transformation parameters recorded during cropping, the fine inspection box undergoes coordinate inversion processing, transforming it from the cropped sub-image coordinate system to the original image coordinate system.

[0084] Next, the two types of detection results are summarized: detailed detection results mapped to the original image coordinate system and high-confidence coarse detection boxes that did not trigger detailed detection. All candidate boxes are fused and deduplicated. Overlapping areas are given priority to the detailed detection results with higher accuracy. Redundant detection boxes are removed to generate the final defect list and complete the defect detection. If there are no candidate defects that meet the detailed detection triggering conditions (i.e., Ui > τ), the high-confidence coarse detection boxes that did not trigger the detailed detection can be directly used as the final defect detection results.

[0085] In some embodiments, the above method further includes: S61. Obtain the initial coarse inspection network, the initial fine inspection network, the first training dataset, and the second training dataset; the first training dataset includes multiple high-resolution images of objects and their corresponding defect annotation information; the second training dataset is obtained by dimensionality reduction processing of the images in the first training dataset. S62. Train the initial coarse detection network using the second training dataset to obtain the first coarse detection network; S63. Train the initial fine-detection network using the first training dataset to obtain the first fine-detection network; S64. Based on the preset joint loss function, the first coarse detection network and the first fine detection network are jointly trained to obtain the trained coarse detection network and the trained fine detection network.

[0086] The initial coarse detection network includes: a coarse detection backbone network, a classification branch, a regression branch, and a variance branch; the variance branch is the aforementioned uncertainty detection head; the coarse detection backbone network, the classification branch, and the regression branch together form the first detection network; specifically: The coarse detection backbone network serves as the feature extraction module of the first detection network. It extracts multi-scale image features from the input low-resolution image and outputs a feature map, providing a feature basis for subsequent classification, bounding box regression, and uncertainty estimation. The classification branch is used to predict the defect category based on the feature map and outputs the probability that the candidate region belongs to each type of defect (i.e., the category confidence), which is used to make a preliminary judgment on whether the candidate region has a defect and the type of defect.

[0087] The regression branch is used to predict the position offset of candidate defect boxes based on the feature map, complete the adjustment of the defect bounding box coordinates, output coarse detection boxes, and achieve preliminary positioning of the defect target.

[0088] The variance branch is used to represent the variance of the bounding box (i.e., coarse detection box) regression based on the feature map, quantifying the uncertainty of the coarse detection box localization; the larger the variance, the lower the reliability of the current candidate box boundary localization. This variance index serves as a trigger condition to screen candidate defects that need to be sent to the fine detection network for further refined detection.

[0089] Specifically, the first training dataset consists of original high-resolution object images and defect annotation information (including defect annotations, product models, resolution information, etc.), serving as the original sample source; the second training dataset consists of low-resolution image samples, generated by performing dimensionality reduction processing on the high-resolution images in the first training dataset, with the corresponding defect annotation coordinates synchronously converted according to the scaling ratio, eliminating the need for re-annotation; then, model training is performed, as follows: The first step, the independent training phase for coarse detection: The initial coarse detection network is trained using the second training dataset. During the training process, the network parameters of the coarse detection backbone network, classification branch, regression branch, and variance branch are optimized simultaneously. The loss function of the initial coarse detection network includes classification loss, bounding box regression loss, and uncertainty regression loss. The global coarse detection model converges, and the first coarse detection network is obtained. The goal of this phase is to enable the coarse detection network to perform preliminary defect localization and category determination on low-resolution images, and output the localization variance to represent uncertainty.

[0090] The second step, the fine-check independent training phase, involves training the initial fine-check network using the first training dataset. The training samples contain two types of cropped sub-images: one is a local high-resolution region cropped from the ground-truth area of ​​the defect annotation information; the other simulates the inference process, based on the coarse-check bounding boxes and variance σ output by the first coarse-check network. iThe trigger score Ui is calculated. For coarse detection boxes with Ui greater than τ, a variance-aware cropping strategy is used to crop the corresponding local cropping region from the original image. The fine detection network's feature extraction capability is optimized based on high-resolution local images. It learns the texture features of minute defects and outputs accurate fine detection boxes and class confidence scores, thus training the first fine detection network.

[0091] The third step, the joint calibration training phase, involves joint training using a pre-defined joint loss function. This function includes a coarse-to-fine consistency loss in addition to the basic detection loss. The inference process simulates the actual deployment: the coarse detection network outputs candidate boxes from a low-resolution image, which are then cropped using variance-aware cropping to obtain a high-resolution sub-image, which is then fed into the fine detection network. The fine detection boxes are then inversely mapped to the original image coordinate system. The coarse-to-fine consistency loss constrains the coarse detection result corresponding to the same defect to be closer to the mapped fine detection box in the original image space, aligning the localization results of the two levels of detection. After joint calibration, the trained coarse detection network and the trained fine detection network are finally obtained.

[0092] In some embodiments, the coarse detection path uses INT8 precision inference, while the fine detection path uses FP16 precision inference. The coarse detection path aims for high throughput and low inference latency. Considering the small dynamic range of the variance branch output values, to avoid small-value variance distortion caused by quantization, the variance branch can retain FP16 precision or adopt a finer-grained quantization strategy. The fine detection path maintains FP16 precision to preserve the texture features of minute defects to the greatest extent, ensuring the accuracy of fine detection recognition. In this way, through differentiated precision configuration, while ensuring the high-speed screening capability of coarse detection, it avoids fine detection triggering logic abnormalities caused by quantization distortion of positioning uncertainty values. The fine detection network maintains half precision, balancing the computing power constraints of edge devices and the accuracy of minute defect detection.

[0093] Edge devices may include at least one of the following: Jetson Orin, industrial control computer GPU, etc.

[0094] It should be explained that after the joint calibration training phase, a fourth step can be included: validation set calibration. This involves obtaining a validation dataset, performing inference processes on the trained coarse detection network and the trained fine detection network, and simulating the complete inference process in an industrial setting using the validation dataset. Multiple hyperparameter combinations are iterated through, and parameters such as coefficients α, τ, β, γ, and r_min are optimally determined based on detection accuracy and inference time metrics. A reasonable trigger rate range for the fine detection box is also determined, completing the network parameter configuration and obtaining deployable coarse and fine detection networks.

[0095] The pre-defined joint loss function can be specifically as follows: ; in, Indicates the predefined joint loss function; This represents the classification loss of the coarse inspection network, used to optimize the defect category prediction accuracy of the coarse inspection network; This represents the regression loss of the coarse detection network, used to optimize coarse detection box localization and variance prediction. This represents the classification loss of the fine inspection network, used to optimize the defect category identification of the fine inspection network. This represents the regression loss of the fine-check network, used to optimize the fine-tuning of the fine-check bounding box localization. This represents the preset consistency loss weighting coefficient, used to balance the magnitude of the basic detection loss and the consistency loss; This represents the coarse-to-fine consistency loss. A preset joint loss function is used to simultaneously optimize the basic detection capabilities of the coarse and fine detection networks, and introduce consistency constraints to simultaneously achieve accurate classification, accurate localization, and spatial alignment of the two-level detection results.

[0096] In some embodiments, coarseness consistency loss Specifically as follows: ; in, Let i represent the set of candidate defects that trigger detailed inspection, where i represents the i-th candidate defect that triggers detailed inspection. Mapped to the original image coordinate system, the i-th coarse detection box output by the coarse detection network; Mapped to the original image coordinate system, the i-th detailed detection box output by the detailed detection network; express and The crossover ratio (CLOUD) characterizes the degree of overlap between coarse and fine bounding boxes. Coarse-fine consistency loss. This is used to constrain the coarse and fine inspection location results corresponding to the same defect to be close to each other in the original high-resolution image coordinate system, eliminating the location discrepancies caused by the coarse inspection using low-resolution images and the fine inspection using high-resolution sub-images, and achieving spatial alignment of the two-level detection.

[0097] In some embodiments, the preset joint loss function may also include an uncertainty calibration term to constrain ||σ. i ||2 is positively correlated with the offset of the thick and thin frames (positioning error). After uncertainty calibration, the variance can truly reflect the unreliability of the coarse detection's own positioning, making the trigger score U constructed based on the variance more accurate. i It can more accurately distinguish between difficult and easy samples, improve the reliability of candidate regions triggering detailed inspection in variance-aware pruning strategies, reduce unnecessary detailed inspection inference, and reduce the risk of missing minor defects.

[0098] As can be seen, the above-mentioned defect detection method reduces the dimensionality of the high-resolution first image to obtain a low-resolution second image, and completes the initial screening of the entire region by relying on the coarse detection network. It does not require performing complete inference on the entire high-resolution image, which greatly reduces the computational load of global inference. Then, only the candidate defect regions obtained by coarse detection are cropped into high-resolution sub-images (i.e. candidate defect region images) and sent to the fine detection network for refined recognition. This avoids redundant high-precision calculations on defect-free background regions. This method effectively reduces the requirements for hardware performance while ensuring the accuracy of small defect recognition, and can realize small defect detection of high-resolution images at low cost.

[0099] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.

[0100] Based on the same inventive concept, this application also provides a defect detection device. The solution provided by this device is similar to the solution described in the above method. Therefore, the specific limitations of one or more defect detection device embodiments provided below can be found in the limitations of the defect detection method above, and will not be repeated here.

[0101] like Figure 5 As shown, this application embodiment provides a defect detection device 500, including: The acquisition module 501 is used to acquire a first image of the object to be tested; the first image is a high-resolution image. The dimension reduction module 502 is used to perform dimension reduction processing on the first image to obtain the second image; the second image is a low-resolution image. The first defect detection module 503 is used to perform defect detection on the second image through a trained coarse detection network to obtain a first defect detection result; and to determine candidate defect region images in the first image based on the first defect detection result. The second defect detection module 504 is used to perform defect detection on the candidate defect region image through a trained fine detection network to obtain a second defect detection result; and to determine the target defect detection result corresponding to the item to be tested based on the second defect detection result, the first defect detection result and the first image.

[0102] Each module in the aforementioned defect detection device 500 can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0103] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores defect detection-related data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements the steps in the defect detection method described above.

[0104] In some embodiments, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7As shown, the computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it performs the steps in the aforementioned defect detection method. The display unit is used to form a visually visible image and can be a display screen, projection device, or virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen; the input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs or touchpads set on the casing of the computer device, or external keyboards, touchpads or mice, etc.

[0105] Those skilled in the art will understand that Figure 6 or Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0106] In some embodiments, a computer device is provided, the computer device including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps in the above method embodiments.

[0107] In some embodiments, such as Figure 8 The diagram shows the internal structure of a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the above-described method embodiments.

[0108] In some embodiments, a computer program product is provided, which includes a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0109] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0110] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0111] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0112] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A defect detection method, characterized in that, include: Obtain the first image of the item to be tested; The first image is a high-resolution image; The first image is subjected to dimensionality reduction processing to obtain the second image; The second image is a low-resolution image; The second image is subjected to defect detection using a trained coarse detection network to obtain a first defect detection result; Based on the first defect detection result, a candidate defect region image in the first image is determined; The candidate defect region image is subjected to defect detection by a trained fine inspection network to obtain a second defect detection result; Based on the second defect detection result, the first defect detection result, and the first image, the target defect detection result corresponding to the item to be tested is determined.

2. The method according to claim 1, characterized in that, The trained coarse detection network includes: an uncertainty detection head and a first detection network; the first defect detection result includes: a coarse detection boxes, a class confidence scores and a uncertainty parameters; where a is a positive integer; The step of performing defect detection on the second image using a trained coarse detection network to obtain a first defect detection result includes: The second image is coarsely detected using the first detection network to obtain first defect detection data; the first defect detection data includes: a coarse detection boxes and a class confidence scores; each coarse detection box corresponds to a class confidence score; The uncertainty detection head is used to determine the a uncertainty parameters corresponding to the a coarse detection boxes.

3. The method according to claim 2, characterized in that, The candidate defect region image includes b defect region images; where b is a natural number less than or equal to a. The step of determining the candidate defect region image in the first image based on the first defect detection result includes: Based on the first preset calculation formula, the a category confidence levels, and the a uncertainty parameters, determine a trigger scores; Determine b target trigger scores that are greater than a preset trigger score from among the a trigger scores; Determine b coarse detection frames that correspond to the b target trigger scores in the a coarse detection frames; Based on the b coarse detection boxes and the first image, determine b cropping region images; The dimensions of the b cropped region images are normalized to obtain the b defect region images.

4. The method according to claim 3, characterized in that, The step of determining b cropping region images based on the b coarse detection boxes and the first image includes: Obtain the first coarse detection box and its corresponding first uncertainty parameter; the first coarse detection box is any one of the b coarse detection boxes; Determine the center coordinates of the corresponding region of the first coarse detection box in the first image, as well as the width and height of the coarse detection box, to obtain the first center coordinates, the width of the first coarse detection box, and the height of the first coarse detection box; The first cutting radius is determined based on the second preset calculation formula, the width of the first coarse inspection frame, the height of the first coarse inspection frame, the first uncertainty parameter, and the preset minimum cutting radius; Based on the first cropping radius and the first center coordinates, the first image is cropped to obtain the cropping region image corresponding to the first coarse detection box.

5. The method according to claim 4, characterized in that, The step of cropping the first image according to the first cropping radius and the first center coordinates to obtain the cropping region image corresponding to the first coarse detection box includes: The first cutting area is determined based on the first cutting radius and the first center coordinates; When the first cropping region does not exceed the image boundary of the first image, the first image is cropped according to the first cropping region to obtain the cropping region image corresponding to the first coarse detection box; or... When the first cropping region exceeds the image boundary of the first image, the first image is cropped according to the preset cropping method and the first cropping region to obtain the cropping region image corresponding to the first coarse detection box; the preset cropping method is used to process the out-of-bounds region when the cropping region exceeds the image boundary so that the cropped region image meets the preset cropping requirements.

6. The method according to any one of claims 3-5, characterized in that, The step of performing defect detection on the candidate defect region image using a trained fine-detection network to obtain a second defect detection result includes: Defect detection is performed on the b defect region images using a trained fine detection network, resulting in b defect detection results; each defect detection result includes a set of fine detection boxes and its corresponding category confidence set. Determine the b coordinate transformation parameters corresponding to the b defect region images; Based on the b coordinate transformation parameters, determine the coordinate set corresponding to each fine inspection box in the first image in the b defect detection results, and obtain b coordinate sets; Based on the b coordinate sets and the b defect detection results, the second defect detection result is determined.

7. The method according to any one of claims 1-5, characterized in that, The method further includes: An initial coarse inspection network, an initial fine inspection network, a first training dataset, and a second training dataset are obtained. The first training dataset includes multiple high-resolution images of objects and their corresponding defect annotation information. The second training dataset is obtained by dimensionality reduction processing of the images in the first training dataset. The initial coarse detection network is trained using the second training dataset to obtain the first coarse detection network; The initial fine-detection network is trained using the first training dataset to obtain the first fine-detection network; Based on a preset joint loss function, the first coarse detection network and the first fine detection network are jointly trained to obtain the trained coarse detection network and the trained fine detection network.

8. A defect detection device, characterized in that, include: The acquisition module is used to acquire the first image of the item to be tested; The first image is a high-resolution image; A dimensionality reduction module is used to perform dimensionality reduction processing on the first image to obtain a second image; the second image is a low-resolution image. The first defect detection module is used to perform defect detection on the second image through a trained coarse detection network to obtain a first defect detection result; Based on the first defect detection result, a candidate defect region image in the first image is determined; The second defect detection module is used to perform defect detection on the candidate defect region image through a trained fine detection network to obtain a second defect detection result. Based on the second defect detection result, the first defect detection result, and the first image, the target defect detection result corresponding to the item to be tested is determined.

9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.