An electronic component defect visual detection method and device based on a positive and negative sample double-recognition AI model, an electronic device, and a storage medium

By jointly training and adjusting the parameters of the AI ​​model based on dual recognition of positive and negative samples, the problem of failing to effectively identify new types of negative samples in existing technologies has been solved, achieving high precision and high detection rate in the detection of electronic components.

CN120726033BActive Publication Date: 2025-11-18HANGZHOU ZHISIDA TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511175462.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-21
Publication Date
2025-11-18
Estimated Expiration
2045-08-21

AI Technical Summary

Technical Problem

Existing AI visual inspection models struggle to effectively identify new types of negative samples that have not been learned before in the inspection of defects in electronic components, resulting in a high false negative rate and failing to meet the high detection rate requirements of industrial production.

Method used

A dual-recognition AI model based on positive and negative samples is adopted. By jointly training the basic visual detection model and the enhanced model, and by using the negative sample supplementary module to adjust specific prediction parameters according to the proportion of negative samples, the accurate recognition of new types of negative samples can be achieved.

Benefits of technology

It greatly reduces the false negative rate and false positive rate of the model, and achieves high accuracy and high detection rate of electronic component detection, with a positive and negative sample detection rate of nearly 100%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120726033B_ABST
    Figure CN120726033B_ABST
Patent Text Reader

Abstract

The application discloses a kind of electronic component defect visual inspection method, device, electronic equipment and storage medium based on positive and negative sample double identification AI model belonging to visual detection technical field.The method comprises: obtaining the image of electronic component as first image sample set, and manually identifying the positive and negative sample of each image sample, as the true attribute of image sample;First image sample set is brought into visual inspection basic model and is supervised training;Negative sample additional module is from visual inspection basic model and negative sample set and grabs the number of image sample and negative sample in negative sample set, carries out initial value setting, and at least one negative sample in positive sample set and negative sample set is formed into second image sample set;Second image sample set is brought into visual inspection enhanced model and is supervised training again.The present application has high inference accuracy and fast inference speed, which greatly reduces the missed detection rate and over detection rate of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic data processing technology, and in particular to a method, apparatus, electronic device, and storage medium for visual inspection of defects in electronic components based on a dual positive and negative sample recognition AI model. Background Technology

[0002] Currently, AI technology is widely used in visual inspection tasks for industrial electronic products, with AI visual defect detection of electronic components being a crucial application. AI visual defect detection of electronic components has high requirements. On one hand, defects in electronic components are generally very small, demanding high precision from AI detection technology; on the other hand, the required detection rate for electronic component defects in production is also high. Adding to the challenge is the generally limited accumulation of negative samples for electronic components. Traditional AI visual inspection models are mostly based on supervised learning algorithms using negative samples. This requires labeling a large number of negative samples to train the model, enabling it to accurately identify previously learned negative samples and generalize to similar negative samples. However, it cannot effectively identify newly occurring negative samples with significant feature differences or those not previously learned by the model. Furthermore, the AI ​​model needs a sufficiently rich number of negative samples to learn from; otherwise, the trained AI model will have a high false negative rate, making it difficult to achieve the high detection rate required for electronic component inspection. Existing technical solutions mainly fall into three categories:

[0003] A. Maintain and iteratively improve the existing supervised learning model for negative samples, wait for and accumulate new types of negative samples that occur in production, add them to the existing negative sample dataset, and retrain the AI ​​model to enable it to identify new types of negative samples.

[0004] B. Replace the supervised learning model for negative samples with an unsupervised learning model to train the existing dataset, so that it can not only identify some existing negative samples, but also partially identify new types of negative samples.

[0005] C. Apply generative AI models to simulate new types of negative samples that have not yet occurred, and add them to the existing negative sample set for training of the supervised learning model of negative samples, so that it can partially identify the new types of negative samples that have occurred.

[0006] The above technical solutions each have the following drawbacks:

[0007] Solution A cannot autonomously identify new types of negative samples and can only wait for new types of negative samples to occur before adding training. This affects the recognition accuracy of the existing AI model and the model improvement cycle is too long, which cannot meet the quality inspection requirements of industrial production.

[0008] Option B directly applies an unsupervised learning model. Although it can autonomously identify some new types of negative samples, due to the limitations of its own algorithm, the overall recognition accuracy of the unsupervised learning model is lower than that of the supervised learning model, making it difficult to meet the quality inspection requirements of industrial production.

