A training method, device, equipment and storage medium for a regional detection model

By performing regional hierarchical processing and model training on the original PCB diagram, the low detection rate problem caused by background and foreground interference is solved, and the accuracy and reliability of PCB defect detection are improved.

CN118297032BActive Publication Date: 2025-05-16SHANGHAI GANTU NETWORK TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410455980.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-16
Publication Date
2025-05-16
Estimated Expiration
2044-04-16

AI Technical Summary

Technical Problem

In the prior art, in PCB circuit board defect detection, due to the interference of background and foreground, the model cannot correctly identify some defects, and the detection rate is low.

Method used

By performing regional hierarchical processing on the original PCB diagram, a layer map training matrix is ​​generated, and based on the training requirements of the initial detection model, the training subset is determined for model training, and finally the object detection model is determined based on the verification results.

Benefits of technology

It reduces the interference between background and foreground, improves the detection rate of PCB defects by the model, and enhances the accuracy and reliability of the detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118297032B_ABST
    Figure CN118297032B_ABST
Patent Text Reader

Abstract

The present application relates to a training method, device, equipment and storage medium for a regional detection model, which is applied in the field of artificial intelligence, wherein the method includes: obtaining a PCB original image training set, performing regional layered processing on each PCB original image in the PCB original image training set, and generating a PCB layer image training matrix; based on the training requirements of several preset initial detection models, determining and training a training subset corresponding to each initial detection model from the PCB layer image training matrix, and generating several trained models to be verified; based on the same set of images to be detected, inputting several models to be verified respectively, generating verification results corresponding to each model to be verified, and determining a target detection model according to the verification results. The technical effect of the present application is: by generating multiple PCB layered images corresponding to the PCB original image, the PCB image information can be extracted according to different levels, which helps to reduce the interference between the background and foreground in the PCB original image and improve the detection rate of the model for PCB defects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of artificial intelligence, and in particular to a training method, device, equipment and storage medium for a regional detection model. Background Art

[0002] PCB circuit boards are the foundation of electronic devices, and their quality directly affects the performance and reliability of the entire electronic product. As modern electronic devices have an increasing demand for miniaturization and high-density integration, the components and wires on PCBs have become more sophisticated and complex, and any defects may cause circuit blockages, short circuits or other failures, affecting the function of the entire system. Therefore, accurately identifying these defects is crucial to improving the quality and reliability of PCB manufacturing.

[0003] The existing technology usually uses a neural network model to automatically detect the appearance defects of PCB circuit boards. The neural network model uses the collected PCB original images for learning during the training phase so that different defects can be identified and classified in practical applications.

[0004] However, there is often interference between the background and foreground in the collected PCB original images, where the background is usually represented by the black part and the foreground is the golden part, that is, the dark side and the bright side; the model will regard defects in some backgrounds as foreground parts and fail to detect them, resulting in a low detection rate in the recognition results. Summary of the invention

[0005] In order to alleviate the interference between the background and the foreground and improve the detection rate of defect recognition, the present application provides a training method, device, equipment and storage medium for a regional detection model.

[0006] In a first aspect, the present application provides a method for training a region-based detection model, which adopts the following technical solution: the method comprises:

[0007] Acquire a PCB original image training set, perform regional layering processing on each PCB original image in the PCB original image training set, and generate a PCB layer image training matrix;

[0008] Based on the training requirements of several preset initial detection models, determine the training subsets corresponding to each of the initial detection models from the PCB layer diagram training matrix, and train them together to generate several trained models to be verified;

[0009] Based on the same set of images to be detected, several models to be verified are input respectively, a verification result corresponding to each model to be verified is generated, and the target detection model is determined according to the verification result.

[0010] In a specific implementation scheme, the performing regional layering processing on each PCB original image in the PCB original image training set includes:

[0011] According to the acquired layer image category requirements, regional stratification processing is performed on each PCB original image in the PCB original image training set one by one, a layer image sequence corresponding to the PCB original image is generated, a target area of ​​each layer image in the layer image sequence is determined, and preset pixels are used to fill the outside of the target area, wherein the target area corresponds to the layer image category requirements.

[0012] In a specific implementation scheme, the layer image category requirements include foreground layer image requirements and background layer image requirements, and the region layering processing is performed on each PCB original image in the PCB original image training set one by one to generate a layer image sequence corresponding to the PCB original image, and determining the target region of each layer image in the layer image sequence includes:

[0013] Performing foreground area layering processing on the PCB original images one by one to generate a foreground layer image sequence corresponding to the PCB original image, and determining a first target area of ​​each foreground layer image in the foreground layer image sequence, wherein the first target area corresponds to the foreground area in the PCB original image;

