Electronic part defect visual detection method and device based on positive and negative sample double-recognition AI model, electronic equipment and storage medium
Through the joint training and parameter adjustment of the positive and negative sample dual recognition AI model, the problem of insufficient recognition of new types of negative samples by electronic component detection models in existing technologies has been solved, achieving high-precision and high detection rate detection effects.
Patent Information
- Application Number
- CN202511175462.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-08-21
AI Technical Summary
Existing AI visual inspection models have difficulty effectively identifying new types of negative samples in electronic component defect detection, resulting in a high missed detection rate and unable to meet the high detection rate requirements of industrial production.
It adopts an AI model based on dual recognition of positive and negative samples, jointly trains the basic visual detection model and the enhanced model, and uses the negative sample additional module to adjust specific prediction parameters according to the proportion of negative samples to achieve autonomous recognition of new types of negative samples.
The model's missed detection rate and over-detection rate are greatly reduced, achieving high precision and high detection rate for electronic component detection, with the detection rate of positive and negative samples approaching 100%.
Smart Images

Figure CN120726033A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic data processing technology, and in particular to a method, device, electronic device and storage medium for visual detection of electronic component defects based on a positive and negative sample dual recognition AI model. Background Art
[0002] Currently, AI technology has been widely used in visual inspection tasks of industrial electronic products, among which AI visual defect detection of electronic components is a very important application. The requirements for AI visual defect detection of electronic components are relatively high. On the one hand, the defects of electronic components are generally small in size, which requires a relatively high accuracy of AI detection technology; on the other hand, the requirements for the detection rate of electronic component defects in production are also relatively high. What is more difficult is that the accumulation of negative samples of electronic components is generally very small. Traditional AI visual inspection models are mostly AI algorithms based on supervised learning of negative samples. A large number of negative samples need to be labeled so that the trained model can more accurately identify the negative detection samples that have been learned, and at the same time have a certain generalization detection ability for similar negative samples. However, it cannot effectively identify new negative samples with large feature differences and that have not been learned by the model. At the same time, the AI model needs to have a sufficiently rich number of negative samples for learning, otherwise the trained AI model will have a high missed detection rate and it will be difficult to meet the high detection rate requirements for electronic component inspection. There are three main existing technical solutions: A. Maintain and iteratively improve the existing negative sample supervised learning model, wait for and accumulate new types of negative samples that occur in production, append them to the existing negative sample dataset, and retrain the AI model to enable it to recognize new types of negative samples.
[0003] B. Replace the supervised learning model for negative samples and directly apply the unsupervised learning model to train the existing dataset, so that it can not only identify certain existing negative samples, but also partially identify new types of negative samples.
[0004] C. Apply a generative AI model to simulate new types of negative samples that have not occurred, and append them to the existing negative sample set for training the negative sample supervised learning model, so that it can partially identify new types of negative samples that have occurred.
[0005] The above technical solutions have the following disadvantages respectively: Solution A cannot autonomously identify new types of negative samples and can only wait for new types of negative samples to occur before additional training. First, this affects the recognition accuracy of the existing AI model. Second, the model improvement cycle is long and cannot meet the quality inspection requirements of industrial production.
[0006] Plan B directly applies the unsupervised learning model. Although it can autonomously identify some new types of negative samples, due to the limitations of its own algorithm principles, the overall recognition accuracy of the unsupervised learning model is lower than that of the supervised learning model, and it is also difficult to meet the quality inspection requirements of industrial production.
[0007] Solution C applies a generative AI model. Although it can simulate new types of negative samples that have not occurred, due to the unique characteristics of industrial product defects, it is difficult for the generative AI model to simulate samples that are similar to real negative samples that occur randomly in production. Therefore, it cannot meet the quality inspection requirements of industrial production.
[0008] At the same time, in product inspection applications for electronic components, production quality inspection requirements often approach 100%, such as 99.99% or 99.999%. Therefore, the industry urgently needs an AI visual inspection model that can detect new negative samples that the model has not learned, while also achieving a positive and negative sample detection rate of over 99.99%. Summary of the Invention
[0009] The purpose of the present invention is to propose a method, device, electronic device and storage medium for visual detection of electronic component defects based on a positive and negative sample dual recognition AI model.
[0010] A method for visual inspection of electronic component defects based on a positive and negative sample dual recognition AI model includes the following steps: Obtaining image samples of electronic components to be inspected as a first image sample set to be inspected, and manually identifying positive and negative samples of each image sample to be inspected as true attributes of the image sample to be inspected; The first image sample set is brought into the visual detection basic model for supervised training. If the model reasoning is NG, the image sample set is classified into the initial negative sample set; if the model reasoning is OK, the image sample set is classified into the positive sample set; The negative sample addition module captures the number of image samples to be inspected and negative samples from the visual detection basic model and the negative sample set. If the ratio of the number of negative samples to the image samples to be inspected is lower than a ratio threshold, the specific prediction parameter of the visual detection enhancement model is doubled from the initial value; if the ratio of the number of negative samples to the image samples to be inspected is not lower than the ratio threshold, the initial value of the specific prediction parameter is retained; and at least one negative sample from the positive sample set and the negative sample set is combined into a second image sample set to be inspected; The second image sample set to be inspected is brought into the visual detection enhancement model for secondary supervised training. If the model reasoning is NG, the output detection result is a negative sample; if the model reasoning is OK, the output detection result is a positive sample; if the model reasoning is Null, the output detection result is Null.
[0011] Furthermore, NG means that a negative sample is detected, regardless of whether a positive sample is detected at the same time; OK means that a positive sample is detected, and no negative sample is detected at the same time; Null means that neither a positive sample nor a negative sample is detected, and a new defect has appeared in the marked positive sample.
[0012] Furthermore, the ratio threshold refers to the number of negative samples accounting for 4 / 10 of the samples to be tested in the image.
[0013] Furthermore, specific prediction parameters are conf, iou, and max_det.
[0014] Furthermore, the initial values of conf, iou, and max_det are 0.25, 0.7, and 300, respectively.
[0015] Furthermore, both the visual inspection basic model and the visual inspection enhancement model adopt the Yolov8 model; The Backbone module of the basic visual detection model uses C2f; the Neck module uses SPPF; and the Head module uses the Transformer module. During training, the Backbone, Neck, and Head modules are first initialized, and the first 10 epochs of the Backbone module are frozen. Then, SGD and Momentum are used as optimizers, and OneCycleLR is adopted for learning rate scheduling. The gradients of 4 batches are accumulated before updating, and gradient clipping is performed to prevent gradient explosion. Flash Attention is used to accelerate the Transformer, and Dropout is added to the Transformer Head for regularization. The training loss, mAP@0.5, and GPU memory usage are monitored. Finally, the gradient of C2f is checked and the attention weight of the Transformer is visualized.
[0016] Furthermore, the backbone module of the visual detection enhancement model includes Focus and CSPNet. The first 14 layers use CSPDarknet53, which includes three sets of continuous convolutions, expands the input channels to 96, and introduces the Swish3 activation function. The cross-stage partial connection ratio is adjusted to 1:2. Each CSP block contains two 3×3 convolutions, reduces the number of parameters through depthwise separable convolutions, and expands the receptive field to 1536×1536 through 4×4 dilated convolutions, while only increasing the number of parameters by 12%. The Neck module uses the PANet structure and introduces the SimAM attention mechanism. It implements adaptive adjustment of channel dimensions through five groups of 1×1 convolutions, improving feature reuse efficiency by 37%. The head module uses the Transformer module, uses a 12-head attention mechanism, and the head dimension is 64.
[0017] A visual inspection device for electronic component defects based on a positive and negative sample dual recognition AI model, comprising: A sample acquisition module is used to acquire image samples of electronic components to be inspected as a first image sample set to be inspected, and manually identify positive and negative samples of each image sample to be inspected as the true attributes of the image sample to be inspected; The first training module is used to bring the first image sample set to be inspected into the visual detection basic model for supervised training. If the model reasoning is NG, the image sample to be inspected is classified into the initial negative sample set; if the model reasoning is OK, the image sample to be inspected is classified into the positive sample set; A parameter setting module is used for the negative sample additional module to capture the number of image samples to be tested and negative samples from the visual detection basic model and the negative sample set. If the ratio of the number of negative samples to the image samples to be tested is lower than the ratio threshold, the specific prediction parameter of the visual detection enhancement model is doubled from the initial value; if the ratio of the number of negative samples to the image samples to be tested is not lower than the ratio threshold, the initial value of the specific prediction parameter is retained; and at least one negative sample from the positive sample set and the negative sample set is combined into a second image sample set to be tested; The second training module is used to bring the second image sample set to be inspected into the visual detection enhancement model for secondary supervised training. If the model reasoning is NG, the output detection result is a negative sample; if the model reasoning is OK, the output detection result is a positive sample; if the model reasoning is Null, the output detection result is Null.
[0018] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step of a method for visually detecting defects in electronic components based on a positive and negative sample dual recognition AI model is implemented.
[0019] A storage medium stores a computer program, which, when executed by a processor, implements the various steps in a method for visually detecting defects in electronic components based on a positive and negative sample dual recognition AI model.
[0020] The beneficial effects of the present invention are: The method of the present invention adopts a scheme of jointly training a basic visual detection model and a visual detection enhancement model. In addition, a negative sample additional module is added to adjust specific prediction parameters according to the proportion of negative samples. The reasoning accuracy is high and the reasoning speed is fast, which greatly reduces the missed detection rate and passed detection rate of the model, thereby achieving the high-precision and high detection rate detection requirements of electronic components. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a flow chart of the electronic component defect visual detection method based on the positive and negative sample dual recognition AI model of the present invention; Figure 2 This is a schematic diagram of the model algorithm reasoning in an embodiment of the present invention; Figure 3 Schematic diagram of the area marked for image acquisition of 35-pin electronic components; Figure 4 A schematic diagram of an electronic component defect visual inspection device based on a positive and negative sample dual recognition AI model; Figure 5 Schematic diagram of the structure of the electronic device of the present invention. DETAILED DESCRIPTION
[0022] The present invention proposes a method, device, electronic device, and storage medium for visual inspection of electronic component defects based on a positive and negative sample dual recognition AI model. The present invention is further described below with reference to the accompanying drawings and specific embodiments.
[0023] Figure 1 This is a flow chart of the electronic component defect visual detection method based on the positive and negative sample dual recognition AI model of the present invention; Figure 2 This is a schematic diagram of the model algorithm reasoning in an embodiment of the present invention, specifically: Obtaining image samples of electronic components to be inspected as a first image sample set to be inspected, and manually identifying positive and negative samples of each image sample to be inspected as true attributes of the image sample to be inspected; The first image sample set is brought into the visual detection basic model for supervised training. If the model reasoning is NG, the image sample set is classified into the initial negative sample set; if the model reasoning is OK, the image sample set is classified into the positive sample set; The negative sample addition module captures the number of image samples to be inspected and negative samples from the visual detection basic model and the negative sample set. If the ratio of the number of negative samples to the image samples to be inspected is lower than a ratio threshold, the specific prediction parameter of the visual detection enhancement model is doubled from the initial value; if the ratio of the number of negative samples to the image samples to be inspected is not lower than the ratio threshold, the initial value of the specific prediction parameter is retained; and at least one negative sample from the positive sample set and the negative sample set is combined into a second image sample set to be inspected; The second image sample set to be inspected is brought into the visual detection enhancement model for secondary supervised training. If the model reasoning is NG, the output detection result is a negative sample; if the model reasoning is OK, the output detection result is a positive sample; if the model reasoning is Null, the output detection result is Null.
[0024] The ratio threshold is set to 4 / 10 of the number of negative samples in the image to be tested. The following are some of the inference results: 1) OK->The sample is reported as "OK" 2) NG->The sample is reported as "NG" 3) OK*NG->report sample as "NG" 4) Null (no detections) -> Report sample as “NG” in: The output of OK indicates that the positive sample target is detected, and no other NG is identified; Outputting NG indicates that the NG target of the negative sample has been detected, regardless of whether there is a positive sample target identified at the same time; Outputting Null means that neither positive sample targets nor negative sample targets were detected. At this time, an unknown NG, that is, a new negative sample, should appear in the area marked with the positive sample target.
[0025] Among them, the positive sample labeling method is as follows: Yolo annotation and file conversion: Method 1: Target Detection: Labelimg Annotation Yolo format: Rectangular boxes are marked with OK / NG labels and directly stored in .txt format [x, y, w, h].
[0026] Method 2: Target Detection: Labelme Annotation The rectangle is labeled OK / NG and stored in .json format [x1, y1, x2, y2].
[0027] After the annotation is completed, store all .json files in a new folder, such as train_json / val_json. Also create a new txt folder, open Jupyter lab, enter json2txt.ipynb, and modify: parser.add_argument('--json-dir', type=str,default='D: / Yolo / datasets / iriso / images / val_json', help='json path dir') parser.add_argument('--save-dir', type=str,default='D: / Yolo / datasets / iriso / images / txt' ,help='txt save dir') The folder paths of '--json-dir' and '--save-dir' in the command line are modified as follows: The actual category of '--classes' in parser.add_argument('--classes', type=str, default='ng,ok',help='classes') is used. Finally, run json2txt.ipynb and copy the files in the txt folder to labels\train or labels\val under the dataset.
[0028] Figure 3 Schematic diagram of the area marked for image acquisition of a 35-pin electronic component: starting from the bottom edge of the pins on the electronic component, including the farthest hardware on the left and right ends, and then collecting downward to the bottom edge of the left and right shells.
[0029] Model and training data: The backbone module of the basic visual detection model (Model A) uses C2f; the neck module uses SPPF; and the head module uses the Transformer module. During training, the backbone, neck, and head modules are first initialized, and the first 10 epochs of the backbone module are frozen. SGD and Momentum are then used as optimizers, and OneCycleLR is employed for learning rate scheduling. Gradients are accumulated over four batches before updating, and gradient clipping is performed to prevent gradient explosion. Flash Attention is used to accelerate the Transformer, and Dropout is added to the Transformer head for regularization. Training loss, mAP@0.5, and GPU memory usage are monitored. Finally, the gradients of C2f are checked and the Transformer attention weights are visualized.
[0030] The backbone module of the visual detection enhancement model (Model C) includes Focus and CSPNet. The first 14 layers use CSPDarknet53, which includes three sets of continuous convolutions, expands the input channels to 96, and introduces the Swish3 activation function. The cross-stage partial connection ratio is adjusted to 1:2. Each CSP block contains two 3×3 convolutions, reduces the number of parameters through depthwise separable convolutions, and expands the receptive field to 1536×1536 through 4×4 dilated convolutions, while only increasing the number of parameters by 12%. The Neck module uses the PANet structure and introduces the SimAM attention mechanism. It implements adaptive adjustment of channel dimensions through five groups of 1×1 convolutions, improving feature reuse efficiency by 37%. The head module uses the Transformer module, uses a 12-head attention mechanism, and the head dimension is 64.
[0031] Figure 4 This is a schematic diagram of an electronic component defect visual inspection device based on a positive and negative sample dual recognition AI model, including: A sample acquisition module is used to acquire image samples of electronic components to be inspected as a first image sample set to be inspected, and manually identify positive and negative samples of each image sample to be inspected as the true attributes of the image sample to be inspected; The first training module is used to bring the first image sample set to be inspected into the visual detection basic model for supervised training. If the model reasoning is NG, the image sample to be inspected is classified into the initial negative sample set; if the model reasoning is OK, the image sample to be inspected is classified into the positive sample set; A parameter setting module is used for the negative sample additional module to capture the number of image samples to be tested and negative samples from the visual detection basic model and the negative sample set. If the ratio of the number of negative samples to the image samples to be tested is lower than the ratio threshold, the specific prediction parameter of the visual detection enhancement model is doubled from the initial value; if the ratio of the number of negative samples to the image samples to be tested is not lower than the ratio threshold, the initial value of the specific prediction parameter is retained; and at least one negative sample from the positive sample set and the negative sample set is combined into a second image sample set to be tested; The second training module is used to bring the second image sample set to be inspected into the visual detection enhancement model for secondary supervised training. If the model reasoning is NG, the output detection result is a negative sample; if the model reasoning is OK, the output detection result is a positive sample; if the model reasoning is Null, the output detection result is Null.
[0032] This example uses a 35-pin model 9637S electronic component from a certain manufacturer as an example. This component contains two types of physical parts, referred to here as Type A and Type B. The number of samples for Type A and Type B is balanced and sufficient. The number of samples for the 10 types of NG images classified by the manufacturer is balanced and sufficient. For extreme NG parts, the number of physical parts and images needs to be doubled. The specific distribution of training data is as follows: Assuming that the number of ng points (position points) of 9637S is x, then the number of ng samples in a set is x. The training data requirements are as follows:
[0033] In addition, for extreme parts, physical samples and images twice as many as those for ordinary parts are required.
[0034] Here are the distribution tables for the two models: Table 1 Data distribution table of model A
[0035] The ratio of training set to validation set is 6.3:1; the ratio of positive and negative samples is 1:1 Table 2 Data distribution table of model C
[0036] The ratio of training set to validation set is 5.9:1; the ratio of positive and negative samples is 1.2:1 In principle, supervised learning models distribute the data of training set, validation set, and test set in a ratio of at least 3:1:1, and ensure that each data set has full coverage of ng, and the ratio of OK to NG data is 1:1. The above data distribution scheme is a basic method. In practice, it can be flexibly adjusted according to the actual situation of the data and the optimization needs of each model. The parameter command for model training is: yolo detect train data=iriso.yaml model=yolov8s.pt epochs=500 imgsz=736 patience=50 batch=16 device=0,1 The A+C model was used to test three types of electronic components from the same manufacturer, including 18-pin, 35-pin, and 40-pin products. The 35-pin product includes two sub-types, Type A and Type B, for a total of four products. The results are shown in Table 3: Table 3 Test results
[0037] The results show that the negative sample detection rate of all products is 100%, and the missed detection rate is 0%; the positive sample detection rate of 35-pin type A and 18-pin is 100%, and the pass rate is 0%; 8 pieces of 35-pin type B passed the inspection, and after manual verification, it was found that the 8 pieces that passed the inspection were all mixed in products from other manufacturers, so the actual pass rate was 0%; 2 pieces of 40-pin passed the inspection, and after manual verification, it was found that the 2 pieces that passed the inspection were defective products that had been self-inspected by the factory, so the actual pass rate was 0%; in summary, the positive and negative sample detection rates of the four products are all 100%, and the false detection rate is 0%.
[0038] Table 4 is the complete parameter table of Model A and Model C: Table 4 Complete parameters of Model A and Model C
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048] Among them, the model deployment APIs are as follows: # API code for Model A: iriso_dtc_A.py import argparse from ultralytics import YOLO import numpy as np import sys from torch import Tensor from typing import Any import cv2 import matplotlib.pyplot as plt path = 'D: / YOLO8 / Yolo / datasets / Iriso711 / anomalib / ng4anomalib / iriso_9.jpg' model = YOLO('D: / YOLO8 / Yolo / datasets / Iriso711 / yolo / train27 / weights / best.pt') result3 = model(path, imgsz=640) mask = result3[0].orig_img.copy() cls, xywh = result3[0].boxes.cls, result3[0].boxes.xywh cls_, xywh_ = cls.detach().cpu().numpy(), xywh.detach().cpu().numpy() font=cv2.FONT_HERSHEY_SIMPLEX labels = 'ng' i=0 for pos, cls_value in zip(xywh_, cls_): It should be noted that there seems to be a typo in line where "0000192" is likely an incorrect encoding. It should probably be "0000192". pt1, pt2 = (np.int_([pos[0] - pos[2] / 2, pos[1] - pos[3] / 2]), np.int_([pos[0] + pos[2] / 2, pos[1] + pos[3] / 2])) color = [0, 0, 255] if cls_value == 0 else [0, 255, 0] [[ID=Z]]str0 = labels+str(': ')+str(round(result3[0].boxes.conf[i].item(),4)) cv2.rectangle(mask, tuple(pt1), tuple(pt2), color, 2) mask=cv2.putText(mask,str0,tuple(pt1),font,1.2,(0,255,255),3) i+=1 if len(result3[0].boxes.cls)>0 : label = 'Predict_1: NG' else: label = 'Predict_1: OK' plt.imshow(mask, cmap='hot') str1 = label+str('! ') plt.title(str1,bbox=dict(facecolor='y', edgecolor='red', alpha=0.65)) plt.savefig('predictions.mask.png') # API code for Model C: iriso_dtc_C.py import argparse from ultralytics import YOLO import numpy as np import sys from torch import Tensor It should be noted that there seems to be a mislabeling in the translation of line 7 where 'Z' is used instead of '7' in the original text. This is likely a typo in the original input for the translation task.from typing import Any import cv2 import matplotlib.pyplot as plt path = 'D: / YOLO8 / Yolo / datasets / Iriso711 / anomalib / ng4anomalib / iriso_9.jpg' model = YOLO('D: / YOLO8 / Yolo / datasets / Iriso711 / yolo / train27 / weights / best.pt') result3 = model(path, imgsz=640) mask = result3[0].orig_img.copy() cls, xywh = result3[0].boxes.cls, result3[0].boxes.xywh cls_, xywh_ = cls.detach().cpu().numpy(), xywh.detach().cpu().numpy() font=cv2.FONT_HERSHEY_SIMPLEX labels = 'ng' i=0 for pos, cls_value in zip(xywh_, cls_): pt1, pt2 = (np.int_([pos[0] - pos[2] / 2, pos[1] - pos[3] / 2]), np.int_([pos[0] + pos[2] / 2, pos[1] + pos[3] / 2])) color = [0, 0, 255] if cls_value == 0 else [0, 255, 0] str0 = labels+str(': ')+str(round(result3[0].boxes.conf[i].item(),4)) cv2.rectangle(mask, tuple(pt1), tuple(pt2), color, 2) mask=cv2.putText(mask,str0,tuple(pt1),font,1.2,(0,255,255),3) i+=1 if result3[0].boxes.cls.item() == 1: label = 'Good' else: label = 'NG' plt.imshow(mask, cmap='hot') str1 = label+str('! ') plt.title(str1,bbox=dict(facecolor='y', edgecolor='red', alpha=0.65)) plt.savefig('predictions.mask.png') In summary, the method of the present invention employs a joint training scheme for a basic visual inspection model and an enhanced visual inspection model. Furthermore, a negative sample supplementary module is added to adjust specific prediction parameters based on the proportion of negative samples. This results in high inference accuracy and speed, significantly reducing the model's missed detection rate and over-detection rate, thereby achieving the high-precision and high-detection rate requirements for electronic component inspection. Through the complementary secondary inference of Model A and Model C, the positive and negative sample detection rates for electronic components are infinitely close to 100%.
[0049] This embodiment also includes an electronic device and a storage medium. Figure 5 This is a schematic diagram of the structure of an electronic device according to the present invention. An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements each step of a method for visually detecting electronic component defects based on a positive-negative dual-recognition AI model. A storage medium stores the computer program. When the processor executes the computer program, it implements each step of a method for visually detecting electronic component defects based on a positive-negative dual-recognition AI model.
[0050] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of the present application may be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0051] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0052] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0053] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0054] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0055] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A visual inspection method for electronic component defects based on a positive and negative sample dual recognition AI model, characterized in that: The following steps are involved: Obtaining image samples of electronic components to be inspected as a first image sample set to be inspected, and manually identifying positive and negative samples of each image sample to be inspected as true attributes of the image sample to be inspected; The first image sample set is brought into the visual detection basic model for supervised training. If the model reasoning is NG, the image sample set is classified into the initial negative sample set; if the model reasoning is OK, the image sample set is classified into the positive sample set; The negative sample addition module captures the number of image samples to be inspected and negative samples from the visual detection basic model and the negative sample set. If the ratio of the number of negative samples to the number of image samples to be inspected is lower than the ratio threshold, the specific prediction parameters of the visual detection enhancement model are doubled from the initial value; if the ratio of the number of negative samples to the number of image samples to be inspected is not lower than the ratio threshold, the initial value of the specific prediction parameter is retained; and forming a second image to-be-tested sample set with at least one negative sample in the positive sample set and the negative sample set; The second image sample set to be inspected is brought into the visual detection enhancement model for secondary supervised training. If the model reasoning is NG, the output detection result is a negative sample; If the model inference is OK, the output detection result is a positive sample; If the model inference is Null, the output detection result is Null.
2. The electronic component defect visual detection method based on the positive and negative sample dual recognition AI model according to claim 1 is characterized in that: NG means that a negative sample is detected, regardless of whether a positive sample is detected at the same time; OK means that a positive sample is detected, and no negative sample is detected at the same time; Null means that neither a positive sample nor a negative sample is detected, and a new defect has appeared in the marked positive sample.
3. The electronic component defect visual detection method based on the positive and negative sample dual recognition AI model according to claim 1 is characterized in that: The ratio threshold refers to the number of negative samples accounting for 4 / 10 of the samples to be tested in the image.
4. The electronic component defect visual detection method based on the positive and negative sample dual recognition AI model according to claim 1 is characterized in that: The specific prediction parameters are conf, iou and max_det.
5. The electronic component defect visual detection method based on the positive and negative sample dual recognition AI model according to claim 4 is characterized in that: The initial values of conf, iou, and max_det are 0.25, 0.7, and 300, respectively.
6. The electronic component defect visual detection method based on the positive and negative sample dual recognition AI model according to claim 2 is characterized in that: Both the visual inspection basic model and the visual inspection enhanced model use the Yolov8 model; The Backbone module of the described visual detection basic model uses C2f; the Neck module uses SPPF; and the Head module uses the Transformer module. During training, the Backbone, Neck, and Head modules are first initialized, and the first 10 epochs of the Backbone are frozen. Then, SGD and Momentum are used as optimizers, and OneCycleLR is adopted for learning rate scheduling. The gradients of 4 batches are accumulated before updating, and gradient clipping is performed to prevent gradient explosion. Flash Attention is used to accelerate the Transformer, and Dropout is added to the Transformer Head for regularization. The training loss, mAP@0.5, and GPU memory usage are monitored. Finally, the gradient of C2f is checked, and the attention weight of the Transformer is visualized.
7. The electronic component defect visual detection method based on the positive and negative sample dual recognition AI model according to claim 6 is characterized in that: The backbone module of the visual detection enhancement model includes Focus and CSPNet. The first 14 layers use CSPDarknet53, which includes three sets of continuous convolutions, expands the input channels to 96, and introduces the Swish3 activation function. The cross-stage connection ratio is adjusted to 1:
2. Each CSP block contains two 3×3 convolutions, reduces the number of parameters through depthwise separable convolutions, and expands the receptive field to 1536×1536 through 4×4 dilated convolutions, while only increasing the number of parameters by 12%. The Neck module uses the PANet structure and introduces the SimAM attention mechanism. It implements adaptive adjustment of channel dimensions through five groups of 1×1 convolutions, improving feature reuse efficiency by 37%. The head module uses the Transformer module, uses a 12-head attention mechanism, and the head dimension is 64.
8. A visual inspection device for electronic component defects based on a positive and negative sample dual recognition AI model, characterized in that: include: A sample acquisition module is used to acquire image samples of electronic components to be inspected as a first image sample set to be inspected, and manually identify positive and negative samples of each image sample to be inspected as the true attributes of the image sample to be inspected; The first training module is used to bring the first image sample set to be inspected into the visual detection basic model for supervised training. If the model reasoning is NG, the image sample to be inspected is classified into the initial negative sample set; if the model reasoning is OK, the image sample to be inspected is classified into the positive sample set; A parameter setting module is used for the negative sample additional module to capture the number of image samples to be inspected and negative samples from the visual detection basic model and the negative sample set. If the ratio of the number of negative samples to the image samples to be inspected is lower than the ratio threshold, the specific prediction parameters of the visual detection enhancement model are doubled from the initial value; if the ratio of the number of negative samples to the image samples to be inspected is not lower than the ratio threshold, the initial value of the specific prediction parameter is retained; and forming a second image to-be-tested sample set with at least one negative sample in the positive sample set and the negative sample set; The second training module is used to bring the second image sample set to be inspected into the visual detection enhancement model for secondary supervised training. If the model reasoning is NG, the output detection result is a negative sample; If the model inference is OK, the output detection result is a positive sample; If the model inference is Null, the output detection result is Null.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, each step of the method for visually detecting defects in electronic components based on a positive and negative sample dual recognition AI model as described in any one of claims 1 to 7 is implemented.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the method for visually detecting defects in electronic components based on a positive and negative sample dual recognition AI model as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Real-time robust two-stage attitude estimation method
CN114842389A
Method and device based on small sample target object defect detection and electronic equipment
CN114881989A
PCB defect image detection method based on improved deep learning algorithm
CN115409797A
Model training method and target equipment identification method
CN118736278A
Method and apparatus for detecting small target, electronic device, computer readable storage medium, and computer program
JP2021179971A