A PCB layer category identification method, electronic equipment and readable storage medium
By combining a multi-branch deep neural network with a regular mapping rule base and image recognition technology, the problem of non-standard naming in PCB layer category recognition is solved, achieving higher recognition accuracy and reliability, and supporting automated recognition in complex scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JIEYI TECHNOLOGY (WUXI) CO LTD
- Filing Date
- 2025-09-29
- Publication Date
- 2026-06-09
Smart Images

Figure CN121236470B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of PCB technology, and more specifically, to a method for identifying PCB layer categories, an electronic device, and a readable storage medium. Background Technology
[0002] With the rapid development of electronic information technology, the design and manufacturing of printed circuit boards (PCBs) have become increasingly complex, and multilayer board structures have become the mainstream configuration. Accurately identifying and distinguishing different types of PCB layers (such as signal layers, power layers, solder mask layers, silkscreen layers, drill layers, etc.) is a crucial step in ensuring design correctness and manufacturing quality during PCB design, manufacturing, and post-testing.
[0003] Currently, the industry typically uses regular expression matching rules, i.e., layer category identification methods based on file naming rules. PCB design software outputs Gerber files that usually contain multiple files, each corresponding to a layer of the PCB, and the filename often includes layer type information. Traditional methods use a predefined regular expression rule base to match keywords in the filename, thereby achieving automatic layer category identification and classification. While this method is simple to implement and fast, it has significant limitations: First, different designers, different design software, and even different project teams may use different naming conventions, resulting in insufficient generalization ability of the rule base, requiring continuous maintenance and expansion; second, when filenames are not standardized, naming information is missing, or there is ambiguity, the rule-based method cannot correctly identify the layer category; finally, this method relies entirely on filename information and cannot handle abnormal situations where file content and name do not match. Summary of the Invention
[0004] The purpose of this application is to provide a PCB layer category identification method, an electronic device, and a readable storage medium to address the shortcomings of the prior art.
[0005] Firstly, a method for identifying PCB layer categories is provided, including...
[0006] The parsing process identifies the filename of each PCB file based on the PCB file group.
[0007] Based on a pre-established regular expression mapping rule library, each PCB file is initially matched for its layer category according to its filename.
[0008] For PCB files that cannot be matched by the regular expression mapping rule library, obtain the layer content of the PCB file and take a screenshot;
[0009] The content of the screenshot is input into a pre-trained visual model, which outputs the layer category labels of the PCB file based on the content of the screenshot.
[0010] Furthermore, the training architecture of the visual model adopts a multi-branch deep neural network, which includes a backbone feature extraction module, a multi-scale feature enhancement module, an element perception branch module, and a classification module.
[0011] The backbone feature extraction module is used to propose general basic features of the image and provide them to the multi-scale feature enhancement module, the element perception branch module and the classification module;
[0012] The multi-scale feature enhancement module is used to fuse feature maps from different levels of the backbone feature extraction module and introduce an attention mechanism.
[0013] The element perception module branch module includes multiple branch networks, each branch network is used to detect a PCB feature element and output the density estimate of the corresponding element in the image.
[0014] The classification module is used for feature fusion and classification decisions.
[0015] Furthermore, the element sensing module branch module includes:
[0016] The trace feature extraction branch is configured to detect linear structure features;
[0017] The copper skin feature extraction branch is configured to detect copper area features with an area greater than a set threshold.
[0018] The pad feature extraction branch is configured to detect circular or square pad features.
[0019] The text feature extraction branch is configured to detect character and identifier features;
[0020] Each branch outputs the density estimate of the corresponding element, forming the element density vector d.
[0021] Furthermore, during the training of the visual model, a multi-task loss function is used for optimization. The multi-task loss function is expressed as follows:
[0022]
[0023] Where L cls The primary classification loss is used, employing a weighted focus loss function; L d For element density consistency loss, calculate the difference between the predicted element density vector d and the predefined element density vectors for each category; L shape The shape feature consistency loss is calculated by determining the difference between the predicted shape features and the pre-acquired true shape features; λ1 and λ2 are weighting coefficients.
[0024] Furthermore, the function of the main classification loss is:
[0025]
[0026] Where N represents the number of samples in a training batch; C is the total number of categories in the PCB layer; y i c indicates whether the true label of sample i belongs to category c. If sample i belongs to category c, the value is 1; otherwise, it is 0. i c represents the probability that the model predicts sample i belongs to class c; w c γ represents the category weight; γ is the focusing parameter.
[0027] The function for the loss of element density uniformity is:
[0028]
[0029] in, This shows the predicted density value of the j-th element type for the i-th sample; This represents the expected density value of the j-th element type within the category ci of the i-th sample;
[0030] The function for shape feature consistency loss is:
[0031]
[0032] Where K is the dimension length of the shape feature vector; It is the k-th element of the predicted shape feature vector of the i-th sample; It is the k-th element of the true shape feature vector of the i-th sample image.
[0033] Furthermore, the method for calculating the true shape feature vector of the image includes:
[0034] The input PCB image is pre-processed into a binary image to generate a binary image.
[0035] Calculate the Hu invariant moments of the binary image to obtain a 7-dimensional Hu invariant moment feature vector;
[0036] Calculate the Zernike moments of the binary image, select the first 5 moments to obtain a 5-dimensional Zernike moment feature vector;
[0037] The 7-dimensional Hu invariant moment feature vector and the 5-dimensional Zernike moment feature vector are concatenated and fused to form a 12-dimensional joint shape feature vector.
[0038] Furthermore, the process of proposing the prediction vector of the shape feature includes:
[0039] Obtain the multi-channel feature map output by the multi-scale feature enhancement module;
[0040] Perform a global average pooling operation on the multi-channel feature map to generate a pooled feature vector;
[0041] The pooled feature vector is input into a regression network, which adopts a multilayer perceptron structure.
[0042] Through the nonlinear transformation processing of the regression network, a 12-dimensional shape feature prediction vector is output that is aligned with the true shape feature vector in the feature space.
[0043] Furthermore, the training of the visual model includes three stages:
[0044] Phase 1: Optimize using only the main classification loss function, learn basic image features, and freeze all trainable parameters of the element-aware branch module.
[0045] Phase 2: Simultaneously activate the main classification loss function and the element density consistency loss function to enhance element perception, and unfreeze all trainable parameters of the element perception branch module.
[0046] Phase 3: Simultaneously enable the main classification loss function, element density consistency loss function, and shape feature consistency loss function to optimize shape consistency.
[0047] In a second aspect, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the program to implement the steps of the method described in the first aspect.
[0048] In a second aspect, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect. Attached Figure Description
[0049] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1-7 These are rendering diagrams of the outer positive signal layer, inner positive signal layer, inner negative ground layer, positive character layer, positive solder mask layer, positive outline layer, and drill layer in a PCB.
[0051] Figure 8 This is a schematic diagram of the architecture of the multi-branch deep neural network in this application;
[0052] Figure 9This is a flowchart of the PCB layer category identification method in this application. Detailed Implementation
[0053] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Unless otherwise defined, the technical or scientific terms used in this application should have the ordinary meaning understood by those skilled in the art. The words "first," "second," and similar terms used in this application do not indicate any order, quantity, or importance, but are only used to distinguish different components. The words "comprising" or "including," etc., mean that the element or object preceding the word covers the element or object listed after the word and its equivalents, but do not exclude other elements or objects. The words "connected," "coupled," or "connected," etc., are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up," "down," "left," "right," etc., are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0054] The PCB layer category identification method in this application embodiment is as follows: Figure 9 As shown, the PCB layer categories are first identified using regular expressions. First, we need to define a rule base to map common naming patterns to specific layer categories. The rule base is divided into a general rule base and a customer-customized rule base. The general rule base is suitable for most customers, while the customer-customized rule base is... The mapping rules for the general rule base are as follows:
[0055] Layer Category Common naming patterns describe Top / bottom signal layer `(Top BOT Inner signal layer `(L2 L3 Power / Ground `(GND PWR solder mask `(SolderMask SM silkscreen layer `(SilkScreen SS flux layer `(Paste PT borehole layer `(Drill DRL Border / Outline Layer `(Outline OL Pore `(Hole Plated).*`
[0056] Gerber files are the standard output format in the PCB manufacturing industry. They are a collection of files, each corresponding to a layer of the PCB. Files include extensions such as ".gbr", ".gm1", and ".art". Each layer is output as a separate Gerber file. Drilling information is described by another standard file, ExcellonDrill (.drl, .txt). The entire Gerber file set is imported into software such as CAM350 and GC-CAM. The software automatically reads all files. Layer stack-up, material information, etc., are typically defined in IPC-356 or ".drl" files. By parsing the filename of each Gerber file, it is initially determined which physical layer it corresponds to.
[0057] Gerber files are a vector graphics format. GC-CAM renders (rasterizes) vector data into individual images. The rendered single-layer images can be used as training data for visual models.
[0058] When judging the visual characteristics of different PCB layers, most judgments are based on the complete image of the entire layer, but some special patterns can be judged quickly.
[0059] The characteristics of common layer categories are shown in the table below:
[0060] Layer category labels Explanation Image characteristics Corresponding to the attached diagram signal_positive_out Outer positive signal layer The three elements of traces, copper foil, and pads are evenly contained Figure 1 signal_positive_inner Inner positive signal layer The upper layer mainly consists of traces and copper foil, with relatively few solder pads. Figure 2 power_ground_negative_inner Inner negative ground layer The layer includes a clear thermal pad design. Figure 3 silk_screen_positive Positive character layer The layer contains a lot of text with rectangular full-frame or half-frame logos. Figure 4 solder_mask_positive Positive solder mask The entire layer of pattern mainly consists of pads. Figure 5 rout_positive Positive shape layer It contains only this single outline. Figure 6 drill_positive borehole layer The entire floor is almost entirely composed of circular shapes, typically formed by drilled holes. Figure 7
[0061] The training method for visual models is as follows:
[0062] All PCB layer images were adjusted to a uniform size (384×384 pixels) and normalized.
[0063] PCB-specific data enhancement:
[0064] Enhance the variation of signal layer traces by randomly adding serpentine traces;
[0065] Enhanced text occlusion at the character layer to simulate incomplete printing.
[0066] Enhance circular disturbances in the borehole layer by randomly adding / deleting circular boreholes.
[0067] In this embodiment, the training architecture of the visual model adopts a multi-branch deep neural network, such as... Figure 8 As shown, the multi-branch deep neural network includes a backbone feature extraction module, a multi-scale feature enhancement module, an element-aware branch module, and a classification module.
[0068] The backbone feature extraction module uses either the DenseNet-121 or DenseNet-169 model and is responsible for extracting multi-level, general-purpose visual features from the input image. It extracts features layer by layer from low-level (edges, corners, textures) to high-level (complex structures, patterns), providing a rich, multi-resolution feature map for use by all subsequent specialized modules. This avoids each module repeatedly extracting basic features from the original image, thus improving efficiency.
[0069] A multi-scale feature enhancement module addresses the issue of varying scales in PCB images and focuses on key regions. PCB elements exhibit significant size differences (e.g., fine traces vs. large copper areas), requiring the network to simultaneously understand information at different scales. A Feature Pyramid Network (FPN) and a Convolutional Attention (CBAM) module can be integrated into the backbone network. This fuses feature maps from different levels of the backbone feature extraction module, resulting in features that contain both high-level semantic information and low-level detail. The network learns to automatically focus on the most important image regions for the current layer category (e.g., focusing on heat sink pads when identifying power layers, and text regions when identifying character layers), suppressing interference from irrelevant background information.
[0070] The element perception module includes four extraction branches: trace feature extraction, copper feature extraction, pad feature extraction, and text feature extraction. Each branch network is used to detect a PCB feature element and output the density estimate of the corresponding element in the image. Each branch module can use a lightweight convolutional network module.
[0071] The trace feature extraction branch can employ Large-Kernel Dilated Convolution (LDC), which can visualize longer line segments at once, better perceiving linear direction and continuity. Without increasing parameters or reducing resolution, it expands the receptive field, captures long-range dependencies in long traces, and prevents line breaks.
[0072] The core structure of the copper surface feature extraction branch is Spatial Pyramid Pooling with Dips (ASPP). ASPP, by using multiple dilated convolutions with different expansion rates in parallel, can simultaneously capture local details and global contextual information of the copper surface region, detecting copper area features larger than a set threshold. The pad feature extraction branch employs a lightweight hourglass module. Pads require precise positioning and shape depiction; the hourglass structure can compress information before upsampling to recover details, helping to generate more accurate pad probability maps.
[0073] The text feature extraction branch employs asymmetric convolution combined with a recurrent neural network (RNN), using (1,5) or (5,1) rectangular convolution kernels to match the horizontal or vertical arrangement of characters and capture the sequence relationships between characters. After convolutional features, an RNN (such as LSTM) or Transformer layer is introduced to scan features along the direction of the text lines. The memory function of the RNN enables it to understand the contextual relationships between characters.
[0074] Finally, each branch outputs a single-channel heatmap with the same width and height as the input image. Each pixel value in the heatmap represents the probability that a corresponding element (such as a trace) exists at that location. Aggregating the heatmap yields a scalar value representing the overall density of its elements. This can be achieved using Global Average Pooling (GAP), which directly calculates the average value of all pixel values in the heatmap. The average value, between 0 and 1, reflects the average probability or coverage of that element in the entire image.
[0075] Finally, the scalar density values calculated from the four branches are concatenated into a 4-dimensional vector to form the element density vector d.
[0076] The classification module can employ a Multilayer Perceptron (MLP) in conjunction with a Softmax module for feature fusion and classification decisions. It comprehensively analyzes the rich but diverse information provided by all preceding modules (multi-scale feature enhancement module, element perception branch) to make a final decision. The high-dimensional fused feature vector is mapped to low-dimensional probability scores for each class. The output is a clear result conforming to the probability distribution, for example, [signal layer: 0.85, solder mask layer: 0.1,...], showing the model's confidence level for each class.
[0077] During the training of the visual model, a multi-task loss function is used for optimization. The multi-task loss function is expressed as follows:
[0078]
[0079] Where L cls The primary classification loss is used, employing a weighted focus loss function; L d For element density consistency loss, calculate the difference between the predicted element density vector d and the predefined element density vectors for each category; L shape The shape feature consistency loss is calculated by determining the difference between the predicted shape features and the pre-acquired true shape features; λ1 and λ2 are weighting coefficients.
[0080] The function for the main classification loss is:
[0081]
[0082] Where N represents the number of samples in a training batch; C is the total number of categories in the PCB layer; yi,c represents whether the true label of sample i belongs to category c, which is 1 if sample i belongs to category c, and 0 otherwise; pi,c represents the probability that the model predicts that sample i belongs to category c; wc is the category weight; and γ is the focusing parameter.
[0083] The element density consistency loss is based on prior knowledge of PCB layer categories. The expected element density vector for each category is defined as follows:
[0084] Outer positive signal layer: [0.3, 0.3, 0.3, 0.1];
[0085] Inner positive signal layer: [0.4, 0.4, 0.1, 0.1];
[0086] Inner negative ground layer: [0.2, 0.3, 0.4, 0.1];
[0087] Positive character layer: [0.1, 0.1, 0.1, 0.7];
[0088] Positive solder mask layer: [0.1, 0.1, 0.7, 0.1];
[0089] Positive shape layer: [0.9, 0.1, 0.0, 0.0];
[0090] Drilling layer: [0.1, 0.1, 0.8, 0.0];
[0091] The function for loss of element density uniformity is:
[0092]
[0093] in, This represents the predicted density value of the j-th element type for the i-th sample; This represents the predefined density value of the j-th element type within the category ci to which the i-th sample belongs;
[0094] The function for shape feature consistency loss is:
[0095]
[0096] Where K is the dimension length of the shape feature vector; It is the k-th element of the predicted shape feature vector of the i-th sample; It is the k-th element of the true shape feature vector of the i-th sample image.
[0097] Methods for calculating the true shape feature vector of an image include:
[0098] The input PCB image is pre-processed into a binary image to generate a binary image.
[0099] Calculate the Hu invariant moments of the binary image to obtain a 7-dimensional Hu invariant moment feature vector;
[0100] Calculate the Zernike moments of the binary image, select the first 5 moments to obtain a 5-dimensional Zernike moment feature vector;
[0101] The 7-dimensional Hu invariant moment feature vector and the 5-dimensional Zernike moment feature vector are concatenated and fused to form a 12-dimensional joint shape feature vector.
[0102] The calculation of Zernike moments involves constraints on the radial polynomial order n and the repetition m, where n ranges from 0 to 4, and m satisfies the constraint that |m|≤n and n-|m| is even. The calculation of Hu invariant moments is based on the normalization of the central moments of the binary image, while the calculation of Zernike moments is based on the orthogonal polynomial transformation on the unit disk.
[0103] The process of proposing the prediction vector for shape features includes:
[0104] Obtain the multi-channel feature map output by the multi-scale feature enhancement module;
[0105] Perform a global average pooling operation on the multi-channel feature map to generate a pooled feature vector;
[0106] The pooled feature vector is input into a regression network, which adopts a multilayer perceptron structure.
[0107] The regression network performs a nonlinear transformation, outputting a 12-dimensional shape feature prediction vector aligned with the true shape feature vector in the feature space. The regression network includes a hidden layer and a ReLU activation function, while its output layer uses a linear activation function.
[0108] The training of a visual model consists of three stages:
[0109] The first stage is the basic feature learning stage, which uses only the main classification loss function for optimization, learns the basic features of the image, and freezes all trainable parameters of the element perception branch module.
[0110] The second stage is the element perception enhancement stage: simultaneously enabling the main classification loss function and the element density consistency loss function to enhance element perception, and unfreezing all trainable parameters of the element perception branch module.
[0111] The third stage is the shape consistency optimization stage: simultaneously enabling the main classification loss function, element density consistency loss function, and shape feature consistency loss function to optimize shape consistency, and using high-resolution input for training.
[0112] After the visual model is trained, it is loaded into the system. For PCB files that cannot be matched by the regular expression mapping rule library, the system obtains the layer content of the PCB file and takes a screenshot. Based on the content of the screenshot, the pre-trained visual model outputs the layer category label of the PCB file.
[0113] This application's embodiments improve the accuracy and reliability of PCB layer category identification by integrating regular expression matching and deep learning visual recognition mechanisms, effectively solving the identification difficulties caused by non-standard naming or complex features in traditional methods. Based on a professionally designed element-aware branch network and multi-scale feature enhancement module, the system can accurately capture the core visual features of different PCB layer types, such as the continuity of traces, the shape distribution of pads, and the sequence characteristics of characters, enhancing the model's generalization ability in complex scenarios. It supports automated identification of a wide range of PCB layers, providing a visual basis for decision-making.
[0114] Based on the same inventive concept, this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory, characterized in that the processor executes the program to implement the steps in the PCB layer category identification method in the above embodiments.
[0115] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform any of the methods described in the above embodiments.
[0116] Those skilled in the art will understand that the embodiments in this application can be provided as methods, systems, or computer program products. Therefore, the embodiments in this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the embodiments in this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0117] This application describes embodiments of methods, apparatus (systems), and computer program products according to embodiments of this application with reference to flowchart illustrations and / or block diagrams. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0118] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0119] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0120] Although preferred embodiments have been described in this application, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of this application.
[0121] Obviously, those skilled in the art can make various modifications and variations to the embodiments of this application without departing from the spirit and scope of the embodiments of this application. Therefore, if these modifications and variations to the embodiments of this application fall within the scope of the claims in this application and their equivalents, then this application also intends to include these modifications and variations.
Claims
1. A method for identifying PCB layer categories, characterized in that: include Parse the PCB file group and identify the filename of each PCB file; Based on a pre-established regular expression mapping rule library, each PCB file is initially matched for its layer category according to its filename. For PCB files that cannot be matched by the regular expression mapping rule library, obtain the layer content of the PCB file and take a screenshot; The content of the screenshot is input into a pre-trained visual model, which outputs the layer category labels of the PCB file based on the content of the screenshot. The training architecture of the visual model adopts a multi-branch deep neural network, which includes a backbone feature extraction module, a multi-scale feature enhancement module, an element perception branch module, and a classification module. The backbone feature extraction module is used to extract basic image features and provide them to the multi-scale feature enhancement module, the element perception branch module, and the classification module. The multi-scale feature enhancement module is used to fuse feature maps from different levels of the backbone feature extraction module and introduce an attention mechanism. The element perception branch module includes multiple branch networks, each branch network is used to detect a PCB feature element and output the density estimate of the corresponding element in the image to form an element density vector d; wherein, each branch network is configured to: generate a single-channel probability map with the same size as the input image, wherein each pixel value in the probability map represents the probability that the PCB feature element exists at the corresponding position; and perform global average pooling on the probability map to obtain a scalar value representing the overall density of the element as the density estimate. The branch network includes: The trace feature extraction branch is configured to detect linear structure features; The copper skin feature extraction branch is configured to detect copper area features with an area greater than a set threshold. The pad feature extraction branch is configured to detect circular or square pad features. The text feature extraction branch is configured to detect character and identifier features; The classification module is used to receive multi-source feature vectors fused from the multi-scale feature enhancement module and the element perception branch module, map the high-dimensional fused features to probability scores of each target category, and output classification confidence.
2. The PCB layer category identification method according to claim 1, characterized in that, During the training of the visual model, a multi-task loss function is used for optimization. The multi-task loss function is expressed as follows: Where L cls The primary classification loss is used, employing a weighted focus loss function; L d For element density consistency loss, calculate the difference between the predicted element density vector d and the predefined element density vectors for each category; L shape For shape feature consistency loss, the difference between the predicted shape features and the pre-acquired true shape features is calculated; λ1 and λ2 are weighting coefficients.
3. The PCB layer category identification method according to claim 2, characterized in that... The function of the main classification loss is: Where N represents the number of samples in a training batch; C is the total number of categories in the PCB layer; This indicates whether the true label of sample i belongs to category c. If sample i belongs to category c, the value is 1; otherwise, it is 0. w represents the probability that the model predicts sample i belongs to class c; c γ represents the category weight; γ is the focusing parameter. The function for the loss of element density uniformity is: in, This represents the density estimate of the j-th element type for the i-th sample; Indicates the category c to which the i-th sample belongs. i The predefined standard density value for the j-th element type; The function for shape feature consistency loss is: Where K is the dimension length of the shape feature vector; It is the k-th element of the predicted shape feature vector of the i-th sample; It is the k-th element of the true shape feature vector of the i-th sample image.
4. The PCB layer category identification method according to claim 3, characterized in that... The method for calculating the true shape feature vector of the image includes: The input PCB image is pre-processed into a binary image to generate a binary image. Calculate the Hu invariant moments of the binary image to obtain a 7-dimensional Hu invariant moment feature vector; Calculate the Zernike moments of the binary image, select the first 5 moments to obtain a 5-dimensional Zernike moment feature vector; The 7-dimensional Hu invariant moment feature vector and the 5-dimensional Zernike moment feature vector are concatenated and fused to form a 12-dimensional joint shape feature vector.
5. The PCB layer category identification method according to claim 4, characterized in that: The process of extracting the predicted shape feature vector includes: Obtain the multi-channel feature map output by the multi-scale feature enhancement module; Perform a global average pooling operation on the multi-channel feature map to generate a pooled feature vector; The pooled feature vector is input into a regression network, which adopts a multilayer perceptron structure. Through the nonlinear transformation processing of the regression network, a 12-dimensional shape feature prediction vector is output that is aligned with the true shape feature vector in the feature space.
6. The PCB layer category identification method according to claim 5, characterized in that: The training of the visual model includes three stages: Phase 1: Optimize using only the main classification loss function, learn basic image features, and freeze all trainable parameters of the element-aware branch module. Phase 2: Simultaneously activate the main classification loss function and the element density consistency loss function to enhance element perception, and unfreeze all trainable parameters of the element perception branch module. Phase 3: Simultaneously enable the main classification loss function, element density consistency loss function, and shape feature consistency loss function to optimize shape consistency.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, When the processor executes the program, it implements the steps of the method as described in any one of claims 1-6.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method as described in any one of claims 1-6.
Citation Information
Patent Citations
PCB defect detection method and system based on Gerber file
CN119067937A
Defect target detection method based on improved YOLOv8
CN120564000A