[0014] Background area layering processing is performed on the PCB original images one by one to generate a background layer image sequence corresponding to the PCB original image, and a second target area of ​​each background layer image in the background layer image sequence is determined, where the second target area corresponds to the background area in the PCB original image.

[0015] In a specific implementation scheme, the model to be verified includes a single-layer detection model and a hybrid detection model, and generating a plurality of trained models to be verified includes:

[0016] If the training subset corresponds to a single type of PCB layer diagram, a single-layer detection model corresponding to the single type of PCB layer diagram is generated; if the training subset corresponds to multiple types of PCB layer diagrams, a mixed detection model corresponding to the multiple types of PCB layer diagrams is generated;

[0017] The generating of the verification result corresponding to each of the models to be verified comprises:

[0018] If the model to be verified is a single-layer detection model, a single-layer detection result corresponding to the single-layer detection model is generated; if the model to be verified is a mixed detection model, a mixed detection result corresponding to the mixed detection model is generated.

[0019] In a specific implementation scheme, generating a mixed detection result corresponding to the mixed detection model includes:

[0020] For each image to be detected in the set of images to be detected, extract a feature map corresponding to the multiple types of PCB layer images, and generate a ROI corresponding to each pixel point in the feature map;

[0021] Performing binary classification and coordinate regression operations on the ROI respectively to obtain a refined region; performing an alignment operation on the refined region to make the pixel ratio of the feature map and the image to be detected the same;

[0022] The refined area is classified, and a mixed detection result is obtained according to the classification result, wherein the mixed detection result includes a defect type, defect coordinates, and a confidence level corresponding to the defect type.

[0023] In a specific implementation scheme, determining the target detection model according to the verification result includes:

[0024] Determine the difference between the defect recognition capabilities of the single-layer detection model and the hybrid detection model by combining the single-layer detection result and the hybrid detection result;

[0025] If the difference is less than a preset threshold, the mixed detection model is determined as the target detection model; otherwise, the single-layer detection model is determined as the target detection model.

[0026] In a specific implementation scheme, the defect recognition capability includes a weighted average of a defect detection rate, a defect over-detection rate, and a defect detection time.

[0027] In a second aspect, the present application provides a training device for a region-based detection model, which adopts the following technical solution: the device comprises:

[0028] A regional hierarchical processing module is used to obtain a PCB original image training set, perform regional hierarchical processing on each PCB original image in the PCB original image training set, and generate a PCB layer image training matrix;

[0029] A detection model training module is used to determine and train training subsets corresponding to each of the initial detection models from the PCB layer diagram training matrix based on the training requirements of the preset initial detection models, and generate a number of trained models to be verified;

[0030] The target model determination module is used to input several models to be verified based on the same set of images to be detected, generate verification results corresponding to each model to be verified, and determine the target detection model according to the verification results.

[0031] In a third aspect, the present application provides a computer device, which adopts the following technical solution: it includes a memory and a processor, and the memory stores a computer program that can be loaded by the processor and executes any of the above-mentioned training methods for the regional detection model.

[0032] In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution: storing a computer program that can be loaded by a processor and execute any of the above-mentioned training methods for the region detection model.

[0033] In summary, this application has the following beneficial technical effects:

[0034] 1. By performing regional layering processing on the original PCB image and decomposing the PCB image into different regions, the model can be more focused on learning information at different levels, reduce the interference between the background and the foreground, and pay more attention to areas where defects may exist, thereby improving the model's detection rate of PCB defects;

[0035] 2. Associate with several preset initial detection models to determine the training subset, so that the model can focus more on learning the features related to the performance differences of the initial model in specific areas, thereby improving the defect detection effect;

[0036] 3. By inputting multiple models to be verified on the same set of images to be detected and finally integrating the verification results, it helps to comprehensively consider the advantages of multiple models and improve the reliability of the target detection model in identifying defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 It is a schematic diagram of performing regional layering on a PCB original image in an embodiment of the present application.

[0038] Figure 2 It is a flowchart of the training method of the regional detection model in an embodiment of the present application.

[0039] Figure 3 It is a schematic diagram used to illustrate the layer graph training matrix in an embodiment of the present application.

[0040] Figure 4 It is a schematic diagram used to illustrate the metal layer map training set in the embodiment of the present application.

[0041] Figure 5 It is a schematic diagram used to illustrate the substrate layer map training set in the embodiments of the present application.

[0042] Figure 6 It is the detection data of the defect detection rate of the single-layer detection model in the embodiment of the present application.

[0043] Figure 7 It is the detection data of the defect detection rate of the hybrid detection model in the embodiment of the present application.

[0044] Figure 8 It is the detection data of the defect pass rate of the single-layer detection model in the embodiment of the present application.

[0045] Fig. 9 It is the detection data of the defect pass rate of the hybrid detection model in the embodiment of the present application.