[0009] Solution C uses a generative AI model, which can simulate new types of negative samples that have not yet occurred. However, due to the unique characteristics of defects in industrial products, it is difficult for generative AI models 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.

[0010] Meanwhile, in the product inspection of electronic components, the requirements for production quality inspection are often very close to 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 before, and at the same time, the detection rate of both positive and negative samples can reach over 99.99%. Summary of the Invention

[0011] The purpose of this invention is to propose a visual inspection method, device, electronic device, and storage medium for defects in electronic components based on a dual positive and negative sample recognition AI model.

[0012] A visual inspection method for defects in electronic components based on a dual-recognition AI model of positive and negative samples includes the following steps:

[0013] The first image sample set is obtained by acquiring images of electronic components to be inspected, and the positive and negative samples of each image sample are manually identified as the true attributes of the image sample to be inspected.

[0014] The first set of images to be inspected is fed into the visual detection base model for supervised training. If the model inference is NG, the images to be inspected are assigned to the initial negative sample set; if the model inference is OK, the images to be inspected are assigned to the positive sample set.

[0015] The negative sample supplementary module extracts the number of image test samples and negative samples from the visual detection base model and the negative sample set. If the number of negative samples accounts for less than the proportion threshold of the image test samples, the specific prediction parameters of the visual detection enhancement model are doubled from their initial values. If the number of negative samples accounts for more than or equal to the proportion threshold of the image test samples, the initial values ​​of the specific prediction parameters are retained. At least one negative sample from the positive sample set and the negative sample set are combined to form a second image test sample set.

[0016] The second set of images to be inspected is fed into the visual detection enhancement model for secondary supervised training. If the model inference 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.

[0017] Furthermore, NG indicates that a negative sample was detected, regardless of whether a positive sample was detected at the same time; OK indicates that a positive sample was detected, and no negative samples were detected at the same time; Null indicates that neither a positive sample nor a negative sample was detected, and a new defect appeared in the labeled positive sample.

[0018] Furthermore, the proportion threshold refers to the number of negative samples accounting for 4 / 10 of the images to be inspected.

[0019] Furthermore, the specific prediction parameters are conf, iou, and max_det.

[0020] Furthermore, the initial values ​​of conf, iou, and max_det are 0.25, 0.7, and 300, respectively.

[0021] Furthermore, both the basic visual detection model and the visual detection enhancement model adopt the Yolov8 model;

[0022] The visual detection base model uses C2f for the backbone module, SPPF for the neck module, and a Transformer module for the head 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 used for learning rate scheduling. Gradients are accumulated for 4 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 attention weights of the Transformer are visualized.

[0023] Furthermore, the backbone module of the visual detection enhancement model includes Focus and CSPNet. The first 14 layers use CSPDarknet53, containing 3 sets of consecutive convolutions, expanding the input channels to 96, and introducing the Swish3 activation function; the cross-stage partial connection ratio is adjusted to 1:2; each CSP block contains 2 3×3 convolutions, reducing the number of parameters through depthwise separable convolutions, and expanding the receptive field to 1536×1536 through 4×4 dilated convolutions, while the number of parameters only increases by 12%.

[0024] The Neck module uses the PANet architecture and introduces the SimAM attention mechanism. It achieves adaptive adjustment of channel dimensions through 5 groups of 1×1 convolutions, which improves the efficiency of feature reuse by 37%.

[0025] The Head module uses the Transformer module and employs a 12-head attention mechanism with a head dimension of 64.

[0026] A visual inspection device for defects in electronic components based on a dual-recognition AI model of positive and negative samples, comprising:

[0027] The sample acquisition module is used to acquire image samples of electronic components as the first image sample set and manually identify the positive and negative samples of each image sample as the true attributes of the image sample.

[0028] The first training module is used to input the first set of image samples to be inspected into the visual detection base model for supervised training. If the model inference is NG, the image samples to be inspected are assigned to the initial negative sample set; if the model inference is OK, the image samples to be inspected are assigned to the positive sample set.

