PCB defect detection method and system based on improved yolov7 algorithm

By improving the network architecture of the YOLOv7 algorithm, the identification and positioning problems of PCB component detection in complex backgrounds are solved, and efficient, lightweight and high-precision detection performance is achieved, suitable for edge device deployment.

WO2025130088A1PCT designated stage expired Publication Date: 2025-06-26SHANGHAI SECOND POLYTECHNIC UNIVERSITY

Patent Information

Application Number
PCT/CN2024/111986
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-12-22
Filing Date
2024-08-14
Publication Date
2025-06-26

AI Technical Summary

Technical Problem

Existing PCB component detection technology is difficult to accurately identify and locate components of different sizes and shapes in complex contexts, and it is difficult to achieve efficient detection in an environment where computing resources are limited.

Method used

Improve the network architecture of the YOLOv7 algorithm, and enhance the optimization performance of feature extraction capabilities and loss functions by introducing RCSOSA module, WISE-IoU loss function and Focal Modulation network module, and improve the adaptability and robustness of the model.

Benefits of technology

Without increasing the calculation amount, the performance of PCB component detection is significantly improved, and lightweight, real-time and high-precision detection is achieved, which can meet the needs of edge devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024111986_26062025_PF_FP_ABST
    Figure CN2024111986_26062025_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of PCB component detection, and discloses a PCB defect detection method and system based on an improved YOLOv7 algorithm. The detection method comprises the following steps: S1, improving an original YOLOv7 network architecture to obtain an improved YOLOv7 network architecture; S2, acquiring a training dataset and a validation dataset of a PCB image, then using the training dataset to train the improved YOLOv7 network architecture, determining model parameters, and using the validation dataset to evaluate and optimize hyperparameters of a training model, and finally obtaining a deep learning model; and S3, inputting the PCB image to be detected into the deep learning model to obtain a detection result of a PCB component. By improving the YOLOv7 network architecture, a series of important structural modifications are performed on a YOLOv7 model, improving the performance and adaptability of the YOLOv7 model; an original ELAN-H structure is replaced with an RCSOSA module, enhancing the feature extraction capability; and the detection performance can be significantly improved without increasing the amount of calculation, and the characteristics of lightweight design, real-time performance, and high precision are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

A PCB defect detection method and system based on improved YOLOv7 algorithm Technical Field

[0001] The present invention relates to the technical field of PCB component detection, and in particular to a PCB defect detection method and system based on an improved YOLOv7 algorithm. Background Art

[0002] Components on PCBs often face complex and changing backgrounds, and objects vary in shape and size, making accurate identification and precise positioning challenging. Future research can focus on how to better handle these complex scenarios and improve the adaptability of detection models. This can also explore how to make deep learning models better adapt to varying PCB image variations, thereby enhancing detection robustness.

[0003] Existing research often relies on image processing methods based on color recognition or is limited by the diversity and quantity of training data. Future research could focus on expanding the training dataset to include more samples of PCB components of varying sizes and shapes to better train deep learning models. Furthermore, the introduction of new data modalities, such as thermal imaging or ultrasonic data, could be considered to provide more information to support PCB component inspection, thereby improving the accuracy and comprehensiveness of inspection.

[0004] To meet the demand for flexible detection, researchers need to continuously improve recognition accuracy while maintaining inference speed. This can be achieved through optimizing the hardware implementation of deep learning models, model compression techniques, and more efficient algorithms. With the development of edge computing and embedded devices, deploying deep learning models in real-world applications has become increasingly important. Therefore, future research can also focus on how to improve performance in resource-constrained environments to meet the needs of different application scenarios.

[0005] The field of PCB component inspection is full of challenges and opportunities. This paper aims to provide a PCB defect detection method and system based on the improved YOLOv7 algorithm through continuous research and innovation. This method can achieve better detection performance and provide higher-quality production and more reliable circuit function analysis for the circuit board manufacturing industry.

[0006] Summary of the Invention

[0007] In response to the shortcomings of the existing technology, the present invention provides a PCB defect detection method and system based on an improved YOLOv7 algorithm, aiming to achieve better performance in multimodal PCB component detection while meeting the limitations of computing resources.

[0008] To achieve the above objectives, the present invention is implemented through the following technical solutions: a PCB defect detection method based on an improved YOLOv7 algorithm, comprising the following method steps:

[0009] S1. Improve the original YOLOv7 network architecture to obtain an improved YOLOv7 network architecture;

[0010] S2. Obtain a training dataset and a validation dataset of PCB images. Then use the training dataset to train the improved YOLOv7 network architecture, determine the model parameters, and use the validation dataset to evaluate and optimize the hyperparameters of the training model, ultimately obtaining a deep learning model.

[0011] S3. The PCB image to be inspected is input into the deep learning model to obtain the inspection results of the PCB components.

[0012] Preferably, in step S1, the step of improving the original YOLOv7 network architecture includes:

[0013] S1-1, adopt a one-shot aggregation RCSOSA module based on RCS, combining RCSOSA and RepConv for path aggregation;

[0014] S1-2, adopt a dynamic non-monotonic FM loss method based on IOU Wise-IoU position loss function;

[0015] S1-3, introduce the Focal Modulation network module to improve the original network architecture.

[0016] Preferably, the RCSOSA module replaces the original ELAN-H structure, combines RCSOSA with RepConv to perform path aggregation, improves the performance of the feature extraction layer, enhances the feature representation ability of the network, and enables the network to better capture the characteristics and context information of the target.

[0017] Preferably, the expression of the WISE-IoU position loss function is:

[0018] Among them, L IoU 、R WIoU , r are the IoU position loss function, penalty term, and non-monotonic focusing coefficient, respectively, β is the outlier degree of the anchor box quality, L * IoU are the exponential running average with momentum and the monotonic focusing coefficient, respectively. α and δ are tiny parameters.

[0019] Preferably, the Focal Modulation network module is introduced to improve the original network architecture, specifically using Focal Modulation to replace SPPCSPC, so as to reduce information loss and improve the performance of the model for difficult-to-detect targets.

[0020] Preferably, in step S2, the step of obtaining the training dataset and the verification dataset of the PCB image includes:

[0021] S2-1. Collect PCB images of different resolutions, brightness and colors to form a multimodal PCB image dataset;

[0022] S2-2. Preprocess the obtained PCB image dataset to separate data subsets for training, verification, and testing, thereby forming a training dataset, a verification dataset, and a test dataset.

[0023] Preferably, the preprocessing of the obtained PCB image dataset specifically includes the following steps:

[0024] S2-21. Crop and flip the PCB image dataset and combine it with Cutout and AugMix techniques to obtain an expanded dataset, thereby improving the model training effect.

[0025] S2-22. In the expanded dataset, the PCB components in each image are labeled and categorized to provide accurate labeling information for subsequent deep learning model training.

[0026] A PCB defect detection system based on an improved YOLOv7 algorithm, including:

[0027] The network architecture building module is used to improve the original YOLOv7 network architecture and obtain the improved YOLOv7 network architecture;

[0028] The model training module is used to obtain training and validation datasets of PCB images for deep learning model training. The improved YOLOv7 network architecture is trained using the training dataset and the parameters of the training model are optimized. The trained model is evaluated using the validation dataset and the model's hyperparameters are tuned to obtain a trained and tuned deep learning model.

[0029] The result output module is used to input the PCB image to be inspected into the deep learning model to obtain the inspection results of the PCB components.

[0030] The present invention provides a PCB defect detection method and system based on an improved YOLOv7 algorithm. It has the following beneficial effects:

[0031] 1. This paper improves the YOLOv7 network architecture and makes a series of important structural modifications to the YOLOv7 model to improve its performance and adaptability. The RCSOSA module replaces the original ELAN-H structure, enhancing the feature extraction capability and enabling the network to better capture the characteristics and contextual information of the target. The reverse recursive path aggregation technology introduced by the RCSOSA module helps to understand the target more comprehensively.

[0032] 2. This invention replaces SPPCSPC by introducing Focal Modulation. This improvement improves the network's perception of targets of different scales in target detection tasks, helps reduce information loss, and improves the model's performance for difficult-to-detect targets. At the same time, WISE-IOU replaces the original CIoU loss function, improving the optimization performance of the loss function. The introduction of the WISE-IOU loss function reduces the degrees of freedom of the loss function and improves the robustness of the network, making it more suitable for different target detection scenarios. These structural modifications together make the YOLOv7 model more accurate to cope with diverse target detection challenges and perform better in various applications.