[0046] Fig.10 It is a structural block diagram of the training device of the regional detection model in the embodiment of the present application.

[0047] Fig.11 It is a schematic diagram used to embody a computer device in an embodiment of the present application.

[0048] Attached figure numbers: 1001, regional stratification processing module; 1002, detection model training module; 1003, target model determination module. DETAILED DESCRIPTION

[0049] The following combination Figure 1-Figure 11 This application is described in further detail.

[0050] The present application embodiment discloses a method for training a region detection model. Image region stratification is an image processing method in which an image is divided into different regions, and each region is processed independently at different levels of the image; Figure 1 As shown, the collected PCB original image contains a metal area and a background area outside the metal area, and the area is regionally layered to be divided into a metal layer image and a substrate layer image, wherein the metal layer image retains the metal area in the PCB original image, and the substrate layer image retains the substrate area in the PCB original image; the training method of the regional detection model is applied to the regional detection model training system, and the regional detection model training system includes a regional layering processing unit for performing regional layering processing on the PCB original image, a detection model training unit for training the detection model, and a target model determination unit for evaluating the detection results and determining the target detection model.

[0051] like Figure 2 As shown, the method comprises the following steps:

[0052] S10, obtaining a PCB original image training set, performing regional layering processing on each PCB original image in the PCB original image training set, and generating a PCB layer image training matrix.

[0053] Specifically, a training set containing various PCB original images is collected, which can be obtained by taking images in actual PCB manufacturing, using synthetic data, or from existing datasets; each PCB original image is subjected to regional layering processing, and image processing techniques such as threshold processing and edge detection can be used to extract the required area in the PCB and the area outside the area as the background area, and finally generate a layered layer image based on the required area and the background area; the PCB layer image training matrix contains all the layer images corresponding to several PCB original images and is arranged in a certain order, for example Figure 3 As shown in the figure, the PCB original image training set contains 3 PCB original images, each of which corresponds to 4 layer images. Then the 3 PCB original images correspond to 12 layer images in total, forming a PCB layer image training matrix, in which each row represents the same type of layer image, and each column corresponds to the same PCB original image.

[0054] S20, based on the training requirements of several preset initial detection models, determine the training subsets corresponding to each initial detection model from the PCB layer diagram training matrix, and train them together to generate several trained models to be verified.

[0055] Specifically, different initial detection models correspond to different PCB original images or layer images. For example, a detection model used to detect defects in metal can use the metal layer image as a training set; a detection model used to detect defects in the entire PCB original image can use all layer images corresponding to the PCB original image as a training set; at this time, based on the training requirements of the initial detection model, the training subset required by the initial detection model is determined from the PCB layer image training matrix, and the initial detection model is trained using the training subset; after each initial detection model is trained, a corresponding model to be verified is generated.

[0056] S30, based on the same set of images to be detected, input a number of models to be verified respectively, generate a verification result corresponding to each model to be verified, and determine the target detection model according to the verification result.

[0057] Specifically, the set of images to be tested contains several original PCB images. The same set of images to be tested is used to input different types of models to be verified to obtain the test results of each model. The verification results can include information such as the location, category, and confidence level of the identified defects. The model evaluation indicators are used to evaluate the defect recognition ability of each model to be verified. By comparing the performance of the models to be verified on the same data set, the models to be verified that meet the requirements are found as the target detection models.

[0058] By using the regional detection model training method to perform regional stratification on the PCB original image, the model can learn the structure of the PCB image more finely, highlight the key areas, reduce the focus on irrelevant areas, and improve the accuracy of locating and detecting PCB defects. According to the training requirements of different initial detection models, the training subset is determined from the PCB layer image training matrix, so that each initial detection model is more focused on learning the area it is concerned about, thereby improving the performance of the specific area of ​​the model. By using multiple models to be verified and integrating their verification results, a more comprehensive evaluation can be obtained to find the target detection model with the required performance. By dynamically determining the target detection model based on the verification results based on the same set of images to be detected, the system can be more flexible and adaptive.

[0059] In one embodiment, in order to improve the accuracy of the training data, the step of performing regional layering processing on each PCB original image in the PCB original image training set may be specifically performed as follows:

[0060] First, define the layer image categories required in the PCB defect detection task, such as metal layer images and substrate layer images; determine the specific goals and requirements of each layer image category, and perform regional layering processing on each PCB original image in the PCB original image training set one by one. For example, for metal layer images, the metal area in the PCB original image can be extracted by image processing technology, and for substrate layer images, the substrate area in the PCB original image can be extracted by image processing technology; generate a layer image sequence corresponding to several PCB original images; determine the target area of ​​each layer image in the layer image sequence, which can be achieved by image processing technologies such as threshold processing, edge detection, and color segmentation; fill the outside of the target area with preset pixels to identify the part of the PCB image that needs to be paid attention to, and fill other areas with preset background colors or values, such as green (the fluorescent green used by the green screen is easier to separate from the foreground in the computer system, and the color is brighter and less likely to produce black edges), so as to reduce the model's attention to irrelevant areas; the target area corresponds to the layer image category requirement. For example, if the layer image category requirement is a metal layer image, the target area corresponds to the metal area in the layer image; Figure 4 In the green-painted small image 256*256 and the green-painted small image 512*512, the non-green areas correspond to the metal areas of the original PCB image; Figure 5 In the figure, the non-green areas in the green-painted small image 256*256 and the green-painted small image 512*512 correspond to the substrate areas of the original PCB image.

[0061] Through this embodiment, the layer image categories required in the PCB defect detection task, such as metal layer images and substrate layer images, are defined, and the specific goals and requirements of each layer image category are determined, which can better adapt to the actual situation of the PCB defect detection task and make the layered processing more targeted; by generating multiple layer image sequences, the training set is enriched, which helps the model learn information at different levels and improves the comprehensiveness and accuracy of detection; the determination of the dynamic target area can more flexibly adapt to the characteristics of different PCB images and improve the accuracy of the model's defect detection; using preset pixels to fill outside the target area, such as filling with green, helps to identify the part of the PCB image that needs attention, and by using eye-catching colors such as green, it can be more easily separated from the foreground, reducing the model's attention to irrelevant areas; ensuring that each layer image in the generated layer image sequence is consistent with the layer image category requirements, helps to improve the accuracy of the training data, so that the model can better understand the characteristics of each category.

[0062] In one embodiment, the layer image category requirements include foreground layer image requirements and background layer image requirements. In order to improve the model's ability to capture and distinguish features at each level in the PCB image, each PCB original image in the PCB original image training set is subjected to regional layering processing one by one to generate a layer image sequence corresponding to the PCB original image. The step of determining the target area of ​​each layer image in the layer image sequence can be specifically performed as follows:

[0063] For several PCB original images in the training set, the foreground area is layered for each PCB original image. Figure 1 For example, a foreground layer image sequence corresponding to the PCB original image is generated, such as a metal layer image sequence, and image processing techniques such as threshold processing and edge detection are used to extract the metal area in the PCB original image as the foreground area, and the target area of ​​each metal layer image in the metal layer image sequence is determined, and the target area corresponds to the metal area in the PCB original image; background area layering processing is performed on the PCB original images one by one to generate a background layer image sequence corresponding to the PCB original image, such as a substrate layer image sequence, and image processing techniques such as threshold processing and edge detection are used to extract the substrate area in the PCB original image as the background area; the target area of ​​each substrate layer image in the substrate layer image sequence is determined, and the target area corresponds to the substrate area in the PCB original image; if there are multiple layers, for example, considering the metal layer, substrate layer and other layers at the same time, similar steps can be followed.

[0064] Through this embodiment, the layer image category requirements are clearly defined, including the foreground layer image requirements and the background layer image requirements, which helps to improve the model's learning ability for information at different levels, so that the model can better understand the foreground and background relationship in the PCB image; by performing layered processing of the foreground and background areas one by one, the multi-layer situation is taken into account, for example, the metal layer, the substrate layer and other layers need to be considered at the same time, so that the model can learn richer information and improve the model's ability to capture and distinguish features at each level in the PCB image; determine the target area of ​​each layer image in each layer image sequence, these target areas correspond to the actual areas in the PCB original image, by highlighting the target area and distinguishing it from the background, the model is more likely to focus on the part that needs to be paid attention to in the PCB image, and improve the model's attention to the target area; by processing several PCB original images in the training set one by one, the applicability of the method is demonstrated, so that the method can be applied to a training set containing various PCB images, including PCB images of different structures and different levels.

[0065] In one embodiment, the model to be verified includes a single-layer detection model and a hybrid detection model. In order to improve the accuracy and robustness of detection, the step of generating several trained models to be verified can be specifically performed as follows:

[0066] For each training subset, determine the type of PCB layer diagram it corresponds to, i.e., single type or multiple types; if the training subset corresponds to a single type of PCB layer diagram, generate a single-layer detection model corresponding to the single type of PCB layer diagram; if the training subset corresponds to multiple types of PCB layer diagrams, generate a mixed detection model corresponding to the multiple types of PCB layer diagrams; use the preset training algorithm and parameters to train each training subset to obtain the corresponding model to be verified.

