Training method and detection method of PCB (Printed Circuit Board) defect detection model
By building a PCB board defect detection model based on the texture adaptive attention model and the YOLOv5 network model, the problem of inconsistent manual inspection standards is solved, and high-accuracy PCB board defect detection is achieved.
Patent Information
- Application Number
- CN202510918612.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-03
- Publication Date
- 2025-09-23
AI Technical Summary
In the existing technology, PCB board defect detection relies on manual inspection, resulting in inconsistent inspection standards and low detection accuracy.
The texture adaptive attention model and YOLOv5 network model are used to build the initial defect detection model. By obtaining historical PCB board images for training, global texture features are enhanced and extracted to form a PCB board defect detection model.
The detection accuracy of PCB board defect detection is improved, especially the detection rate of small target defects, and the model's ability to learn global texture features is enhanced.
Smart Images

Figure CN120689342A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence technology, and in particular relates to a training method and a detection method for a PCB board defect detection model. Background Art
[0002] In the production process of electronic and electrical products, printed circuit boards (PCBs) are important components. Defects in PCBs are directly related to product reliability and performance stability.
[0003] Currently, PCB defect detection mainly relies on manual work. The manual method of detecting PCB board defects is not stable. Different inspection standards of different inspectors will result in non-standard inspections. In addition, the fatigue of inspectors will also cause misjudgments, resulting in low detection accuracy of PCB board defects. Summary of the Invention
[0004] In view of this, an embodiment of the present application provides a training method and a detection method for a PCB board defect detection model to overcome or at least partially solve the above problems of the prior art.
[0005] In a first aspect, an embodiment of the present application provides a training method for a PCB board defect detection model, comprising: obtaining historical PCB board images, where the historical PCB board images contain PCB defect information; constructing an initial defect detection model based on a texture adaptive attention model and a YOLOv5 network model, where the texture adaptive attention model is used to enhance and extract global texture features of the historical PCB board images; and inputting the historical PCB board images into the initial defect detection model for training to obtain a PCB board defect detection model.
[0006] In a second aspect, an embodiment of the present application provides a PCB board defect detection method, comprising: obtaining a current PCB board image of a PCB board to be inspected; inputting the current PCB board image into a PCB board defect detection model to obtain a corresponding PCB board defect detection result; wherein the PCB board defect detection model is trained based on the PCB board defect detection model training method provided in the first aspect above.
[0007] In a third aspect, an embodiment of the present application provides a training device for a PCB board defect detection model, including: a historical image acquisition module, used to acquire historical PCB board images, which contain PCB defect information; a construction module, used to construct an initial defect detection model based on a texture adaptive attention model and a YOLOv5 network model, wherein the texture adaptive attention model is used to enhance and extract the global texture features of the historical PCB board images; and a training module, used to input historical PCB board images into the initial defect detection model for training to obtain a PCB board defect detection model.
[0008] In a fourth aspect, an embodiment of the present application provides a PCB board defect detection device, comprising: a current image acquisition module, used to acquire a current PCB board image of a PCB board to be inspected; an input module, used to input the current PCB board image into a PCB board defect detection model to obtain a corresponding PCB board defect detection result; wherein the PCB board defect detection model is trained based on the PCB board defect detection model training method provided in the first aspect above.
[0009] In a fifth aspect, an embodiment of the present application provides an electronic device comprising a memory; one or more processors coupled to the memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the training method of the PCB board defect detection model provided in the first aspect above, and / or the PCB board defect detection method provided in the second aspect above.
[0010] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, in which program code is stored. The program code can be called by a processor to execute the training method of the PCB board defect detection model provided in the first aspect above, and / or the PCB board defect detection method provided in the second aspect above.
[0011] In a seventh aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a computer device, the computer device executes the training method of the PCB board defect detection model provided in the first aspect above, and / or the PCB board defect detection method provided in the second aspect above.
[0012] The solution provided in this application obtains historical PCB board images, which contain PCB defect information, and constructs an initial defect detection model based on a texture adaptive attention model and a YOLOv5 network model. The texture adaptive attention model is used to enhance and extract global texture features of the historical PCB board images, and the historical PCB board images are input into the initial defect detection model for training to obtain a PCB board defect detection model. The solution implements training of the initial defect detection model constructed based on the texture adaptive attention model and the YOLOv5 network model based on the historical PCB board images to obtain a PCB board defect detection model. The PCB board defect detection model has high detection accuracy for PCB board defects, which is conducive to improving the detection accuracy of PCB board defects.
[0013] Furthermore, the texture adaptive attention model can be used to enhance and extract the global texture features of PCB board images, which is conducive to improving the learning ability of the PCB board defect detection model to learn the global texture features of PCB board images, making small target PCB board defects easier to detect, which is conducive to further improving the detection accuracy of PCB board defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0015] Figure 1 A schematic diagram of a scenario of a PCB board defect detection system provided in an embodiment of the present application is shown.
[0016] Figure 2 A flow chart of a method for training a PCB board defect detection model provided in an embodiment of the present application is shown.
[0017] Figure 3 A schematic diagram of a scenario of a texture adaptive attention model in the training method of a PCB board defect detection model provided in an embodiment of the present application is shown.
[0018] Figure 4 A schematic diagram of a scenario of an initial defect detection model in the training method of a PCB board defect detection model provided in an embodiment of the present application is shown.
[0019] Figure 5 Another flow chart of the training method of the PCB board defect detection model provided in an embodiment of the present application is shown.
[0020] Figure 6 A flow chart of a PCB board defect detection method provided in an embodiment of the present application is shown.
[0021] Figure 7 A structural block diagram of a training device for a PCB board defect detection model provided in an embodiment of the present application is shown.
[0022] Figure 8 A structural block diagram of a PCB board defect detection device provided in an embodiment of the present application is shown.
[0023] Figure 9 A functional block diagram of an electronic device provided in an embodiment of the present application is shown.
[0024] Figure 10 A computer-readable storage medium provided in an embodiment of the present application is shown for storing or carrying a program code for implementing a training method for a PCB board defect detection model provided in an embodiment of the present application and / or a PCB board defect detection method.
[0025] Figure 11 A computer program product provided in an embodiment of the present application is shown, which is used to store or carry program code for implementing a training method for a PCB board defect detection model provided in an embodiment of the present application, and / or a PCB board defect detection method. DETAILED DESCRIPTION
[0026] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the embodiments described below are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0027] It will be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0028] It should also be understood that the terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0029] It should be further understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0030] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0031] In the production process of electronic and electrical products, printed circuit boards (PCBs) are important components. Defects in PCBs are directly related to product reliability and performance stability.
[0032] Currently, PCB defect detection mainly relies on manual work. The manual method of detecting PCB board defects is not stable. Different inspection standards of different inspectors will result in non-standard inspections. In addition, the fatigue of inspectors will also cause misjudgments, resulting in low detection accuracy of PCB board defects.
[0033] To address the above problems, the embodiments of the present application provide a training method and a detection method for a PCB board defect detection model. By acquiring historical PCB board images, which contain PCB defect information, and constructing an initial defect detection model based on a texture adaptive attention model and a YOLOv5 network model, the texture adaptive attention model is used to enhance and extract global texture features of the historical PCB board images. The historical PCB board images are input into the initial defect detection model for training to obtain a PCB board defect detection model. This method trains the initial defect detection model constructed based on the texture adaptive attention model and the YOLOv5 network model based on the historical PCB board images to obtain a PCB board defect detection model. The PCB board defect detection model has a high detection accuracy for PCB board defect detection, which is conducive to improving the detection accuracy of PCB board defect detection.
[0034] Furthermore, the texture adaptive attention model can be used to enhance and extract the global texture features of PCB board images, which is conducive to improving the learning ability of the PCB board defect detection model to learn the global texture features of PCB board images, making small target PCB board defects easier to detect, which is conducive to further improving the detection accuracy of PCB board defect detection.
[0035] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application.
[0036] See also Figure 1, which shows a schematic diagram of an application scenario of the PCB board defect detection system provided in an embodiment of the present application. The PCB board defect detection system may include a PCB board 100, a camera 200 and a processing device 300. The camera 200 can be connected to the processing device 300 through a network and exchange data with the processing device 300 through the network.
[0037] The PCB board 100 may be any one of a single-sided PCB board, a double-sided PCB board or a multi-layer PCB board. The type of the PCB board 100 is not limited here and may be specifically configured according to actual needs.
[0038] The camera 200 can be used to capture an image of the PCB 100, obtain an image of the PCB, and transmit the image of the PCB to the processing device 300 via a network. The camera 200 can be any of a wide-angle camera, a macro camera, an ultra-wide-angle camera, or a panoramic camera. The type of camera 200 is not limited here and can be set according to actual needs.
[0039] The processing device 300 can be used to receive the PCB board image sent by the camera 200 and perform solder defect detection on the PCB board based on the PCB board image. The processing device 300 can be any of a server or a terminal device, etc., and is not limited here. The specific configuration can be based on actual needs.
[0040] The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), big data, and artificial intelligence platforms.
[0041] The terminal device may be a mobile terminal device (for example, a vehicle-mounted terminal, a PDA (Personal Digital Assistant), a tablet PC (Tablet Personal Computer, Tablet PC), a laptop computer, etc.), or a fixed terminal device (a desktop computer, a smart panel, etc.).
[0042] The network may be any one of a ZigBee network, a Bluetooth (BT) network, a Wireless Fidelity (Wi-Fi) network, a Thread network, a Long Range Radio (LoRa) network, a Low-Power Wide-Area Network (LPWAN), an infrared network, a Narrow Band Internet of Things (NB-IoT), a Controller Area Network (CAN), a Digital Living Network Alliance (DLNA) network, a Wide Area Network (WAN), a Local Area Network (LAN), a Metropolitan Area Network (MAN), or a Wireless Personal Area Network (WPAN), etc., without limitation here.
[0043] See also Figure 2 , which shows a flow chart of a training method for a PCB board defect detection model provided by an embodiment of the present application. In a specific embodiment, the training method for a PCB board defect detection model can be applied to Figure 1 The processing device 300 in the PCB board defect detection system shown in FIG. 3 is taken as an example below. Figure 2 The process shown in FIG. 1 is described in detail. The training method of the PCB board defect detection model may include the following steps S110 to S130.
[0044] Step S110: Acquire historical PCB board images.
[0045] In an embodiment of the present application, the processing device may obtain historical PCB board images, wherein the historical PCB board images may contain PCB defect information.
[0046] PCB defect information may include PCB defect type (for example, crack defect, pinhole defect, or breakage defect), PCB defect location, and PCB defect size. The type of PCB defect information is not limited here and can be set according to actual needs.
[0047] In some implementations, the processing device may pre-store historical PCB board images, and the processing device may read the pre-stored historical PCB board images.
[0048] In some implementations, the processing device may generate an upload prompt message and receive historical PCB board images uploaded by the inspector according to the upload prompt message.
[0049] Among them, the upload prompt information can be used to prompt the inspection personnel to upload the historical PCB board image to the processing equipment according to the upload prompt information. The upload prompt information can be at least any one of text prompt information, sound prompt information or light prompt information, etc., which is not limited here.
[0050] Step S120: constructing an initial defect detection model based on the texture adaptive attention model and the YOLOv5 network model.
[0051] In an embodiment of the present application, the processing device can build an initial defect detection model based on the texture adaptive attention model and the YOLOv5 network model.
[0052] The YOLOv5 network model consists of three parts: the backbone network, the neck network, and the head network. The backbone network extracts features from the input image to generate feature maps, which are then passed to the neck network. The neck network fuses multi-scale features from the feature maps to generate fused features, which are then passed to the head network. The head network performs the final regression prediction.
[0053] The texture adaptive attention model can be used to enhance and extract the global texture features of the historical PCB board image. The texture adaptive attention model can include a deep convolution module, a Criss-CrossAttention (CCA) module, a Squeeze and Excitation (SE) module, and a Rectified Linear Units (ReLU) activation function module. The deep convolution module, the CCA module, the SE module, and the ReLU activation function module can be connected in sequence, such as Figure 3 As shown in the figure, the deep convolution module, CCA module, and SE module can all be connected to the ReLU activation function module through a residual (shortcut), so that the texture adaptive attention model can learn deeper global texture features, which is conducive to improving the texture adaptive attention model's ability to learn the global texture features of PCB board images.
[0054] The deep convolution module can be used to extract deep features of historical PCB board images to obtain the first feature map; the CCA module can be used to extract and fuse the global texture features of the first feature map to obtain the second feature map; the SE module can be used to assign weights to the second feature map to obtain the third feature map; the ReLU activation function module can be used to perform ReLU activation function processing on the third feature map.
[0055] The deep convolution module, CCA module, SE module and ReLU activation function module are connected in sequence to produce a synergistic effect, which enables the texture adaptive attention model to learn more complex texture features, and can improve the sensitivity of the texture adaptive attention model to small target PCB board defects, which is conducive to improving the detection accuracy of the PCB board defect detection model for PCB board defects.
[0056] Specifically, the processing device can fuse the texture adaptive attention model between the spatial pyramid pooling (SPP) module in the backbone network of the YOLOv5 network model and the path aggregation network (PANet) module in the neck network to obtain a fusion model, and delete the cross stage partial (CSP) module and the SPP module in the fusion model to obtain an initial defect detection model, such as Figure 4 As shown in the figure, the texture adaptive attention model can be connected between the C2f module and the PANet module. Due to the addition of the texture adaptive attention model, the learning ability of global texture features can be improved. Since the computational complexity of the CSP module and the SPP module is relatively high, after deleting the CSP module and the SPP module in the fusion model, the model expression performance of the initial defect detection model remains unchanged. At the same time, the network structure of the initial defect detection model is simplified, which is beneficial to reducing the computational complexity of the initial defect detection model, thereby improving the detection efficiency of defect detection on PCB boards.
[0057] Among them, the processing device can fuse the deep convolution module, CCA module, SE module and ReLU activation function module to obtain a texture adaptive attention model.
[0058] Step S130: inputting historical PCB board images into the initial defect detection model for training to obtain a PCB board defect detection model.
[0059] In an embodiment of the present application, the processing device can input historical PCB board images into the initial defect detection model. The initial defect detection model receives and responds to the historical PCB board images, and is trained based on the historical PCB board images to obtain a PCB board defect detection model. This realizes the training of the initial defect detection model constructed based on the texture adaptive attention model and the YOLOv5 network model based on the historical PCB board images to obtain the PCB board defect detection model. The detection accuracy of defect detection on the PCB board based on the PCB board defect detection model is high, which is conducive to improving the detection accuracy of defect detection on the PCB board.
[0060] Furthermore, the texture adaptive attention model can be used to enhance and extract the global texture features of PCB board images, which is conducive to improving the learning ability of the PCB board defect detection model to learn the global texture features of PCB board images, making small target PCB board defects easier to detect, which is conducive to further improving the detection accuracy of PCB board defect detection.
[0061] The solution provided in this application obtains historical PCB board images, which contain PCB defect information, and constructs an initial defect detection model based on a texture adaptive attention model and a YOLOv5 network model. The texture adaptive attention model is used to enhance and extract global texture features of the historical PCB board images, and the historical PCB board images are input into the initial defect detection model for training to obtain a PCB board defect detection model. The solution implements training of the initial defect detection model constructed based on the texture adaptive attention model and the YOLOv5 network model based on the historical PCB board images to obtain a PCB board defect detection model. The PCB board defect detection model has high detection accuracy for PCB board defects, which is conducive to improving the detection accuracy of PCB board defects.
[0062] Furthermore, the texture adaptive attention model can be used to enhance and extract the global texture features of PCB board images, which is conducive to improving the learning ability of the PCB board defect detection model to learn the global texture features of PCB board images, making small target PCB board defects easier to detect, which is conducive to further improving the detection accuracy of PCB board defect detection.
[0063] See also Figure 5 , which shows a flow chart of a training method for a PCB board defect detection model provided by another embodiment of the present application. In a specific embodiment, the training method for a PCB board defect detection model can be applied to Figure 1 The processing device 300 in the PCB board defect detection system shown in FIG. 3 is taken as an example below. Figure 5The process shown in FIG. 1 is described in detail. The training method of the PCB board defect detection model may include the following steps S210 to S250.
[0064] Step S210: Acquire a historical PCB board image, where the historical PCB board image contains PCB defect information.
[0065] Step S220: Construct an initial defect detection model based on the texture adaptive attention model and the YOLOv5 network model.
[0066] In this embodiment, step S210 and step S220 may refer to the contents of the corresponding steps in the aforementioned embodiment, and will not be repeated here.
[0067] Step S230: Determine a training set and a test set based on historical PCB board images.
[0068] In this embodiment, the processing device may annotate historical PCB board images to obtain corresponding annotated images, and divide the annotated images according to preset division rules to obtain a training set and a test set.
[0069] Among them, when the processing device marks the historical PCB board image, it mainly marks the PCB defect type, PCB defect location and PCB defect size in the historical PCB board image.
[0070] For example, the processing device may use a marking box to mark the PCB defect type in the historical PCB board image, mark the corner coordinates of the marking box, and mark the size of the marking box.
[0071] The preset partitioning rule can be a manual partitioning rule. For example, the preset partitioning rule can be a training set:test set = 7:3 manual partitioning rule. When the number of historical PCB board images is 20,000, the training set is 14,000 and the test set is 6,000. The preset partitioning rule can be a training set:test set = 9:1 manual partitioning rule. When the number of historical PCB board images is 30,000, the training set is 27,000 and the test set is 3,000. The partitioning method of the preset partitioning rule is not limited here and can be set according to actual needs.
[0072] Step S240: performing data enhancement processing on the training set to obtain an enhanced training set.
[0073] In this embodiment, the processing device may perform data enhancement processing on the training set to obtain an enhanced training set.
[0074] Among them, data enhancement processing can include at least any one of brightness enhancement processing, grayscale enhancement processing, contrast enhancement processing and transparency enhancement processing. The type of data enhancement processing is not limited here and can be set according to actual needs.
[0075] Step S250: inputting the enhanced training set into the initial defect detection model for training to obtain a PCB board defect detection model.
[0076] In this embodiment, the processing device can input the enhanced training set into the initial defect detection model. The initial defect detection model receives and responds to the enhanced training set, and is trained according to the enhanced training set to obtain a PCB board defect detection model. This realizes the training of the initial defect detection model according to the enhanced training set, thereby avoiding the low robustness of the PCB board defect detection model obtained by training the initial defect detection model with a smaller training set due to the small number of historical PCB board images, thereby increasing the robustness of the PCB board defect detection model.
[0077] In some embodiments, after the processing device inputs the enhanced training set into the initial defect detection model for training to obtain the PCB board defect detection model, it can determine whether the PCB board defect detection model converges based on the test set, so as to determine whether the PCB board defect detection model is stable.
[0078] Among them, the processing device can input the test set into the PCB board defect detection model, the PCB board defect detection model receives and responds to the test set, performs testing according to the test set, obtains corresponding test results, and determines the test accuracy corresponding to the test results based on the test results and the test set, and determines whether the PCB board defect detection model converges based on the test accuracy.
[0079] When the test accuracy is greater than or equal to the preset accuracy threshold, it is determined that the PCB board defect detection model has converged; when the test accuracy is less than the preset accuracy threshold, it is determined that the PCB board defect detection model has not converged.
[0080] The preset accuracy threshold can be used to represent the minimum accuracy corresponding to the convergence of the PCB board defect detection model. The preset accuracy threshold can be an accuracy pre-set by the inspection personnel, or it can be an accuracy automatically generated by the processing equipment based on the process of multiple defect inspections on the PCB board. The setting method of the preset accuracy threshold is not limited here and can be set according to actual needs.
[0081] The solution provided in this embodiment obtains historical PCB board images, which contain PCB defect information, and constructs an initial defect detection model based on a texture adaptive attention model and a YOLOv5 network model. A training set and a test set are determined based on the historical PCB board images, and data enhancement processing is performed on the training set to obtain an enhanced training set. The enhanced training set is input into the initial defect detection model for training to obtain a PCB board defect detection model. This achieves the training of the initial defect detection model constructed based on the texture adaptive attention model and the YOLOv5 network model based on the historical PCB board images to obtain a PCB board defect detection model. The PCB board defect detection model has high detection accuracy for PCB board defects, which is conducive to improving the detection accuracy of PCB board defects.
[0082] Furthermore, the texture adaptive attention model can be used to enhance and extract the global texture features of PCB board images, which is conducive to improving the learning ability of the PCB board defect detection model to learn the global texture features of PCB board images, making small target PCB board defects easier to detect, which is conducive to further improving the detection accuracy of PCB board defect detection.
[0083] Furthermore, the initial defect detection model is trained based on the enhanced training set, thereby avoiding the low robustness of the PCB board defect detection model obtained by training the initial defect detection model with a smaller training set due to the small number of historical PCB board images, thereby increasing the robustness of the PCB board defect detection model.
[0084] See also Figure 6 , which shows a flow chart of a PCB board defect detection method provided by an embodiment of the present application. In a specific embodiment, the PCB board defect detection method can be applied to Figure 1 The processing device 300 in the PCB board defect detection system shown in FIG. 3 is taken as an example below. Figure 6 The process shown in FIG. 1 is described in detail. The PCB board defect detection method may include the following steps S310 to S320.
[0085] Step S310: Acquire the current PCB board image of the PCB board to be inspected.
[0086] In this embodiment, when the inspector needs to perform defect detection on the PCB board, he can send a detection instruction to the processing device. The processing device receives and responds to the detection instruction, sends an image acquisition instruction to the camera via the network, and the camera receives and responds to the image acquisition instruction, performs image acquisition on the PCB board to be inspected, obtains the current PCB board image, and sends the current PCB board image to the processing device via the network. The processing device receives the current PCB board image returned by the camera.
[0087] The detection instruction can be used to instruct the processing device to perform defect detection on the PCB board, and the image acquisition instruction can be used to instruct the camera to acquire images of the PCB board to be inspected.
[0088] In some embodiments, the processing device can detect the operation of the inspector. When it is determined based on the detected operation of the inspector that the inspector has input an inspection instruction to perform defect inspection on the PCB board, the inspection instruction to perform defect inspection on the PCB board is received.
[0089] For example, when an inspector needs to perform defect detection on a PCB board, he or she can perform a touch operation on the operation panel of the processing device. The processing device responds to the inspector's touch operation, generates a corresponding touch signal, and analyzes the touch signal. When it is determined that the touch signal is a preset detection signal for characterizing defect detection on the PCB board, it is determined that a detection instruction for defect detection on the PCB board has been received.
[0090] In some embodiments, the processing device may be provided with a voice recognition module. When an inspector needs to perform defect detection on a PCB board, the inspector may send voice information within the voice collection range of the voice recognition module. The voice recognition module collects the voice information sent by the inspector and performs voice recognition on the collected voice information. Based on the recognition result of the voice recognition, it is determined that the recognition result contains keywords for indicating defect detection on the PCB board, such as "PCB board defect detection", or "PCB board" and "defect detection", etc., and it is determined that a detection instruction for defect detection on the PCB board has been received.
[0091] As an example, the voice message sent by the inspector is: perform defect detection on the PCB board. The recognition result of the voice recognition contains the keywords "PCB board" and "defect detection", then it is determined that the inspection instruction for performing defect detection on the PCB board has been received.
[0092] In some embodiments, the PCB board defect detection system may further include a client associated with the inspection personnel, the client being connected to the processing device via a network and performing data exchange with the processing device via the network.
[0093] When inspectors need to perform defect detection on PCB boards, they can send inspection instructions to the client. The client receives and responds to the inspection instructions and forwards the inspection instructions to the processing device through the network. The processing device receives the inspection instructions forwarded by the client.
[0094] Among them, the client can be any one of a mobile client (for example, a mobile phone client, a PDA client, a Tablet PC client, a laptop client, a smart watch client, a smart bracelet client or a wearable client, etc.) or a fixed client (for example, a desktop computer client, a smart panel client, etc.). The type of client is not limited here and can be set according to actual needs.
[0095] Step S320: inputting the current PCB board image into the PCB board defect detection model to obtain the corresponding PCB board defect detection result.
[0096] In this embodiment, after the processing device obtains the current PCB board image of the PCB board to be inspected, the current PCB board image can be input into the PCB board defect detection model. The PCB board defect detection model receives and responds to the current PCB board image, performs defect detection on the PCB board to be inspected based on the current PCB board image, obtains a corresponding PCB defect detection result, and outputs the PCB defect detection result to the processing device. The processing device receives the PCB defect detection result output by the PCB board defect detection model, thereby realizing defect detection of the PCB board based on the PCB board defect detection model and improving the detection accuracy of defect detection on the PCB board.
[0097] Furthermore, the texture-adaptive attention model can be used to enhance and extract the global texture features of PCB board images, thereby improving the learning ability of the PCB board defect detection model to learn the global texture features of PCB board images, making small target PCB board defects easier to detect, thereby further improving the detection accuracy of PCB board defect detection.
[0098] The PCB board defect detection model can be trained based on the PCB board defect detection model training method provided in the aforementioned embodiment.
[0099] The PCB board defect detection result may include a first detection result used to indicate that the current PCB board image contains PCB defect information, and a second detection result used to indicate that the current PCB board image does not contain PCB defect information.
[0100] In some embodiments, the processing device inputs the current PCB board image into the PCB board defect detection model. When obtaining the corresponding first detection result, it can determine the processing plan corresponding to the first detection result and send the processing plan to the client via the network so that the inspection personnel can process the PCB board in time according to the processing plan, thereby improving the user experience of the inspection personnel in the process of performing defect detection on the PCB board.
[0101] The processing device pre-stores a processing solution table, which can be used to represent the correspondence between PCB defect information and processing solutions. The processing device can search the processing solution table according to the first detection result to obtain the processing solution.
[0102] For example, the PCB defect information may include first PCB defect information, second PCB defect information, and third PCB defect information. The processing solution may include a first processing solution, a second processing solution, and a third processing solution.
[0103] The correspondence between PCB defect information and processing solutions can be shown in Table 1, ie, a processing solution table. Based on the correspondence, a processing solution corresponding to the first detection result can be obtained.
[0104] Table 1
[0105] PCB defect information Solution First PCB defect information First treatment plan Second PCB defect information Second treatment plan Third PCB defect information The third treatment plan
[0106] It should be noted that the correspondence between PCB defect information and processing solutions is not limited to that shown in Table 1, and can be specifically set according to actual needs.
[0107] The solution provided in this embodiment obtains a current PCB image of the PCB to be inspected and inputs the current PCB image into a PCB defect detection model to obtain a corresponding PCB defect detection result. This implements defect detection on the PCB based on the PCB defect detection model, thereby improving the detection accuracy of PCB defect detection.
[0108] Furthermore, the texture-adaptive attention model can be used to enhance and extract the global texture features of PCB board images, thereby improving the learning ability of the PCB board defect detection model to learn the global texture features of PCB board images, making small target PCB board defects easier to detect, thereby further improving the detection accuracy of PCB board defect detection.
[0109] See also Figure 7 , which shows a training device 400 for a PCB board defect detection model provided by an embodiment of the present application. The training device 400 for a PCB board defect detection model can be applied to Figure 1 The processing device 300 in the PCB board defect detection system shown in FIG. 3 is taken as an example below. Figure 7 The training device 400 for the PCB board defect detection model shown in FIG. 4 is described in detail. The training device 400 for the PCB board defect detection model may include a historical image acquisition module 410 , a construction module 420 , and a training module 430 .
[0110] The historical image acquisition module 410 can be used to acquire historical PCB board images, which can contain PCB defect information. The construction module 420 can be used to build an initial defect detection model based on the texture adaptive attention model and the YOLOv5 network model. The texture adaptive attention model can be used to enhance and extract the global texture features of the historical PCB board images. The training module 430 can be used to input historical PCB board images into the initial defect detection model for training to obtain a PCB board defect detection model.
[0111] In some embodiments, the construction module 420 may include a fusion unit and a deletion unit.
[0112] The fusion unit can be used to fuse the texture adaptive attention model into the spatial pyramid pooling module and the path aggregation network module of the YOLOv5 network model to obtain a fusion model; the deletion unit can be used to delete the cross-stage local module and the spatial pyramid pooling module in the fusion model to obtain an initial defect detection model.
[0113] In some embodiments, the training device 400 for the PCB defect detection model may further include a fusion module.
[0114] The fusion module can be used to construct the initial defect detection model based on the texture adaptive attention model and the YOLOv5 network model in the construction module 420, and fuse the deep convolution module, the vertical and horizontal cross attention module, the compression excitation module and the rectified linear unit activation function module to obtain the texture adaptive attention model.
[0115] In some embodiments, the depthwise convolution module, the cross-attention module, the squeeze-excitation module, and the rectified linear unit activation function module can be connected in sequence.
[0116] In some embodiments, the deep convolution module can be used to perform deep feature extraction on historical PCB board images to obtain a first feature map; the vertical and horizontal cross attention module can be used to extract and fuse the global texture features of the first feature map to obtain a second feature map.
[0117] The compression excitation module can be used to assign weights to the second feature map to obtain a third feature map; the rectified linear unit activation function module can be used to perform rectified linear unit activation function processing on the third feature map.
[0118] In some embodiments, the training device 400 for a PCB defect detection model may further include a first determination module and a processing module.
[0119] The first determination module can be used for the training module 430 to input historical PCB board images into the initial defect detection model for training. Before obtaining the PCB board defect detection model, the training set and the test set are determined based on the historical PCB board images; the processing module can be used to perform data enhancement processing on the training set to obtain an enhanced training set.
[0120] In some implementations, the training module 430 may include a training unit.
[0121] The training unit can be used to input the enhanced training set into the initial defect detection model for training to obtain a PCB board defect detection model.
[0122] The solution provided in this embodiment obtains historical PCB board images, which contain PCB defect information, and constructs an initial defect detection model based on a texture adaptive attention model and a YOLOv5 network model. The texture adaptive attention model is used to enhance and extract global texture features of the historical PCB board images. The historical PCB board images are input into the initial defect detection model for training to obtain a PCB board defect detection model. This achieves the training of the initial defect detection model constructed based on the texture adaptive attention model and the YOLOv5 network model based on the historical PCB board images to obtain a PCB board defect detection model. The PCB board defect detection model has high detection accuracy for PCB board defects, which is conducive to improving the detection accuracy of PCB board defects.
[0123] Furthermore, the texture adaptive attention model can be used to enhance and extract the global texture features of PCB board images, which is conducive to improving the learning ability of the PCB board defect detection model to learn the global texture features of PCB board images, making small target PCB board defects easier to detect, which is conducive to further improving the detection accuracy of PCB board defect detection.
[0124] See also Figure 8 , which shows a PCB board defect detection device 500 provided by an embodiment of the present application. The PCB board defect detection device 500 can be applied to Figure 1 The processing device 300 in the PCB board defect detection system shown in FIG. 3 is taken as an example below. Figure 8 The PCB board defect detection device 500 shown in FIG. 5 is described in detail. The PCB board defect detection device 500 may include a current image acquisition module 510 and an input module 520 .
[0125] The current image acquisition module 510 can be used to obtain the current PCB board image of the PCB board to be inspected; the input module 520 can be used to input the current PCB board image into the PCB board defect detection model to obtain the corresponding PCB board defect detection result; wherein, the PCB board defect detection model can be trained based on the PCB board defect detection model training method provided in the aforementioned embodiment.
[0126] In some implementations, the PCB defect detection apparatus 500 may further include a second determination module and a sending module.
[0127] The second determination module can be used to determine the processing solution corresponding to the first detection result when the PCB board defect detection result is a first detection result used to characterize that the current PCB board image contains PCB defect information; the sending module can be used to send the processing solution to the client associated with the inspection personnel.
[0128] The solution provided in this embodiment obtains a current PCB image of the PCB to be inspected and inputs the current PCB image into a PCB defect detection model to obtain a corresponding PCB defect detection result. This implements defect detection on the PCB based on the PCB defect detection model, thereby improving the detection accuracy of PCB defect detection.
[0129] Furthermore, the texture-adaptive attention model can be used to enhance and extract the global texture features of PCB board images, thereby improving the learning ability of the PCB board defect detection model to learn the global texture features of PCB board images, making small target PCB board defects easier to detect, thereby further improving the detection accuracy of PCB board defect detection.
[0130] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to in detail. For the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, refer to the partial description of the method embodiments. Any processing method described in the method embodiment can be implemented by the corresponding processing module in the device embodiment, and will not be repeated in detail in the device embodiment.
[0131] In addition, the functional modules in the various embodiments of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into a single module. The above-mentioned integrated modules may be implemented in the form of hardware or software functional modules.
[0132] See also Figure 9, which shows a functional block diagram of an electronic device 600 provided by an embodiment of the present application. The electronic device 600 may include one or more of the following components: a memory 610, a processor 620, and one or more applications, wherein the one or more applications may be stored in the memory 610 and configured to be executed by the one or more processors 620, and the one or more applications are configured to execute the method described in the aforementioned method embodiment.
[0133] The memory 610 may include a random access memory (RAM) or a read-only memory (ROM). The memory 610 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 610 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as obtaining a historical PCB board image, building an initial defect detection model, enhancing global texture features, extracting global texture features, inputting a historical PCB board image, training an initial defect detection model, obtaining a PCB board defect detection model, fusing a model, obtaining a fusion model, deleting a module, obtaining an initial defect detection model, fusing a module, obtaining a texture adaptive attention model, extracting deep features, obtaining a first feature map, extracting global texture features, fusing global texture features, obtaining a second feature map, assigning weights, obtaining a third feature map, performing a rectified linear unit activation function process, determining a training set, determining a test set, performing data enhancement processing, obtaining an enhanced training set, inputting an enhanced training set, obtaining a current PCB board image, inputting a current PCB board image, obtaining a PCB board defect detection result, determining a processing solution, and sending a processing solution, etc.), instructions for implementing the following various method embodiments, etc. The data storage area can also store data created by the electronic device 600 during use (such as historical PCB board images, PCB defect information, texture adaptive attention model, YOLOv5 network model, initial defect detection model, global texture features, PCB board defect detection model, spatial pyramid pooling module, path aggregation network module, fusion model, cross-stage local module, deep convolution module, vertical and horizontal cross attention module, compression excitation module, rectified linear unit activation function module, first feature map, second feature map, third feature map, training set, test set, enhanced training set, PCB board to be detected, current PCB board image, PCB board defect detection result, PCB defect information, first detection result, processing plan, detection personnel and client), etc.
[0134] The processor 620 may include one or more processing cores. The processor 620 utilizes various interfaces and circuits to connect various components within the electronic device 600. It executes instructions, programs, code sets, or instruction sets stored in the memory 610, and accesses data stored in the memory 610 to perform various functions and process data within the electronic device 600. Optionally, the processor 620 may be implemented using at least one hardware form factor selected from the group consisting of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 620 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem handles wireless communications. It is understood that the modem may not be integrated into the processor 620 and may instead be implemented separately via a communications chip.
[0135] Please refer to Figure 10 , which shows a block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable storage medium 700 stores program code 710, which can be called by a processor to execute the method described in the above method embodiment.
[0136] The computer-readable storage medium 700 can be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk, or a ROM. Alternatively, the computer-readable storage medium 700 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 700 has storage space for program code 710 for executing any of the method steps described above. These program codes can be read from or written to one or more computer program products. The program code 710 can be compressed, for example, in a suitable form.
[0137] Please refer to Figure 11, which shows a block diagram of the structure of a computer program product 800 provided in an embodiment of the present application. The computer program product 800 includes a computer program / instructions 810, which is stored in a computer-readable storage medium of a computer device. When the computer program product 800 is executed on the computer device, the computer device's processor reads the computer program / instructions 810 from the computer-readable storage medium and executes the computer program / instructions 810, causing the computer device to perform the method described in the above method embodiment.
[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A training method for a PCB board defect detection model, characterized in that: include: Acquire a historical PCB board image, where the historical PCB board image contains PCB defect information; Building an initial defect detection model based on a texture adaptive attention model and a YOLOv5 network model, wherein the texture adaptive attention model is used to enhance and extract global texture features of the historical PCB board image; The historical PCB board image is input into the initial defect detection model for training to obtain a PCB board defect detection model.
2. The training method according to claim 1, characterized in that The initial defect detection model is constructed based on the texture adaptive attention model and the YOLOv5 network model, including: Fusing the texture adaptive attention model between the spatial pyramid pooling module and the path aggregation network module of the YOLOv5 network model to obtain a fusion model; The cross-stage local module and the spatial pyramid pooling module in the fusion model are deleted to obtain the initial defect detection model.
3. The training method according to claim 1, characterized in that Before constructing the initial defect detection model based on the texture adaptive attention model and the YOLOv5 network model, the training method further includes: The texture adaptive attention model is obtained by fusing the deep convolution module, the cross-attention module, the compression excitation module and the rectified linear unit activation function module; The depth convolution module, the vertical and horizontal cross attention module, the compression excitation module and the rectified linear unit activation function module are connected in sequence.
4. The training method according to claim 3, characterized in that The deep convolution module is used to extract deep features from the historical PCB board image to obtain a first feature map; the vertical and horizontal cross attention module is used to extract and fuse the global texture features of the first feature map to obtain a second feature map; The compression excitation module is used to assign weights to the second feature map to obtain a third feature map; the corrected linear unit activation function module is used to perform corrected linear unit activation function processing on the third feature map.
5. The training method according to any one of claims 1 to 4, characterized in that: Before inputting the historical PCB board image into the initial defect detection model for training to obtain the PCB board defect detection model, the training method further includes: Determine a training set and a test set based on the historical PCB board images; Performing data enhancement processing on the training set to obtain an enhanced training set; The inputting the historical PCB board image into the initial defect detection model for training to obtain the PCB board defect detection model includes: The enhanced training set is input into the initial defect detection model for training to obtain the PCB board defect detection model.
6. A PCB board defect detection method, characterized in that: include: Obtain the current PCB board image of the PCB board to be inspected; Inputting the current PCB board image into the PCB board defect detection model to obtain a corresponding PCB board defect detection result; The PCB board defect detection model is trained based on the training method described in any one of claims 1 to 5.
7. The PCB board defect detection method according to claim 6, characterized in that: Also includes: When the PCB board defect detection result is a first detection result used to indicate that the current PCB board image contains PCB defect information, determining a processing solution corresponding to the first detection result; Send the processing solution to the client associated with the inspector.
8. A training device for a PCB board defect detection model, characterized in that: include: A historical image acquisition module is used to acquire historical PCB board images, wherein the historical PCB board images contain PCB defect information; A construction module is used to build an initial defect detection model based on a texture adaptive attention model and a YOLOv5 network model, wherein the texture adaptive attention model is used to enhance and extract global texture features of the historical PCB board image; The training module is used to input the historical PCB board image into the initial defect detection model for training to obtain a PCB board defect detection model.
9. An electronic device, characterized in that: include: Memory; one or more processors coupled to the memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by one or more processors, and the one or more applications are configured to execute the training method according to any one of claims 1 to 5, and / or the PCB board defect detection method according to any one of claims 6 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, which can be called by a processor to execute the training method according to any one of claims 1 to 5, and / or the PCB board defect detection method according to any one of claims 6 to 7.
Citation Information
Patent Citations
Image target detection method combining lightweight attention mechanism and YOLOv3 network
CN113869412A
Deep neural network bearing fault diagnosis method containing attention mechanism
CN115905806A
Lightweight neural network airport scene plane identification method
CN116343011A
Workpiece surface defect detection method and device based on attention mechanism
CN116777853A
Micro-expression recognition method based on feature fusion and structure re-parameterization
CN117456580A