[0029] The parameter setting module is used by the negative sample addition module to extract the number of image test samples and negative samples from the visual detection base model and the negative sample set. If the number of negative samples accounts for less than the proportion threshold of the image test samples, the specific prediction parameters of the visual detection enhancement model are doubled from their initial values. If the number of negative samples accounts for more than or equal to the proportion threshold of the image test samples, the initial values ​​of the specific prediction parameters are retained. At least one negative sample from the positive sample set and the negative sample set are combined to form a second image test sample set.

[0030] The second training module is used to input the second set of images to be inspected into the visual detection enhancement model for secondary supervised training. If the model inference 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.

[0031] 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 the various steps in a visual inspection method for defects in electronic components based on a dual-recognition AI model of positive and negative samples.

[0032] A storage medium storing a computer program that, when executed by a processor, implements the various steps of a visual inspection method for defects in electronic components based on a dual-recognition AI model of positive and negative samples.

[0033] The beneficial effects of this invention are as follows:

[0034] The method of this invention adopts a scheme of joint training of a visual detection base model and a visual detection enhancement model. In addition, the negative sample supplementary module adjusts 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 false negative rate and false positive rate of the model, thereby achieving the high precision and high detection rate requirements of electronic component detection. Attached Figure Description

[0035] Figure 1 This is a flowchart of the electronic component defect visual inspection method based on a positive and negative sample dual recognition AI model according to the present invention.

[0036] Figure 2 This is a schematic diagram of the model algorithm reasoning in an embodiment of the present invention;

[0037] Figure 3 A schematic diagram of the labeled area for image acquisition of a 35-pin electronic component;

[0038] Figure 4 This is a schematic diagram of a visual inspection device for defects in electronic components based on a dual positive and negative sample recognition AI model.

[0039] Figure 5 This is a schematic diagram of the structure of the electronic device of the present invention. Detailed Implementation

[0040] This invention proposes a visual inspection method, device, electronic device, and storage medium for defects in electronic components based on a dual positive and negative sample recognition AI model. The invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0041] Figure 1 This is a flowchart of the electronic component defect visual inspection method based on a positive and negative sample dual recognition AI model according to the present invention. Figure 2 This is a schematic diagram of the model algorithm inference in an embodiment of the present invention, specifically as follows:

[0042] The first image sample set is obtained by acquiring images of electronic components to be inspected, and the positive and negative samples of each image sample are manually identified as the true attributes of the image sample to be inspected.

[0043] The first set of images to be inspected is fed into the visual detection base model for supervised training. If the model inference is NG, the images to be inspected are assigned to the initial negative sample set; if the model inference is OK, the images to be inspected are assigned to the positive sample set.

[0044] The negative sample supplementary module extracts the number of image test samples and negative samples from the visual detection base model and the negative sample set. If the number of negative samples accounts for less than the proportion threshold of the image test samples, the specific prediction parameters of the visual detection enhancement model are doubled from their initial values. If the number of negative samples accounts for more than or equal to the proportion threshold of the image test samples, the initial values ​​of the specific prediction parameters are retained. At least one negative sample from the positive sample set and the negative sample set are combined to form a second image test sample set.

[0045] The second set of images to be inspected is fed into the visual detection enhancement model for secondary supervised training. If the model inference 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.

[0046] The proportion threshold is set to 4 / 10 of the image samples to be inspected. The following are some of the inferred results:

[0047] 1) OK -> The sample report is "OK"

[0048] 2) NG -> Report sample as "NG"

[0049] 3) OK*NG -> Report sample as "NG"

[0050] 4) Null (no detections) -> Reports the sample as "NG"

[0051] in:

[0052] An OK output indicates that the positive sample target has been detected, and no other NGs have been identified.

[0053] The output NG indicates that the NG target of the negative sample has been detected, regardless of whether positive sample targets are identified at the same time.

[0054] An output of null indicates that neither a positive nor a negative target was detected. In this case, an unknown NG (Not Given) should have appeared in the region marked with a positive target, which is a new negative sample.

[0055] The positive sample annotation method is as follows:

[0056] Yolo annotation and file conversion:

[0057] Method 1: Target detection: Labellim annotation

[0058] Yolo format: Labels OK / NG with rectangles and save directly as .txt files [x,y,w,h].

[0059] Method 2: Target detection: Label annotation

[0060] Label the rectangle with OK / NG and store it in .json format [x1,y1,x2,y2].

[0061] After annotation, store all .json files in a new folder, such as train_json / val_json. Also create a new txt folder. Open Jupyter Lab, navigate to json2txt.ipynb, and modify it as follows:

[0062] parser.add_argument('--json-dir', type=str,default='D: / Yolo / datasets / iriso / images / val_json', help='json path dir')

[0063] parser.add_argument('--save-dir', type=str,default='D: / Yolo / datasets / iriso / images / txt' ,help='txt save dir')

[0064] Set the folder paths for '--json-dir' and '--save-dir' in the configuration, and modify them accordingly:

[0065] In `parser.add_argument('--classes', type=str, default='ng,ok',help='classes')`, add the actual classes for '--classes'. Finally, run `json2txt.ipynb` to copy the files from the `txt` folder to either `labels\train` or `labels\val` in the dataset.

[0066] Figure 3A schematic diagram of the image acquisition and annotation area for a 35-pin electronic component: Starting from the lower edge of the pin on the electronic component, including the farthest hardware at both ends, the image is acquired downwards to the lower edge of the left and right housings.

[0067] Model and training data:

[0068] The visual detection base model (Model A) uses C2f for the Backbone module, SPPF for the Neck module, and a Transformer module for the Head 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 used 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 attention weights of the Transformer are visualized.

[0069] The backbone module of the visual detection enhancement model (Model C) includes Focus and CSPNet. The first 14 layers use CSPDarknet53, containing 3 sets of consecutive convolutions, expanding the input channels to 96, and introducing the Swish3 activation function. The cross-stage partial connection ratio is adjusted to 1:2. Each CSP block contains two 3×3 convolutions. The number of parameters is reduced by depthwise separable convolutions, and the receptive field is expanded to 1536×1536 by 4×4 dilated convolutions, while the number of parameters only increases by 12%.

[0070] The Neck module uses the PANet architecture and introduces the SimAM attention mechanism. It achieves adaptive adjustment of channel dimensions through 5 groups of 1×1 convolutions, which improves the efficiency of feature reuse by 37%.

[0071] The Head module uses the Transformer module and employs a 12-head attention mechanism with a head dimension of 64.

[0072] Figure 4 This is a schematic diagram of a visual inspection device for electronic component defects based on a dual-recognition AI model using positive and negative samples, including:

[0073] The sample acquisition module is used to acquire image samples of electronic components as the first image sample set and manually identify the positive and negative samples of each image sample as the true attributes of the image sample.

[0074] The first training module is used to input the first set of image samples to be inspected into the visual detection base model for supervised training. If the model inference is NG, the image samples to be inspected are assigned to the initial negative sample set; if the model inference is OK, the image samples to be inspected are assigned to the positive sample set.

[0075] The parameter setting module is used by the negative sample addition module to extract the number of image test samples and negative samples from the visual detection base model and the negative sample set. If the number of negative samples accounts for less than the proportion threshold of the image test samples, the specific prediction parameters of the visual detection enhancement model are doubled from their initial values. If the number of negative samples accounts for more than or equal to the proportion threshold of the image test samples, the initial values ​​of the specific prediction parameters are retained. At least one negative sample from the positive sample set and the negative sample set are combined to form a second image test sample set.

[0076] The second training module is used to input the second set of images to be inspected into the visual detection enhancement model for secondary supervised training. If the model inference 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.

[0077] This embodiment uses a 35-pin electronic component 9637S from a certain manufacturer as an example, which includes physical components of two materials, referred to here as Type A and Type B. The sample sizes for Type A and Type B are ensured to be balanced and sufficient; the sample sizes for the 10 categories of out-of-place (NG) images defined by the original manufacturer are also balanced and sufficient; for extremely NG components, the number of physical components and images needs to be doubled. The specific distribution of the training data is as follows:

[0078] Assuming the number of ng points (location points) of 9637S is x, then the number of ng samples in one set is x. The training data requirements are as follows:

[0079]

[0080] In addition, for extreme ng parts, twice the physical sample and images are required for ordinary ng parts.

[0081] The following are the distribution tables for the two models:

[0082] Table 1 Data Distribution Table for Model A

[0083]

[0084] The ratio of training set to validation set is 6.3:1; the ratio of positive to negative samples is 1:1.

[0085] Table 2 Data Distribution Table for Model C

[0086]

[0087] The ratio of training set to validation set is 5.9:1; the ratio of positive to negative samples is 1.2:1.