[0033] 3. The PCB component detection method provided by the present invention can significantly improve the detection performance without increasing the amount of calculation. It is lightweight, real-time, and highly precise, and can meet the needs of deployment on edge devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] FIG1 is a network structure diagram of YOLOv7 before the improvement of the detection method of the present invention;

[0035] FIG2 is a structural diagram of the RCS-OSA used in the detection method of the present invention;

[0036] FIG3 is an illustration of the WISE-IoU position loss function of the present invention;

[0037] FIG4 is a network structure diagram of YOLOv7 after the detection method of the present invention is improved;

[0038] FIG5 is a graph of mAP@0.5 before the improved algorithm in the present invention;

[0039] Figure 6 is a graph showing the mAP@0.5 curve after the improved algorithm in the present invention.

[0040] Figure 7 shows the detection effect of PCB components in different modes using the original YOLOv7.

[0041] FIG8 is a diagram showing the detection effects of the model of the present invention on PCB components in different modes. DETAILED DESCRIPTION

[0042] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the present specification. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0043] Example 1:

[0044] An embodiment of the present invention provides a PCB component detection method based on deep learning, which mainly includes the following steps:

[0045] S1. Improve the original YOLOv7 network architecture to obtain an improved YOLOv7 network architecture;

[0046] Specifically, in this step, the steps to improve the original YOLOv7 network architecture include:

[0047] S1-1, adopt a one-shot aggregation RCSOSA module based on RCS, combining RCSOSA and RepConv for path aggregation;

[0048] S1-2, adopt a dynamic non-monotonic FM loss method based on IOU Wise-IoU position loss function;

[0049] S1-3. Introduce the Focal Modulation network module to improve the original network architecture. In this step, by introducing the Focal Modulation network module, the original network architecture is improved. Specifically, FocalModulation is used to replace SPPCSPC, which can reduce information loss and improve the performance of the model for difficult-to-detect targets.

[0050] Furthermore, the RCSOSA module replaces the original ELAN-H structure and combines RCSOSA with RepConv for path aggregation, improving the performance of the feature extraction layer and enhancing the feature representation ability of the network, enabling the network to better capture the characteristics and contextual information of the target;

[0051] Specifically, in this embodiment, the expression of the WISE-IoU position loss function is:

[0052] Among them, L IoU 、R WIoU , r are the IoU position loss function, penalty term, and non-monotonic focusing coefficient, respectively, β is the outlier degree of the anchor box quality, L * IoUare the exponential running average with momentum and the monotonic focusing coefficient, respectively. α and δ are tiny parameters.

[0053] S2. Obtain a training dataset and a validation dataset of PCB images. Then use the training dataset to train the improved YOLOv7 network architecture, determine the model parameters, and use the validation dataset to evaluate and optimize the hyperparameters of the training model, ultimately obtaining a deep learning model.

[0054] Specifically, in this step, the steps of obtaining the training dataset and the verification dataset of the PCB image include:

[0055] S2-1. Collect PCB images of different resolutions, brightness and colors to form a multimodal PCB image dataset;

[0056] S2-2. Perform necessary preprocessing on the obtained PCB image dataset to separate data subsets for training, verification, and testing, thereby forming a training dataset, a verification dataset, and a test dataset;

[0057] Specifically, in this step, the obtained PCB image dataset is preprocessed, which specifically includes the following steps:

[0058] S2-21. Crop and flip the PCB image dataset and combine it with Cutout and AugMix techniques to obtain an expanded dataset, thereby improving the model training effect.

[0059] S2-22. In the expanded dataset, the PCB components in each image are labeled and categorized to provide accurate labeling information for subsequent deep learning model training.

[0060] S3. The PCB image to be inspected is input into the deep learning model to obtain the inspection results of the PCB components.

[0061] In this embodiment, a deep learning model is obtained by training the improved YOLOv7 network architecture, which can improve the accuracy and efficiency of PCB component detection and recognition.

[0062] Specifically, in this embodiment, the detection method may include: obtaining a training data set, a verification data set, and a test data set of PCB images, improving different parts of the original YOLOv7 network architecture by combining the three methods, training a deep learning model, and obtaining detection results.

[0063] The specific implementation steps include: collecting PCB images of different resolutions, different brightness and different colors to form a multimodal PCB image dataset; performing necessary preprocessing on the obtained PCB image dataset to separate data subsets for training, verification and testing, thereby forming a training dataset, a verification dataset and a test dataset.