[0067] Through this embodiment, single-type and multi-type PCB layer diagrams are distinguished, and then corresponding detection models are dynamically generated according to different types. This dynamic generation method enables the structure of the model to be flexibly adjusted according to different types of PCB layer diagrams, so as to better adapt to different detection tasks and improve the applicability of the model; in the face of multi-type PCB layer diagrams, a hybrid detection model is generated, which can comprehensively consider information at different levels and realize comprehensive detection of multiple defects. By integrating multiple information in one model, the global perception ability of the model can be improved, thereby improving the accuracy and robustness of the detection; by judging the PCB layer diagram type corresponding to the training subset, flexible processing of single-type and multi-type PCB layer diagrams is achieved. This flexibility enables the method to adapt to different scenarios and needs, and provides an optional model solution for different types of PCB defect detection.

[0068] In one embodiment, the model to be verified includes a single-layer detection model and a hybrid detection model. In order to more accurately compare the performance of the single-layer detection model and the hybrid detection model, for each model to be verified, the same set of images to be detected is used for verification, and the verification results corresponding to each model to be verified are generated, including:

[0069] If the model to be verified is a single-layer detection model, a set of images to be detected is input to generate a single-layer detection result corresponding to the single-layer detection model, and the single-layer detection result includes information such as the location, category, and confidence level of the identified defects; if the model to be verified is a mixed detection model, the same set of images to be detected is input to generate a mixed detection result corresponding to the mixed detection model, which includes the detection results of various PCB layer diagrams, the comprehensive output of the model for information at different levels, and the post-processing of fusing the detection results of each layer to obtain the final comprehensive detection result. Finally, a mixed detection result corresponding to the mixed detection model is generated, and the mixed detection result includes information such as the location, category, and confidence level of the identified defects.

[0070] Through this embodiment, the same set of images to be detected is used for verification, which ensures the comparability of the verification results, helps to more accurately compare the performance of the single-layer detection model and the hybrid detection model, and improves the credibility of the verification; for the hybrid detection model, by fusing the detection results of various PCB layer maps, deep fusion of information at different levels is achieved, and the detection capability of complex PCB structures is improved; in the verification process of the hybrid detection model, post-processing of the model output is performed to obtain the final hybrid detection result. This post-processing process is expected to further improve the output accuracy and interpretability of the hybrid detection model and make more refined adjustments and optimizations to the detection results; by ensuring the consistency of the output result format of the single-layer detection model and the hybrid detection model, the comparison and analysis of the results are facilitated, and performance evaluation and result interpretation can be more conveniently performed, thereby improving the practicality of the entire verification process; through the design of the hybrid detection model, the model can adapt to the needs of different PCB defect detection, including the detection of different types of PCB layer maps. This flexibility makes the model more versatile and suitable for a variety of PCB manufacturing scenarios.

[0071] In one embodiment, in order to improve the accuracy of detection, the step of generating a hybrid detection result corresponding to the hybrid detection model may be specifically performed as follows:

[0072] For each image to be detected in the set of images to be detected, a hybrid detection model is used to extract feature maps corresponding to multiple types of PCB layer images, and a region of interest (ROI) corresponding to each pixel in the feature map is generated; a binary classification operation is performed on each region of interest (ROI) to determine whether the region contains defects. This is achieved through the binary classification results output by the model, that is, to determine whether the defect exists, and a coordinate regression operation is performed at the same time to obtain the accurate location information of the defect, including the coordinates, shape and other information of the defect; for the defect area obtained by coordinate regression, an alignment operation is performed. The purpose of this operation is to adjust the size and position of the region of interest so that it has the same pixel ratio as the image to be detected, which helps to more accurately map the hybrid detection results back to the original image; a final classification operation is performed on the refined area after the alignment operation to determine the specific type of the defect. This step usually uses the classification results output by the model, which can identify different types of defects in multiple PCB layer images; a hybrid detection result is obtained based on the classification result, including the type of defect, the coordinate information of the defect, and the confidence corresponding to the defect type. This information constitutes the hybrid detection result, which is used to describe the defect conditions of various PCB layer images in each image to be detected.

[0073] Through this embodiment, a hybrid detection model is used to extract feature maps corresponding to multiple types of PCB layer images, thereby achieving simultaneous capture and processing of different types of defect information. Such deep fusion allows the model to understand the PCB image more comprehensively and improves the accuracy of detection. A binary classification operation is used to determine whether a defect exists, and accurate location information is obtained through a coordinate regression operation, which can improve the precise positioning of the defect and provide more accurate input for subsequent alignment and classification operations. The use of the alignment operation is a key step in refining the defect area, which helps to adjust the size and position of the area of ​​interest so that it has the same pixel ratio as the image to be detected, and helps to more accurately map the detection results back to the original image, thereby improving the reliability of the results. The final classification operation comprehensively considers the defect information in multiple types of PCB layer images. This comprehensive classification improves the adaptability of the model to different PCB layer image structures and defect types. The hybrid detection result includes the defect type, coordinate information, and confidence level corresponding to the type, providing a comprehensive description of the various PCB layer image defect conditions in each image to be detected, making the result more detailed.