[0088] In principle, supervised learning models should allocate training, validation, and test sets in a ratio of at least 3:1:1, ensuring full coverage of the ng (good) and NG (good) datasets for each model, with an OK to NG ratio of 1:1. This data distribution scheme is a basic approach; in practice, it should be flexibly adjusted based on the actual data and the optimization needs of each model. The model training parameter command is: yolo detect train data=iriso.yaml model=yolov8s.pt epochs=500 imgsz=736patience=50 batch=16 device=0,1

[0089] For three main categories of electronic components from the same manufacturer—18-pin, 35-pin, and 40-pin—including two sub-types, A and B, totaling four products, the A+C model was applied for testing. The results are shown in Table 3.

[0090] Table 3 Test Results

[0091]

[0092] The results showed that the negative sample detection rate for all products was 100%, and the false negative rate was 0%; the positive sample detection rate for 35-needle type A and 18-needle types was 100%, and the pass rate was 0%; 8 pieces of 35-needle type B passed the test, but manual verification revealed that all 8 pieces were products from other manufacturers that had been mixed in, so the actual pass rate was 0%; 2 pieces of 40-needle type passed the test, but manual verification revealed that both pieces were defective products that had been inspected by the factory itself, so the actual pass rate was 0%; In summary, the positive and negative sample detection rates for all four types of products were 100%, and the false negative rate was 0%.

[0093] Table 4 is the complete parameter table for Model A and Model C:

[0094] Table 4. Complete parameters for Model A and Model C

[0095]

[0096]

[0097]

[0098]

[0099]

[0100]

[0101]

[0102]

[0103]

[0104]

[0105] The model deployment APIs are as follows:

[0106] # API code for Model A: iriso_dtc_A.py

[0107] import argparse

[0108] from ultralytics import YOLO

[0109] import numpy as np

[0110] import sys

[0111] from torch import Tensor

[0112] from typing import Any

[0113] import cv2

[0114] import matplotlib.pyplot as plt

[0115] path = 'D: / YOLO8 / Yolo / datasets / Iriso711 / anomalib / ng4anomalib / iriso_9.jpg'

[0116] model = YOLO('D: / YOLO8 / Yolo / datasets / Iriso711 / yolo / train27 / weights / best.pt')

[0117] result3 = model(path, imgsz=640)

[0118] mask = result3[0].orig_img.copy()

[0119] cls, xywh = result3[0].boxes.cls, result3[0].boxes.xywh

[0120] cls_, xywh_ = cls.detach().cpu().numpy(), xywh.detach().cpu().numpy()

[0121] font=cv2.FONT_HERSHEY_SIMPLEX

[0122] labels = 'ng'

[0123] i=0

[0124] for pos, cls_value in zip(xywh_, cls_):

[0125] pt1, pt2 = (np.int_([pos[0] - pos[2] / 2, pos[1] - pos[3] / 2]),

[0126] np.int_([pos[0] + pos[2] / 2, pos[1] + pos[3] / 2]))

[0127] color = [0, 0, 255] if cls_value == 0 else [0, 255, 0]

[0128] str0 = labels+str(': ')+str(round(result3[0].boxes.conf[i].item(),4))

[0129] cv2.rectangle(mask, tuple(pt1), tuple(pt2), color, 2)

[0130] mask=cv2.putText(mask,str0,tuple(pt1),font,1.2,(0,255,255),3)

[0131] i+=1

[0132] if len(result3[0].boxes.cls)>0 :

[0133] label = 'Predict_1: NG'

[0134] else:

[0135] label = 'Predict_1: OK'

[0136] plt.imshow(mask, cmap='hot')

[0137] str1 = label+str('! ')

[0138] plt.title(str1,bbox=dict(facecolor='y', edgecolor='red', alpha=0.65 ))

[0139] plt.savefig('predictions.mask.png')

[0140] # API code for Model C: iriso_dtc_C.py

[0141] import argparse

[0142] from ultralytics import YOLO

[0143] import numpy as np

[0144] import sys

[0145] from torch import Tensor

[0146] from typing import Any

[0147] import cv2

[0148] import matplotlib.pyplot as plt

[0149] path = 'D: / YOLO8 / Yolo / datasets / Iriso711 / anomalib / ng4anomalib / iriso_9.jpg'

[0150] model = YOLO('D: / YOLO8 / Yolo / datasets / Iriso711 / yolo / train27 / weights / best.pt')