[0064] More specifically, the steps include:

[0065] The PCB image dataset is cropped and flipped, and combined with Cutout and AugMix techniques to obtain an expanded dataset, thereby improving the model training effect;

[0066] In the expanded dataset, the PCB components in each image are labeled and categorized to provide accurate labeling information for subsequent deep learning model training.

[0067] In this application, different parts of the original YOLOv7 network architecture are improved by combining three methods. The YOLOv7 network architecture before improvement is shown in Figure 1. The network structure includes an input layer, a backbone network (backbone), a stem layer, an ELAN layer, an MP-n layer, and a RepConv layer. The input layer receives the original data, the backbone network consists of convolution, batch normalization, and activation functions for feature extraction, the Stem layer performs preliminary processing on the input data, the ELAN layer aims to improve feature learning capabilities, the MP-n layer implements spatial downsampling, and the RepConv layer performs structural reparameterization, decoupling multi-branch training and inference architectures for model deployment and acceleration. These components work together to support effective training and inference of deep learning models, helping to achieve high performance and efficiency.

[0068] In the backbone structure, the initial image first passes through the stem layer to produce a two-fold downsampled feature map; next, the feature map passes through a Conv layer containing a convolution kernel of 3 and a stride of 2, and an ELAN convolution layer. This combination will output a four-fold downsampled feature map; then, the feature map will undergo three rounds of repeated MP-n (n=1) downsampling and ELAN combination operations, and finally obtain a 32-fold downsampled feature map.

[0069] In the head structure, the SPPCSPC module performs a pooling operation on the feature map, halving the number of channels to 512. Then, through a 1x1 convolution operation, it generates feature maps that have been downsampled by 8 times, 16 times, and 32 times. Finally, these feature maps are used for multi-level prediction, including prediction of objectness, target category, and bounding box. This structural design makes full use of multi-level feature maps to achieve accurate target detection.

[0070] Furthermore, in this embodiment, the steps of improving different parts of the original YOLOv7 network architecture specifically include:

[0071] Step 1: The original ELAN-H structure is replaced by the RCSOSA module to enhance feature extraction capabilities.

[0072] Step 2: A single-shot aggregation (OSA) module is proposed to overcome the inefficiency of dense connections in the density network, that is, different features are represented by multiple receptive fields and all features are aggregated only once in the final feature map.

[0073] As shown in Figure 2, RCS is combined into an RCS-OSA module, and the RCS modules are repeatedly stacked to ensure feature reuse and enhance the information flow between different channels between features in adjacent layers. Different numbers of stacked modules are set at different positions in the network. To reduce the degree of network fragmentation, only three feature cascades are maintained on the one-time aggregation path, which can reduce the network computational burden and reduce memory usage.

[0074] RCS-OSA also maintains the same number of input channels and minimal output channels, thereby reducing memory access costs (MAC); for network construction, RCSOSA is combined with RepConv for path aggregation, and YOLOv7 is undersampled 32 times with maximum pooling to build the backbone network.

[0075] A dynamic non-monotonic FM loss method based on IOU, Wise-IoU (WIoU) position loss function, is adopted. This step is equivalent to using the WISE-IoU position loss function as the calculation method for the regression of the predicted box and the true label position.

[0076] Specifically, the intersection-over-union (IoU) refers to the ratio of the intersection and union of the target predicted bounding box and the true bounding box, that is, the overlap between the object prediction box and the true box. The definition of IoU is a standard for measuring the accuracy of object positioning. The model prediction calculates the gradient by calculating IOU for regression. The loss function, as a penalty measure, needs to be minimized during training, and ideally, the predicted box outlining the object can be matched with the corresponding true box. This paper introduces a new position loss function WISE-IoU to improve the CIoU loss function of YOLOv7.

[0077] Please refer to Figure 3 for the proposed position loss function WISE-IoU. Based on the CIoU loss function, the aspect ratio is divided into the actual length-to-width ratio while considering the direction of the distance in the desired regression. A matching direction loss penalty term between the true box and the predicted bounding box is added to the penalty index to improve the convergence speed and inference accuracy, pursuing high-quality matching between the predicted box and the true box.

[0078] In this embodiment, the position loss function WISE-IoUWISE-IoU is defined as follows:

[0079] Among them, L IoU 、R WIoU , r are the IoU position loss function, penalty term, and non-monotonic focusing coefficient, respectively. β is the outlier used to describe the quality of the anchor box. L * IoU are the exponential running average with momentum and the monotonic focusing coefficient, respectively. α and δ are adjustable hyperparameters.

[0080] Among them, W g and H g Indicates the width and height of the minimum bounding box; x gt and y gt Indicates the center coordinates of the target frame; x and y are the center coordinates of the anchor frame; in order to prevent R WIoU Producing gradients that hinder convergence, W g and H g Detach from the computation graph (superscript * denotes this operation).

[0081] α and δ are adjustable hyperparameters; when β = , r = 4. When the outlier degree of the anchor box satisfies β = C (C is a constant), the anchor box will obtain the highest gradient gain; the model has increased tolerance to low-quality samples and improved the detection ability of low-quality samples, which can greatly improve the training and reasoning capabilities of the object detection algorithm.

[0082] Compared with the previous method CIoU, the WISE-IoU loss function can make the prediction box converge faster during the training phase and have better inference performance.

[0083] In this embodiment, steps S1-3 introduce the Focal Modulation network module to improve the original network architecture. Specifically, the Focal Modulation network module includes: focal context, implemented using a set of deep convolutional layers to encode visual context from short to long ranges, gated aggregation to selectively collect context into a modulator for each query token, and element-wise affine transformation to inject the modulator into the query. The Focal Modulation network module exhibits remarkable interpretability and reduces computational cost for image classification, object detection, and segmentation tasks.

[0084] In this embodiment, the SPPCSPC module is replaced by Focal Modulation. This improvement improves the network's ability to perceive targets of different scales in the target detection task. The introduction of Focal Modulation greatly simplifies the calculation process and improves the model's performance for difficult-to-detect targets.

[0085] The improved YOLOv7 network architecture is shown in FIG4 . After the improved YOLOv7 network architecture is constructed, the learning model can be trained.

[0086] The model training process specifically includes: using the training dataset to train the improved YOLOv7 network architecture and determine the parameters of the training model; these parameters are automatically adjusted by the model through the learning process to best adapt to the data and achieve task performance; using the validation dataset to evaluate and adjust the hyperparameters of the training model; hyperparameters are pre-set parameters that can affect the training process and performance of the model.

[0087] During the training process, common deep learning training methods are followed, including data loading, loss function definition, optimizer selection, batch size, number of training cycles, etc.; these steps help the model continuously learn and adapt through training data to obtain a high-performance detection model.

[0088] Regarding the adjustment of hyperparameters, the selection of hyperparameters is optimized based on the performance indicators of the validation dataset, such as precision and recall rate, including learning rate, regularization parameter, number of network layers, number of channels, etc. Through continuous adjustment and verification, a deep learning model with good performance is obtained for subsequent PCB component detection tasks. This training process may require multiple iterations and adjustments to obtain the best performance.

[0089] After the model training is completed, it also includes: inputting the test data set into the deep learning model to verify the generalization ability of the deep learning model.

[0090] In this embodiment, combined with the above content, the final step is to input the PCB image to be inspected into the deep learning model to obtain the final inspection results of the PCB components.

[0091] This invention offers the following advantages: Data augmentation strategies such as cropping, flipping, Cutout, and AugMix improve the quality of the dataset and enhance the generalization capabilities of deep learning models, making them more adaptable to diverse scenarios and tasks. These methods enrich the dataset and help the model perform better in real-world PCB component inspections.

[0092] A single-shot aggregation (OSA) module is proposed to overcome the inefficiency of dense connections in dense networks, replacing the original ELAN-H structure with the RCSOSA module to enhance feature extraction capabilities. RCS-OSA also maintains the same number of input channels and minimizes output channels, thereby reducing memory access cost (MAC).

[0093] Specifically, this embodiment also proposes the WISE-IoU position loss function, which divides the aspect ratio into the actual length-to-width ratio while considering the direction of the distance in the desired regression. A matching direction loss penalty term between the real box and the predicted bounding box is added to the penalty index to improve the convergence speed and inference accuracy.

[0094] Furthermore, the present invention uses Focal Modulation to replace SPPCSPC. This improvement improves the network's perception of targets of different scales in target detection tasks. The introduction of Focal Modulation greatly simplifies the calculation process and improves the model's performance for difficult-to-detect targets.