[0074] In one embodiment, in order to comprehensively consider the recognition accuracy of the model for various defects, the step of determining the target detection model according to the verification result can be specifically performed as follows:

[0075] The single-layer detection results and the hybrid detection results, including the location, category, confidence and other information of each defect, are combined to determine the difference in defect recognition ability between the single-layer detection model and the hybrid detection model. The difference can comprehensively consider the model's performance in terms of recognition accuracy and positioning accuracy for various defects. A preset threshold is introduced to determine whether the difference in defect recognition ability between the single-layer detection model and the hybrid detection model is significant enough. If the difference is less than the preset threshold, the hybrid detection model is determined as the target detection model, otherwise, the single-layer detection model is determined as the target detection model.

[0076] Through this embodiment, the difference is calculated, not only focusing on the performance of the model in a certain aspect (such as defect detection rate), but also comprehensively considering the model's performance in multiple aspects such as recognition accuracy and positioning accuracy of various defects, which is more in line with the expectations for the comprehensive performance of the model in practical applications; the introduction of preset thresholds makes the model selection process more automated and intelligent. By setting the thresholds, the system can automatically select the target detection model suitable for the current task in different scenarios without manual intervention, thereby improving the flexibility and adaptability of the system; by setting the difference and threshold, the actual difference in defect recognition ability between the single-layer detection model and the hybrid detection model can be more objectively judged, which helps to reduce the judgment of the model based solely on a certain performance indicator, and instead conducts a more comprehensive analysis based on actual conditions.

[0077] In one embodiment, in order to better reflect the performance of the model in multiple aspects, the defect recognition capability includes the weighted average of the defect detection rate, the defect over-detection rate and the defect detection time; the defect detection rate refers to the ability of the model to successfully identify real defects, which means the proportion of all real defects that are successfully detected by the model (detection data such as Figure 6 and Figure 7 The defect over-detection rate refers to the frequency of false positives when the model detects defects, indicating the proportion of areas marked as defects by all models that actually have no real defects (detection data such as Figure 8 and Fig. 9 As shown in the figure); defect detection time refers to the time required for the model to complete the identification of defects; since the importance of different indicators may be different in practical applications, different weights are assigned to these three measurement indicators, and the weighted average of the defect identification ability is calculated to better reflect the overall performance of the model in different defect scenarios.

[0078] Through this embodiment, multiple dimensions such as defect detection rate, defect pass rate and defect detection time are introduced to more comprehensively evaluate the performance of the model in the defect identification task. This multi-dimensional evaluation helps to gain a deeper understanding of the performance of the model in actual scenarios and alleviates the oversimplified evaluation method; it explains that the evaluation process is based on real defect data rather than theoretical assumptions. Such verification is closer to the actual application scenario, ensuring the practicality and credibility of the evaluation results; different weights are given to different indicators, and the importance of different indicators in practical applications is flexibly considered. This weight assignment strategy makes the overall evaluation more in line with actual needs and adapts to the different concerns of different application scenarios on model performance. The weighted average allows the contribution of different indicators to be flexibly adjusted, thereby better reflecting the performance of the model in many aspects.

[0079] Figure 2 FIG. 1 is a flow chart of a method for training a region detection model in an embodiment. It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but the steps are not necessarily executed in the order indicated by the arrows; unless otherwise specified herein, there is no strict order restriction for the execution of the steps, and the steps may be executed in other orders; and Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequentially, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0080] Based on the above method, an embodiment of the present application also discloses a training device for a region-based detection model.

[0081] Reference Fig.10 , the device includes the following modules:

[0082] The regional layered processing module 1001 is used to obtain a PCB original image training set, perform regional layered processing on each PCB original image in the PCB original image training set, and generate a PCB layer image training matrix;

[0083] The detection model training module 1002 is used to determine the training subsets corresponding to each initial detection model from the PCB layer diagram training matrix based on the training requirements of the preset initial detection models, and to train them together to generate a number of trained models to be verified;

[0084] The target model determination module 1003 is used to input several models to be verified based on the same set of images to be detected, generate verification results corresponding to each model to be verified, and determine the target detection model according to the verification results.

[0085] In one embodiment, the regional layering processing module 1001 is specifically used to perform regional layering processing on each PCB original image in the PCB original image training set one by one according to the acquired layer image category requirements, generate a layer image sequence corresponding to the PCB original image, determine the target area of ​​each layer image in the layer image sequence, and fill the outside of the target area with preset pixels, wherein the target area corresponds to the layer image category requirements.