[0151] result3 = model(path, imgsz=640)

[0152] mask = result3[0].orig_img.copy()

[0153] cls, xywh = result3[0].boxes.cls, result3[0].boxes.xywh

[0154] cls_, xywh_ = cls.detach().cpu().numpy(), xywh.detach().cpu().numpy()

[0155] font=cv2.FONT_HERSHEY_SIMPLEX

[0156] labels = 'ng'

[0157] i=0

[0158] for pos, cls_value in zip(xywh_, cls_):

[0159] pt1, pt2 = (np.int_([pos[0] - pos[2] / 2, pos[1] - pos[3] / 2]),

[0160] np.int_([pos[0] + pos[2] / 2, pos[1] + pos[3] / 2]))

[0161] color = [0, 0, 255] if cls_value == 0 else [0, 255, 0]

[0162] str0 = labels+str(': ')+str(round(result3[0].boxes.conf[i].item(),4))

[0163] cv2.rectangle(mask, tuple(pt1), tuple(pt2), color, 2)

[0164] mask=cv2.putText(mask,str0,tuple(pt1),font,1.2,(0,255,255),3)

[0165] i+=1

[0166] if result3[0].boxes.cls.item() == 1:

[0167] label = 'Good'

[0168] else:

[0169] label = 'NG'

[0170] plt.imshow(mask, cmap='hot')

[0171] str1 = label+str('! ')

[0172] plt.title(str1,bbox=dict(facecolor='y', edgecolor='red', alpha=0.65 ))

[0173] plt.savefig('predictions.mask.png')

[0174] In summary, the method of this invention employs a joint training scheme of a basic visual detection model and a visual detection enhancement model. The additional negative sample supplementary module adjusts specific prediction parameters based on the proportion of negative samples, resulting in high inference accuracy and fast inference speed. This significantly reduces the model's false negative and false positive rates, thereby achieving the high-precision and high-detection-rate requirements for electronic component detection. Through complementary secondary inference using the superposition of model A and model C, the detection rate of both positive and negative samples for electronic components approaches 100%.

[0175] This embodiment also includes an electronic device and a storage medium. Figure 5 This is a schematic diagram of the electronic device of 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 various steps in the visual inspection method for electronic component defects based on a positive and negative sample dual-recognition AI model. A storage medium stores a computer program thereon. When the computer program is executed by a processor, it implements various steps in the visual inspection method for electronic component defects based on a positive and negative sample dual-recognition AI model.

[0176] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can 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 this application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.

[0177] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0178] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0179] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0180] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0181] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A visual inspection method for defects in electronic components based on a dual-recognition AI model of positive and negative samples, characterized in that, Includes the following steps: The first image sample set is obtained by acquiring images of electronic components to be inspected, and the positive and negative samples of each image sample are manually identified as the true attributes of the image sample to be inspected. The first set of images to be inspected is fed into the visual detection base model for supervised training. If the model inference is NG, the images to be inspected are assigned to the initial negative sample set; if the model inference is OK, the images to be inspected are assigned to the positive sample set. The negative sample addition module extracts the number of image samples to be inspected and negative samples from the visual detection base model and the negative sample set. If the number of negative samples accounts for less than the proportion of image samples to be inspected, the specific prediction parameters of the visual detection enhancement model are doubled from their initial values. If the number of negative samples accounts for more than the proportion of image samples to be inspected, the initial values ​​of the specific prediction parameters are retained. The positive sample set and at least one negative sample from the negative sample set are combined to form the second image test sample set; The second set of images to be tested is fed into the visual detection enhancement model for secondary supervised training. If the model inference 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. NG indicates that a negative sample was detected, regardless of whether a positive sample was detected at the same time; OK indicates that a positive sample was detected, and no negative samples were detected at the same time; Null indicates that neither a positive sample nor a negative sample was detected, and a new defect appeared in the labeled positive sample. Both the basic visual inspection model and the visual inspection enhancement model use the Yolov8 model; The visual detection base model uses C2f for the Backbone module, SPPF for the Neck module, and a Transformer module for the Head 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 used for learning rate scheduling. Gradients are accumulated for 4 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 and GPU memory usage are monitored. Finally, the gradients of C2f are checked, and the attention weights of the Transformer are visualized. The backbone module of the visual detection enhancement model includes Focus and CSPNet. The first 14 layers use CSPDarknet53, containing 3 sets of consecutive convolutions, expanding the input channels to 96, and introducing the Swish3 activation function. The cross-stage partial connection ratio is adjusted to 1:

2. Each CSP block contains two 3×3 convolutions. The number of parameters is reduced by depthwise separable convolutions, and the receptive field is expanded to 1536×1536 by 4×4 dilated convolutions, while the number of parameters only increases by 12%. The Neck module uses the PANet architecture and introduces the SimAM attention mechanism. It achieves adaptive adjustment of channel dimensions through 5 groups of 1×1 convolutions, which improves the efficiency of feature reuse by 37%. The Head module uses the Transformer module and employs a 12-head attention mechanism with a head dimension of 64.

2. The method for visual inspection of defects in electronic components based on a dual-recognition AI model of positive and negative samples according to claim 1, characterized in that, The ratio threshold refers to the number of negative samples accounting for 4 / 10 of the image samples to be inspected.

3. The method for visual inspection of defects in electronic components based on a dual-recognition AI model of positive and negative samples according to claim 1, characterized in that, The specific prediction parameters are conf, iou, and max_det.

4. The method for visual inspection of defects in electronic components based on a dual-recognition AI model of positive and negative samples according to claim 3, characterized in that, The initial values ​​for conf, iou, and max_det are 0.25, 0.7, and 300, respectively.

5. A visual inspection device for defects in electronic components based on a dual-recognition AI model of positive and negative samples, characterized in that, include: The sample acquisition module is used to acquire image samples of electronic components as the first image sample set and manually identify the positive and negative samples of each image sample as the true attributes of the image sample. The first training module is used to input the first set of image samples to be inspected into the visual detection base model for supervised training. If the model inference is NG, the image samples to be inspected are assigned to the initial negative sample set; if the model inference is OK, the image samples to be inspected are assigned to the positive sample set. The parameter setting module is used by the negative sample addition module to extract the number of image samples to be inspected and negative samples from the visual detection base model and the negative sample set. If the number of negative samples accounts for less than the proportion threshold of the image samples to be inspected, the specific prediction parameters of the visual detection enhancement model are doubled from their initial values. If the number of negative samples accounts for more than or equal to the proportion threshold of the image samples to be inspected, the initial values ​​of the specific prediction parameters are retained. The positive sample set and at least one negative sample from the negative sample set are combined to form the second image test sample set; The second training module is used to input the second set of images to be inspected into the visual detection enhancement model for secondary supervised training. If the model inference 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. NG indicates that a negative sample was detected, regardless of whether a positive sample was detected at the same time; OK indicates that a positive sample was detected, and no negative samples were detected at the same time; Null indicates that neither a positive sample nor a negative sample was detected, and a new defect appeared in the labeled positive sample. Both the basic visual inspection model and the visual inspection enhancement model use the Yolov8 model; The visual detection base model uses C2f for the Backbone module, SPPF for the Neck module, and a Transformer module for the Head 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 used for learning rate scheduling. Gradients are accumulated for 4 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 and GPU memory usage are monitored. Finally, the gradients of C2f are checked, and the attention weights of the Transformer are visualized. The backbone module of the visual detection enhancement model includes Focus and CSPNet. The first 14 layers use CSPDarknet53, containing 3 sets of consecutive convolutions, expanding the input channels to 96, and introducing the Swish3 activation function. The cross-stage partial connection ratio is adjusted to 1:

2. Each CSP block contains two 3×3 convolutions. The number of parameters is reduced by depthwise separable convolutions, and the receptive field is expanded to 1536×1536 by 4×4 dilated convolutions, while the number of parameters only increases by 12%. The Neck module uses the PANet architecture and introduces the SimAM attention mechanism. It achieves adaptive adjustment of channel dimensions through 5 groups of 1×1 convolutions, which improves the efficiency of feature reuse by 37%. The Head module uses the Transformer module and employs a 12-head attention mechanism with a head dimension of 64.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements each step of the electronic component defect visual inspection method based on a positive and negative sample dual recognition AI model as described in any one of claims 1 to 4.

7. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements each step of the electronic component defect visual inspection method based on a positive and negative sample dual recognition AI model as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • PCB defect image detection method based on improved deep learning algorithm

    CN115409797A