[0095] The following is a further explanation of the application content through specific steps:

[0096] The first step is to collect a multimodal PCB image dataset and enrich the dataset through a combination of data augmentation strategies such as cropping, flipping, Cutout, and AugMix to provide more diverse data for model training.

[0097] The second step is to use the pre-trained parameter method during model training, using the pre-trained weights of the baseline model YOLOv7 to initialize the model. This helps the model converge faster and learn useful feature representations in the early stages of training. Set the warm-up learning rate with an initial value of 0.01 to help the model learn more stably at the beginning. This pre-trained parameter setting method helps improve the effectiveness and performance of model training.

[0098] The third step is to design a network architecture based on YOLOv7, including the backbone network, feature extraction layer, and prediction layer. Through the comprehensive improvement of three methods, different components of the original YOLOv7 network are optimized to improve performance and efficiency.

[0099] The fourth step is to use an RCS-based one-shot aggregation (RCSOSA) module to replace the original ELAN-H structure, and combine RCSOSA and RepConv with path aggregation; use a dynamic non-monotonic FM loss method based on IOU, Wise-IoU (WIoU), to improve the CIoU loss function of YOLOv7; introduce the Focal Modulation network module to replace the SPPCSPC module and improve the original network architecture; obtain the overall structure of the improved YOLOv7 network.

[0100] S5. Next, the model is trained. The specific process includes: inputting the training set images that have undergone data augmentation processing into the backbone network, performing feature extraction, and generating feature maps; then, these feature maps are passed to the head network, and after feature fusion, detection frames are generated; these detection frames are screened by a preset threshold to form prediction frames; then, the validation set images are input into the improved YOLOv7 model, and the prediction frames are used to obtain detection results; based on the detection results, the loss function of the improved YOLOv7 model is calculated, and by continuously adjusting the model parameters, the loss function is gradually reduced, and finally the model training is completed; this process helps the model gradually improve its performance and accuracy.

[0101] The above detailed steps primarily describe the implementation of the PCB component detection method of the present invention and the image processing process of the network model. Next, the modified model is trained. During training, the model processes the input image information in the same manner as described above. Once training is complete, a trained weight and parameter file is generated. These trained weight and parameter files can be used for model deployment and testing. The effectiveness of this method in practical applications is evaluated using the mAP@0.5 performance metric, which helps determine the model's detection performance and usability.

[0102] The results show that compared with the original YOLOv7 algorithm, the mAP@0.5 of the algorithm of the present invention is improved by 3.1% to 95.3%. The mAP@0.5 curves before and after the improvement are shown in Figures 5 and 6. To verify the detection effect of the present invention, PCB board images were collected for detection. Figure 7 shows the detection effect of the original YOLOv7, and Figure 8 shows the detection effect diagram of the PCB component detection method of the present invention. The results show that the PCB component detection method of the present invention significantly improves the detection accuracy and reduces the missed detection rate.

[0103] In summary, the PCB component detection method of the present invention significantly improves the detection performance without increasing the amount of calculation. Its lightweight, real-time, and high-precision characteristics can meet the requirements of deployment on edge devices.

[0104] Example 2:

[0105] Based on the same inventive concept as in the first embodiment, this embodiment of the present invention provides a PCB component detection system based on deep learning, including:

[0106] A network architecture building module is used to improve the original YOLOv7 network architecture to obtain an improved YOLOv7 network architecture. The improvement of the original YOLOv7 network architecture includes: adopting an RCS-based One-Shot Aggregation (RCSOSA) module to combine RCSOSA and RepConv for path aggregation; adopting a dynamic non-monotonic FM loss method based on IoU (WIoU) position loss function; and introducing a Focal Modulation network module to improve the original network architecture.

[0107] Obtain training and validation datasets of PCB images; use the training dataset to train the improved YOLOv7 network architecture, determine the model parameters, and use the validation dataset to evaluate and optimize the hyperparameters of the training model to ultimately obtain a deep learning model;

[0108] The result output module is used to input the PCB image to be inspected into the deep learning model to obtain the inspection results of the PCB components.

[0109] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.

Claims