[0086] In one embodiment, the regional layering processing module 1001 is specifically used to perform foreground region layering processing on the PCB original image one by one, generate a foreground layer image sequence corresponding to the PCB original image, determine the first target area of ​​each foreground layer image in the foreground layer image sequence, and the first target area corresponds to the foreground area in the PCB original image; perform background region layering processing on the PCB original image one by one, generate a background layer image sequence corresponding to the PCB original image, determine the second target area of ​​each background layer image in the background layer image sequence, and the second target area corresponds to the background area in the PCB original image.

[0087] In one embodiment, the detection model training module 1002 is specifically used to generate a single-layer detection model corresponding to a single type of PCB layer diagram if the training subset corresponds to a single type of PCB layer diagram; if the training subset corresponds to multiple types of PCB layer diagrams, then a mixed detection model corresponding to the multiple types of PCB layer diagrams is generated; if the model to be verified is a single-layer detection model, then a single-layer detection result corresponding to the single-layer detection model is generated; if the model to be verified is a mixed detection model, then a mixed detection result corresponding to the mixed detection model is generated.

[0088] In one embodiment, the detection model training module 1002 is specifically used to extract feature maps corresponding to multiple types of PCB layer images for each image to be detected in the set of images to be detected, and generate ROIs corresponding to each pixel point in the feature maps; perform binary classification and coordinate regression operations on the ROIs to obtain refined regions; perform alignment operations on the refined regions to make the pixel ratio of the feature maps the same as that of the image to be detected; classify the refined regions, and obtain mixed detection results based on the classification results, and the mixed detection results include defect types, defect coordinates, and confidence levels corresponding to the defect types.

[0089] In one embodiment, the target model determination module 1003 is specifically used to combine the single-layer detection results and the mixed detection results to determine the difference in defect recognition capabilities between the single-layer detection model and the mixed detection model; if the difference is less than a preset threshold, the mixed detection model is determined as the target detection model, otherwise, the single-layer detection model is determined as the target detection model.

[0090] In one embodiment, the target model determination module 1003 is specifically used to illustrate that the defect recognition capability includes a weighted average of a defect detection rate, a defect pass rate, and a defect detection time.

[0091] The training device for the regional detection model provided in the embodiment of the present application can be applied to the training method for the regional detection model provided in the above embodiment. For relevant details, refer to the above method embodiment. The implementation principle and technical effect are similar and will not be repeated here.

[0092] It should be noted that: when the training device for the sub-region detection model provided in the embodiment of the present application performs the training of the sub-region detection model, only the division of the above-mentioned functional modules / functional units is used as an example. In actual applications, the above-mentioned functional allocation can be completed by different functional modules / functional units as needed, that is, the internal structure of the training device for the sub-region detection model is divided into different functional modules / functional units to complete all or part of the functions described above. In addition, the implementation method of the training method for the sub-region detection model provided in the above-mentioned method embodiment and the implementation method of the training device for the sub-region detection model provided in this embodiment belong to the same concept. The specific implementation process of the training device for the sub-region detection model provided in this embodiment is detailed in the above-mentioned method embodiment and will not be repeated here.

[0093] The embodiment of the present application also discloses a computer device.

[0094] Specifically, if Fig.11 As shown, the computer device can be a computer device such as a desktop computer, a laptop computer, a PDA, and a cloud server. The computer device may include, but is not limited to, a processor and a memory. The processor and the memory may be connected via a bus or otherwise. The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, graphics processors (GPU), embedded neural network processors (NPU) or other dedicated deep learning coprocessors, discrete gates or transistor logic devices, discrete hardware components and other chips, or a combination of the above-mentioned various chips.

[0095] As a non-transient computer-readable storage medium, the memory can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the methods in the above-mentioned embodiments of the present application. The processor executes various functional applications and data processing of the processor by running the non-transient software programs, instructions and modules stored in the memory, that is, the method in the above-mentioned method implementation is realized. The memory may include a program storage area and a data storage area, wherein the program storage area may store the control unit, the application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.

[0096] The embodiment of the present application also discloses a computer-readable storage medium.

[0097] Specifically, a computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method in the above-mentioned method implementation is implemented. Those skilled in the art will understand that the implementation of all or part of the process in the above-mentioned implementation method of the present application can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and the program, when executed, may include the process of the implementation of the above-mentioned methods. Among them, the storage medium may be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk (Hard Disk Drive, abbreviated as: HDD) or a solid-state drive (SSD), etc.; the storage medium may also include a combination of the above-mentioned types of memory.

[0098] This specific embodiment is merely an explanation of the present invention and is not a limitation of the present invention. After reading this specification, those skilled in the art may make non-creative modifications to the present embodiment as needed. However, as long as they are within the scope of the claims of the present invention, they are protected by the patent law.

Claims

1. A method for training a region detection model, characterized in that: The method comprises: Acquire a PCB original image training set, perform regional layering processing on each PCB original image in the PCB original image training set, and generate a PCB layer image training matrix; Based on the training requirements of the preset initial detection models, determine the training subsets corresponding to each of the initial detection models from the PCB layer diagram training matrix, and train them together to generate a number of trained models to be verified; The model to be verified includes a single-layer detection model and a mixed detection model, and the generating of several trained models to be verified includes: if the training subset corresponds to a single type of PCB layer diagram, generating a single-layer detection model corresponding to the single type of PCB layer diagram; if the training subset corresponds to multiple types of PCB layer diagrams, generating a mixed detection model corresponding to the multiple types of PCB layer diagrams; Based on the same set of images to be detected, several models to be verified are input respectively, a verification result corresponding to each model to be verified is generated, and the target detection model is determined according to the verification result.

2. The method according to claim 1, characterized in that The performing regional layering processing on each PCB original image in the PCB original image training set comprises: According to the acquired layer image category requirements, regional stratification processing is performed on each PCB original image in the PCB original image training set one by one, a layer image sequence corresponding to the PCB original image is generated, a target area of ​​each layer image in the layer image sequence is determined, and preset pixels are used to fill the outside of the target area, wherein the target area corresponds to the layer image category requirements.

3. The method according to claim 2, characterized in that The layer image category requirements include foreground layer image requirements and background layer image requirements, performing regional layering processing on each PCB original image in the PCB original image training set one by one, generating a layer image sequence corresponding to the PCB original image, and determining the target area of ​​each layer image in the layer image sequence includes: Performing foreground area layering processing on the PCB original images one by one to generate a foreground layer image sequence corresponding to the PCB original image, and determining a first target area of ​​each foreground layer image in the foreground layer image sequence, wherein the first target area corresponds to the foreground area in the PCB original image; Background area layering processing is performed on the PCB original images one by one to generate a background layer image sequence corresponding to the PCB original image, and a second target area of ​​each background layer image in the background layer image sequence is determined, where the second target area corresponds to the background area in the PCB original image.

4. The method according to claim 1, characterized in that The generating of the verification result corresponding to each of the models to be verified comprises: If the model to be verified is a single-layer detection model, a single-layer detection result corresponding to the single-layer detection model is generated; if the model to be verified is a mixed detection model, a mixed detection result corresponding to the mixed detection model is generated.

5. The method according to claim 4, characterized in that The generating a hybrid detection result corresponding to the hybrid detection model comprises: For each image to be detected in the set of images to be detected, extract a feature map corresponding to the multiple types of PCB layer images, and generate a ROI corresponding to each pixel point in the feature map; Performing binary classification and coordinate regression operations on the ROI respectively to obtain a refined region; performing an alignment operation on the refined region to make the pixel ratio of the feature map and the image to be detected the same; The refined area is classified, and a mixed detection result is obtained according to the classification result, wherein the mixed detection result includes a defect type, defect coordinates, and a confidence level corresponding to the defect type.

6. The method according to claim 5, characterized in that Determining the target detection model according to the verification result includes: Determine the difference between the defect recognition capabilities of the single-layer detection model and the hybrid detection model by combining the single-layer detection result and the hybrid detection result; If the difference is less than a preset threshold, the mixed detection model is determined as the target detection model; otherwise, the single-layer detection model is determined as the target detection model.

7. The method according to claim 6, characterized in that The defect recognition capability includes a weighted average of a defect detection rate, a defect over-detection rate, and a defect detection time.

8. A training device for a region detection model, characterized in that: The device comprises: A regional layered processing module (1001) is used to obtain a PCB original image training set, perform regional layered processing on each PCB original image in the PCB original image training set, and generate a PCB layer image training matrix; A detection model training module (1002) is used to determine, based on the training requirements of a plurality of preset initial detection models, a training subset corresponding to each of the initial detection models from the PCB layer diagram training matrix, and train them together to generate a plurality of trained models to be verified; A different to-be-verified model generation module (1003) is used to generate a single-layer detection model corresponding to the single-type PCB layer diagram if the training subset corresponds to a single-type PCB layer diagram; and to generate a mixed detection model corresponding to the multiple-type PCB layer diagram if the training subset corresponds to multiple-type PCB layer diagrams; The target model determination module (1004) is used to input a plurality of the models to be verified based on the same set of images to be detected, generate a verification result corresponding to each of the models to be verified, and determine the target detection model according to the verification result.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored which can be loaded by a processor and execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • PCB surface defect detection method and system

    CN116452540A

  • Method and apparatus of training image recognition model, and method of detecting display substrate

    US20240070848A1