1. A PCB defect detection method based on an improved YOLOv7 algorithm, characterized in that: The method comprises the following steps: S1. Improve the original YOLOv7 network architecture to obtain an improved YOLOv7 network architecture; S2. Obtain the training data set and validation data set of the PCB images, then use the training data set to train the improved YOLOv7 network architecture, determine the model parameters, and use the validation data set to evaluate and optimize the hyperparameters of the training model, and finally obtain the deep learning model; S3. The PCB image to be inspected is input into the deep learning model to obtain the inspection results of the PCB components.

2. According to a PCB defect detection method based on the improved YOLOv7 algorithm according to claim 1, it is characterized in that: In the S1 step, the steps of improving the original YOLOv7 network architecture include: S1-1, adopt a one-shot aggregation RCSOSA module based on RCS, combining RCSOSA and RepConv with path aggregation; S1-2, adopt a dynamic non-monotonic FM loss method based on IOU Wise-IoU position loss function; S1-3, introduce the Focal Modulation network module to improve the original network architecture.

3. A PCB defect detection method based on an improved YOLOv7 algorithm according to claim 2, characterized in that: The RCSOSA module replaces the original ELAN-H structure, combines RCSOSA with RepConv to perform path aggregation, improves the performance of the feature extraction layer, enhances the feature representation ability of the network, and enables the network to better capture the characteristics and context information of the target.

4. A PCB defect detection method based on an improved YOLOv7 algorithm according to claim 2, characterized in that: The expression of the WISE-IoU position loss function is: Among them, L IoU , R WIoU , r are respectively the IoU position loss function, penalty term, and non-monotonic focusing coefficient number, β is the outlier degree of the anchor box quality, L * IoU are the exponential running mean with momentum and the monotonic focusing coefficient respectively, and α and δ are tiny parameters.

5. A PCB defect detection method based on an improved YOLOv7 algorithm according to claim 2, characterized in that: The Focal Modulation network module is introduced to improve the original network architecture, specifically using Focal Modulation to replace SPPCSPC, so as to reduce information loss and improve the performance of the model for difficult-to-detect targets.

6. A PCB defect detection method based on an improved YOLOv7 algorithm according to claim 1, characterized in that: In the step S2, the steps of obtaining the training data set and the verification data set of the PCB image include: S2-1, collect PCB images of different resolutions, different brightness and different colors to form a multimodal PCB image dataset; S2-2. Preprocess the obtained PCB image dataset to separate data subsets for training, verification and testing, thereby forming a training dataset, a verification dataset and a test dataset.

7. A PCB defect detection method based on an improved YOLOv7 algorithm according to claim 6, characterized in that: The preprocessing of the obtained PCB image data set specifically includes the following steps: S2-21. Crop and flip the PCB image dataset, and combine Cutout and AugMix techniques to obtain an expanded dataset, thereby improving the training effect of the model; S2-22. In the expanded dataset, the PCB components in each image are labeled and categorized to provide accurate labeling information for subsequent deep learning model training.

8. A PCB defect detection system based on an improved YOLOv7 algorithm, characterized in that: A PCB defect detection method based on an improved YOLOv7 algorithm as described in any one of claims 1 to 7, comprising: Network architecture building module, used to improve the original YOLOv7 network architecture and obtain the improved YOLOv7 Network architecture; The model training module is used to obtain the training data set and the verification data set of the PCB images for training the deep learning model; the improved YOLOv7 network architecture is trained using the training data set, and the parameters of the training model are optimized; the trained model is evaluated using the verification data set, and the hyperparameters of the model are tuned to obtain a trained and tuned deep learning model; The result output module is used to input the PCB image to be inspected into the deep learning model to obtain the inspection results of the PCB components.

Citation Information

Patent Citations

  • PCB element detection method and system based on deep learning, and storage medium

    CN116168017A

  • PCB bare board surface defect detection method based on YOLOv8

    CN116823738A

  • PCB defect detection method based on improved YOLOv7

    CN116863242A

  • PCB surface defect detection method and system based on improved yolov7 network

    CN116912659A

  • PCB defect detection method and system based on improved YOLOv7 algorithm

    CN117745684A

Cited By

  • PCB defect cross-domain cooperative detection method based on multi-modal model

    CN120765629A

  • PCB welding spot defect detection method and device based on microscopic image

    CN120833337A

  • Wind power blade defect detection method based on improved YOLOv8

    CN121010588A

  • Circuit board production defect detection method and system based on image recognition

    CN121121273A

  • Artificial intelligence identification method and system for bevel gear defect detection

    CN121211232A