Spray code character defect detection method and device based on improved GLASS network

By improving the deformable adaptive cutting and multi-scale dynamic attention fusion technology of GLASS network, the problems of feature breakage and dimensional explosion in ink-coded character detection are solved, and the accuracy and efficiency of detection are improved.

CN120496079AActive Publication Date: 2025-08-15HANGZHOU QOGORI TECH
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510963006.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-14
Publication Date
2025-08-15
Estimated Expiration
2045-07-14

AI Technical Summary

Technical Problem

The existing ink-coded character detection methods have broken features during cross-block defect detection, and the edge filling introduces noise. Multi-scale feature fusion leads to dimensional explosion, making it difficult to meet the lightweight deployment needs of industrial equipment.

Method used

The improved GLASS network is adopted to dynamically adjust the feature cutting position through the deformable adaptive cutting network, and feature weighted fusion is performed through a multi-scale dynamic attention fusion network, and defect detection is performed in combination with a spatial dynamic perception discriminator.

Benefits of technology

It effectively solves the problem of cross-block defect fracture during feature map cutting, reduces edge noise, avoids feature dimension explosion, and improves the accuracy and efficiency of ink-coded character defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120496079A_ABST
    Figure CN120496079A_ABST
Patent Text Reader

Abstract

The invention relates to a code spraying character defect detection method and device based on an improved GLASS network. The method comprises the following steps: acquiring image data of a code spraying area; inputting the image data into an improved GLASS network to carry out code spraying character defect detection and positioning; wherein the improved GLASS network comprises: a feature extractor, which is used for extracting a multi-scale feature map from the image data; the feature adapter comprises a deformable adaptive cutting network used for carrying out dynamic block cutting on the multi-scale feature map, and a multi-scale dynamic attention fusion network used for carrying out weighted fusion on the multi-scale features; and the discriminator is used for discriminating the output result of the feature adapter and outputting defect detection and positioning. By adopting the method, the detection precision of the character code spraying defect can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of industrial visual inspection, and in particular to a method and device for detecting defects in inkjet coding characters based on an improved GLASS network. Background Art

[0002] With the large-scale development of the new energy industry, detecting defects in inkjet-coded characters, such as slight smearing, broken lines, blurring, and broken patterns, during the production of batteries and electronic components has become a critical step in quality control. These defects typically exhibit submillimeter scale, require high cross-region continuity, and exhibit complex surface distortion. Existing detection methods, such as GLASS networks, combine multi-branch feature processing with a discriminator to detect anomalies in inkjet-coded images.

[0003] However, these methods suffer from the following drawbacks in practical applications of inkjet character detection: First, the fixed-step-size cutting mechanism used in feature maps results in the fragmentation of cross-block defect features, and noise introduced by edge padding further contaminates the feature representation. Second, the static weighting strategy employed in multi-scale feature fusion results in poor coupling between low-level details and high-level semantics. Direct concatenation leads to feature dimensionality explosion, and high-frequency details are severely attenuated during fusion. These drawbacks make existing inkjet character defect detection difficult to meet the requirements of lightweight deployment in industrial equipment. Therefore, a method is needed to improve the accuracy of inkjet character defect detection. Summary of the Invention

[0004] To solve the above problems, the present application provides a method and device for detecting defects in inkjet printing characters based on an improved GLASS network.

[0005] In a first aspect, the present application provides a method for detecting defects in inkjet characters based on an improved GLASS network, comprising:

[0006] Obtain image data of the coding area;

[0007] Inputting the image data into the improved GLASS network to detect and locate defects in inkjet characters;

[0008] Wherein, the improved GLASS network includes:

[0009] A feature extractor, configured to extract multi-scale image features from the image data to obtain a multi-scale feature map;

[0010] A feature adapter comprising a deformable adaptive cutting network and a multi-scale dynamic attention fusion network, wherein the deformable adaptive cutting network is used to dynamically adjust the feature cutting position through a learnable offset and dynamically block-cut the multi-scale feature map; the multi-scale dynamic attention fusion network is used to perform channel-aligned projection on the multi-scale feature map, generate spatially adaptive dynamic attention weights, and realize weighted fusion of the multi-scale features;

[0011] The discriminator is used to discriminate the output result of the feature adapter and output defect detection and positioning.

[0012] In one embodiment, dynamically dividing the multi-scale feature map into blocks includes:

[0013] The learnable cut block offset formula is:

[0014]

[0015] in, is the learnable cut block offset, is the convolution operation, is the convolution kernel, is the hyperbolic tangent activation function, A scaling factor that controls the magnitude of the offset.

[0016] In one embodiment, the deformable adaptive cutting network further constrains the offset of the cutting block in the edge area of the image by the following formula:

[0017]

[0018] in, is the offset direction and amplitude of the cut block in the edge area of the image, is the normalized distance from the current cut block to the edge area of the image.

[0019] In one embodiment, performing channel-aligned projection on the multi-scale feature map includes:

[0020] The high-level features of the multi-scale feature map Project to low-dimensional space to generate high-level projection features ,in is the batch size, is the number of channels of the low-level feature, H is the height of the high-level projection feature, and W is the width of the high-level projection feature map;

[0021] By using the cosine similarity loss function, the high-level projection features are constrained and the high-level features The consistency of , its objective function is:

[0022]

[0023] in, is global average pooling.

[0024] In one embodiment, generating spatially adaptive dynamic attention weights to achieve weighted fusion of the multi-scale features includes:

[0025] Projecting features on high levels With low-level features Splicing to form splicing features ;

[0026] The splicing feature The kernel performs a lightweight convolution operation and projects it into a new space to generate a two-dimensional attention weight:

[0027]

[0028] in, is the low-level feature weight, is the high-level feature weight, , Split is the channel splitting operation, and Softmax is the normalization operation;

[0029] The low-level features With the high-level features Fusion, the formula is:

[0030]

[0031] in, Budget for element-wise multiplication, is the weighted fusion feature.

[0032] In one embodiment, the multi-scale dynamic attention fusion network suppresses noise interference in the following way:

[0033] Use 1×1 convolution to weight the fusion features Projecting to the new vector space, we get ;

[0034] Instance normalization is used to eliminate statistical deviations within batches. The formula is:

[0035]

[0036] in, To calculate the instance mean of the channel, To calculate the instance variance of the channel, is a learnable scaling factor, is the learnable offset.

[0037] In one embodiment, the discriminator is a spatial dynamics perception discriminator, comprising:

[0038] Use depth-wise separable convolution and dilated convolution to obtain local and global features;

[0039] The local features are concatenated with the global features to generate spatially sensitive features, and the threshold is dynamically adjusted through a lightweight fully connected layer to adjust the sensitivity of defect detection.

[0040] In one embodiment, using depthwise separable convolution and dilated convolution to obtain local and global context features includes:

[0041] The feature map output by the feature adapter Restore to original spatial arrangement characteristics , where b is the batch size, c is the number of channels, and w is the width of the original spatial arrangement feature. ;

[0042] The original spatial arrangement features are obtained through depth-wise separable convolution Local features :

[0043]

[0044] in, is the depthwise convolution operation, is the depth convolution kernel, is the bias term;

[0045] Use dilated convolution to expand the receptive field and extract the local features Global characteristics of :

[0046]

[0047] in, is the dilated convolution operation, is the dilated convolution kernel.

[0048] In one embodiment, concatenating the local features with the global features to generate spatially sensitive features, and dynamically adjusting the threshold through a lightweight fully connected layer includes:

[0049] For the local features and the global features Perform splicing and fusion to generate spatially sensitive fusion features :

[0050]

[0051] The adaptive threshold is generated by a lightweight fully connected layer, and its formula is:

[0052]

[0053] in, is the weight matrix of the lightweight fully connected layer, is the global feature dimension, is the bias term of the lightweight fully connected layer;

[0054] Arrange features in the original space With the adaptive threshold Multiply the channels element by element to get the final discriminant score:

[0055]

[0056] in, is the weight matrix of the final discriminant layer, is the bias term of the final discriminant layer.

[0057] In a second aspect, the present application also provides a device for detecting defects in inkjet characters based on an improved GLASS network, comprising:

[0058] Image acquisition module, used to obtain image data of the coding area;

[0059] A defect detection module, used for inputting the image data into the improved GLASS network to detect and locate defects in the inkjet characters;

[0060] Wherein, the improved GLASS network includes:

[0061] A feature extractor, configured to extract multi-scale image features from the image data to obtain a multi-scale feature map;

[0062] A feature adapter comprising a deformable adaptive cutting network and a multi-scale dynamic attention fusion network, wherein the deformable adaptive cutting network is used to dynamically adjust the feature cutting position through a learnable offset and dynamically block-cut the multi-scale feature map; the multi-scale dynamic attention fusion network is used to perform channel-aligned projection on the multi-scale feature map, generate spatially adaptive dynamic attention weights, and realize weighted fusion of the multi-scale features;

[0063] The discriminator is used to discriminate the output result of the feature adapter and output defect detection and positioning.

[0064] The above-mentioned inkjet character defect detection method and device based on the improved GLASS network dynamically wraps the defect area through the learnable offset in the deformable adaptive cutting network, solves the problem of cross-block defect breakage during feature map cutting, constrains the offset of the cutting block in the edge area of the image, reduces the sampling of invalid filling areas, and eliminates edge noise; the multi-scale dynamic attention fusion network compresses high-level features to the same dimension as the low-level features, avoids feature dimension explosion, and effectively improves the accuracy of inkjet character defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments of the present application or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.

[0066] Figure 1 A diagram showing an application environment of a method for detecting defects in inkjet characters in one embodiment;

[0067] Figure 2 Flowchart of a method for detecting defects in inkjet characters in one embodiment;

[0068] Figure 3 is a flow chart of a deformable adaptive cutting network in one embodiment;

[0069] Figure 4 A comparison diagram of the visualization effect of a cutting block in one embodiment;

[0070] Figure 5 A flow chart of channel alignment projection in one embodiment;

[0071] Figure 6 This is a flowchart of weighted fusion of multi-scale features in one embodiment;

[0072] Figure 7 The network structure of a multi-scale dynamic attention fusion network in one embodiment;

[0073] Figure 8 A flowchart of obtaining local and global context features in one embodiment;

[0074] Figure 9 A flowchart of dynamically adjusting a threshold through a lightweight fully connected layer in one embodiment;

[0075] Figure 10 A comparison diagram of defect detection effects in one embodiment;

[0076] Figure 112 is a structural block diagram of a defect detection device in one embodiment. DETAILED DESCRIPTION

[0077] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0078] The inkjet character defect detection method based on the improved GLASS network provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. The terminal 102 communicates with the server 104 via the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers. The terminal 102 includes a data acquisition unit, including but not limited to industrial cameras, smart sensors, embedded detection equipment, etc., to obtain the inkjet image of the battery surface in real time. The terminal 102 can be, but is not limited to, various computers, laptops, smart phones, tablets, and IoT devices. The server 104, as the core processing unit, can be deployed as an independent physical server, a distributed cluster, or a cloud server to improve the model training, parameter optimization, and defect detection tasks of the GLASS network. The data storage system can be integrated with the server 104 or deployed as a cloud database to store training samples, historical detection results, and model parameters.

[0079] In an exemplary embodiment, a method for detecting defects in inkjet characters based on an improved GLASS network is provided. Figure 1 The computer equipment in the description is as follows, Figure 2 As shown, the following steps S201 to S202 are included:

[0080] S201, obtaining image data of the coding area.

[0081] Specifically, raw image data containing the coded characters is acquired through a data acquisition system, which includes intelligent terminal devices such as industrial cameras. To improve the accuracy of defect recognition, the raw image data must contain as complete a coded character as possible. If the image contains excessive edges, the character area can be calibrated and cropped.

[0082] During the network training and evaluation phase, the original image data is divided into a training set and a test set. The training set contains only normal samples, while the test set contains both normal and abnormal samples. Abnormal samples include minor defects such as minor smearing, line breaks, blurring, and broken frames. The training set is used to train the improved GLASS network, and the test set is used to evaluate the trained network.

[0083] S202: Input the image data into the improved GLASS network to detect and locate defects in inkjet characters.

[0084] Among them, the improved GLASS network includes: a feature extractor, which is used to extract multi-scale image features from the image data to obtain a multi-scale feature map; a feature adapter, which includes a deformable adaptive cutting network and a multi-scale dynamic attention fusion network. The deformable adaptive cutting network is used to dynamically adjust the feature cutting position through a learnable offset and dynamically block-cut the multi-scale feature map; the multi-scale dynamic attention fusion network is used to perform channel-aligned projection on the multi-scale feature map, generate spatially adaptive dynamic attention weights, and realize weighted fusion of the multi-scale features; a discriminator is used to discriminate the output results of the feature adapter and output defect detection and positioning.

[0085] The GLASS network is an unsupervised anomaly detection network based on anomaly synthesis. Its core framework consists of a normal branch, a global anomaly synthesis branch (GAS), and a local anomaly synthesis branch (LAS). The GAS branch uses gradient-guided Gaussian noise and truncated projections to synthesize anomaly features close to a normal distribution in the feature space, enhancing the detection of subtle defects. The LAS branch generates diverse anomalies at the image level through texture overlay, improving anomaly coverage. The three branches share a feature extractor and feature adapter, and the discriminator is used to jointly train the multi-branch defect detection network end-to-end.

[0086] The present invention improves the feature extractor in the GLASS network and uses a pre-trained convolutional neural network to extract features from image data. It is understood that this pre-trained convolutional neural network has been trained on a large-scale dataset and can extract rich image features and obtain multi-scale feature maps of the original image data.

[0087] Because feature extractors are typically pre-trained under different data distributions, the multi-scale feature maps they output may not be fully suitable for the character defect detection task. Therefore, a feature adapter is needed to adapt and generalize the feature maps output by the feature extractor by learning the data distribution of the current task, thereby obtaining feature maps that meet the objectives of the current defect detection task. The feature adapter in this invention uses a deformable adaptive patchify network (DAPN) to improve the fixed-step segmentation method of the original GLASS network. It also uses a multi-scale dynamic attention fusion network (MDAFN) to perform channel-aligned projection on the multi-scale feature maps output by the feature extractor, generating spatially adaptive dynamic attention weights to achieve weighted fusion of the multi-scale features.

[0088] Specifically, since the original GLASS network uses fixed-step cutting, the cutting position lacks flexibility. For tiny defects across blocks, this cutting method will cause the defect features to be forcibly split, and the model cannot capture the defect morphology. Therefore, in order to capture defects as much as possible, a deformable adaptive cutting network is introduced into the feature adapter. This network includes a dynamic offset learning mechanism and an adaptive patch positioning mechanism. Among them, dynamic offset learning refers to the introduction of a learnable offset to the position of each cutting block, allowing the network to dynamically adjust the sampling grid during training, so that the cutting block can avoid the defect boundary or completely wrap the defect area. The adaptive cutting position optimization mechanism enables the coverage of each cutting block to be adaptively adjusted according to the input content, avoiding rigid cutting with a fixed step size.

[0089] The Multi-scale Dynamic Attention Fusion Network (MDAFN) includes a channel-aligned projection (CAP) and dynamic attention weight generation mechanism. CAP projects the high-level features of the input feature map into a low-dimensional space while ensuring that the projected high-level features retain their high-dimensional semantic information. This concatenation of the high-level projected features, which carry high-dimensional semantic information, with the low-level features prevents the spatial dimensionality explosion caused by direct concatenation of high- and low-level features. The dynamic attention weight generation mechanism first inputs the concatenated features into a lightweight convolutional network, then performs a split operation to generate dynamic attention weights. This achieves the effect of dynamically allocating weights between high- and low-level features based on the complexity of local features (such as texture mutations and defect edges). The resulting dynamic attention weights are then element-wise multiplied by the high- and low-level features to generate fused features.

[0090] The discriminator is used to detect anomalies and locate defects in features. During network training, the discriminator receives the dynamically fused feature map output by the feature adapter and outputs anomaly probabilities to achieve accurate defect identification.

[0091] In this embodiment, the defect area is dynamically wrapped by the learnable offset in the deformable adaptive cutting network to solve the problem of cross-block defect breakage during feature map cutting. The offset of the cutting block in the edge area of the image is constrained, the sampling of invalid filling areas is reduced, and edge noise is eliminated. The multi-scale dynamic attention fusion network mechanism compresses high-level features to the same dimension as the low-level features, avoiding feature dimension explosion, which can improve the accuracy of character inkjet coding detection.

[0092] In one embodiment, the feature adapter in S202, when dynamically dividing the multi-scale feature map into blocks, specifically includes the following steps:

[0093] A learnable offset is introduced for the position of each cut block, allowing the network to dynamically adjust the sampling grid. The learnable cut block offset formula is:

[0094]

[0095] in, is the learnable cut block offset, is the convolution operation, is the convolution kernel, is the hyperbolic tangent activation function, A scaling factor that controls the magnitude of the offset.

[0096] It can be understood that the original GLASS network uses a fixed step size to cut, dividing the multi-scale feature map output by the feature extractor into a uniform grid. The sampling position of each cut block is determined by the preset step size and padding. For small defects across blocks (such as broken wire defects across the boundaries of two blocks), the cutting operation will forcibly cut off the defect features, resulting in the model being unable to fully capture the defect morphology. Therefore, in the dynamic block cutting process in the deformable adaptive cutting network, a learnable offset is introduced to the position of each cut block. .

[0097] Specifically, the input image is generated by the feature extractor to generate the initial multi-scale feature map. During initialization, the cutting blocks are divided according to a fixed step size to form a uniform grid. The size of each cutting block is For each cut block, for the feature Perform convolution. Apply the hyperbolic tangent activation function to the output value after convolution, constrain the value to the interval [-1, 1], and then compare the above result with Multiply, is a scaling factor for controlling the offset amplitude. , which increases the offset range to [-1.5, 1.5] pixels to avoid excessive deformation of the sampling grid and resulting in feature distortion. During network training, this offset can be adaptively adjusted through learning.

[0098] Learnable offset The coverage of each cut block is also adaptively adjusted according to the input content to avoid rigid cutting with fixed step lengths. Specifically:

[0099]

[0100] in, For the Block original cutting block, For the The offset of the original cut block of the block, Generate, ensuring that adjacent blocks still maintain overlapping coverage after offset, eliminating cutting gaps.

[0101] As you can understand, in the above formula, the coverage area is equal to the union of all the cut blocks plus the offset. After adjusting the position of each block by the learnable offset, the coverage area still maintains the overlap between blocks.

[0102] Through the method of this embodiment, the cutting block offset learns the image content through convolution, so that the cutting block can avoid the defect boundary or completely wrap the defect area. For example, when there is a broken line defect across the block in the inkjet coding, the cutting position is adjusted to completely capture the defect, and it is more adaptable to the extreme aspect ratio of the long strip inkjet coding area.

[0103] In another exemplary embodiment, the step of constraining the offset of the cutting block in the edge area of the image by the deformable adaptive cutting network further includes:

[0104]

[0105] in, is the offset direction and amplitude of the cut block in the edge area of the image, is the normalized distance from the current cut block to the edge area of the image.

[0106] In the original GLASS network, a fixed padding strategy (Zero-Padding) was used to maintain consistency in output size. This strategy results in asymmetric padding in the coded image, especially in long strips of input images. That is, the horizontal padding is much greater than the vertical padding, which introduces unnatural edge features in the edge areas.

[0107] The above formula can automatically converge the offset of the cutting block in the edge area to the negative direction, thereby avoiding the edge filling area of the inkjet image, such as invalid background and zero-padding noise, reducing the dependence on the filling area, and improving the accuracy of edge area defect detection.

[0108] In a specific embodiment, the deformable adaptive cutting network of the feature adapter simultaneously uses the learnable offset in the above embodiment to divide the feature map and imposes cutting block constraints on the edge area of the image, such as Figure 3 As shown, the following steps S301 to S303 are included:

[0109] S301, introducing a learnable offset for the position of each cut block.

[0110] S302: Dynamically divide and cut the multi-scale feature map output by the feature extractor into blocks.

[0111] S303: constraining the offset of the cutout blocks in the edge area of the image.

[0112] The specific implementation details can be combined with reference to the above embodiments and will not be described in detail in this embodiment.

[0113] Figure 4This is a visualization of the cutting results of the deformable adaptive cutting network in this embodiment and the fixed cutting method in the original GLASS network, specifically showing a fixed sliding window moving one pixel at a time on the image. The first row of the picture shows the original character image, the second row is the feature map generated by the cutting strategy of the original GLASS network, and the third row is the cutting block with the introduction of a learnable offset. It can be seen that through dynamic offset learning and adaptive position cutting optimization, each cutting block can not only maintain the characteristics of the character when crossing blocks, but also converge toward the center of the character edge, avoiding sampling in invalid edge areas.

[0114] In some embodiments, as Figure 5 As shown in Figure 2, channel alignment projection of multi-scale feature maps specifically includes the following:

[0115] S501, high-level features of the multi-scale feature map Project to low-dimensional space to generate high-level projection features ,in is the batch size, is the number of channels of low-level features, H is the height of the feature map, and W is the width of the feature map.

[0116] In the original GLASS network, after the feature extractor extracts multi-scale feature maps, it uses simple channel-wise concatenation to combine low-level and high-level features. However, directly concatenating low-dimensional and high-dimensional features can lead to a dimensional explosion in the feature space. For example, if low-level features are 512-dimensional and focus on texture details, while high-level features are 1024-dimensional and carry semantic information, the dimensionality will increase to 1536 after direct concatenation. This makes it difficult for the model to effectively mine cross-scale correlation features, and the semantic information of high-level features is "swamped" by low-level details, making it difficult for the discriminator to capture semantic defects such as broken lines and blurry features.

[0117] Specifically, in this embodiment, high-level features are projected into a low-dimensional space through 1x1 convolution to eliminate the dimensionality differences of heterogeneous features, which can be expressed as:

[0118]

[0119] It is a 1x1 convolution operation. By lightweight 1x1 convolution, the number of channels of high-level features is compressed to be consistent with that of low-level features, which facilitates subsequent cross-scale feature splicing and fusion.

[0120] S502, constraining the high-level projection features through the cosine similarity loss function and the high-level features The consistency of , its objective function is:

[0121]

[0122] in, is global average pooling.

[0123] It's important to note that Global Average Pooling (GAP) is a commonly used feature aggregation method that reduces the length and width of the data by averaging each channel of each feature map. Cosine similarity evaluates the similarity between two feature vectors by calculating the cosine of the angle between them. Therefore, the higher the feature vector similarity, the closer the cosine value approaches 1, and the closer the objective function, the cosine similarity loss function, approaches 0.

[0124] In the above formula, high-level projected features and high-level features are first subjected to global average pooling to compress the feature map into a global feature vector with a length and width of 1. Then, the cosine similarity constraint is used to make the cosine similarity loss of the high-level projected features and high-level features obtained by global average pooling approach 0.

[0125] In this embodiment, the channel alignment projection technology minimizes the objective function , forcing high-level projection features The global semantic vector of As similar as possible to avoid loss of original semantic information due to dimensionality compression.

[0126] In an exemplary embodiment, Figure 6 As shown, generating spatially adaptive dynamic attention weights to achieve weighted fusion of the multi-scale features includes the following steps S601 to S603:

[0127] S601, high-level projection features With low-level features Splicing to form splicing features .

[0128] Low-level features High-level projection features After direct splicing, generate splicing features , is the number of channels after compression. In this step, the concatenated features can fuse cross-scale information and provide a global perspective for the next step of weight generation.

[0129] S602, the splicing feature The kernel performs a lightweight convolution operation and projects it into a new space to generate a two-dimensional attention weight. The formula is:

[0130]

[0131] in, is the low-level feature weight, is the high-level feature weight, , Split is the channel splitting operation, ReLu is the ReLu activation function, and Softmax is the Softmax activation function.

[0132] For example, in this embodiment, the two-layer convolutional network is 1 1 convolution. It is understandable that 1 1. The essence of convolution is to perform a linear combination of the channels of the input feature map. It can integrate the number of channels to the same number as the convolution kernel while keeping the length and height of the input feature map unchanged, so as to achieve the effect of integrating information from different channels while keeping the spatial dimension compressed, thereby greatly reducing the amount of calculation.

[0133] The splicing features are passed through two layers 1 1. Split operation is performed after convolution network, which splits the two channel output into independent and , the dimensions are .

[0134] S603, low-level features With the high-level features Fusion. The formula is:

[0135]

[0136] in, Budget for element-wise multiplication, is the weighted fusion feature.

[0137] Figure 7 The network structure of the multi-scale dynamic attention fusion network in the above embodiment is shown. Through the above formula, the spatial alignment of weights and features is achieved, and weights are dynamically allocated according to the complexity of local area features (such as texture mutations and defect edges). If there are defects in areas with rich details, such as broken lines on the edges of characters, then Weight enhancement to enhance low-level features If the semantics of the local area is clear, but there is a large area of pollution and the character is blurred as a whole, then The weight is increased, thereby enhancing high-level features Response.

[0138] In another embodiment, in a multi-scale dynamic attention fusion network, suppressing noise interference specifically includes:

[0139] Use 1×1 convolution to weight the fusion features Projecting to the new vector space, we get ;

[0140] Before normalization, weighted fusion features are first performed through 1×1 convolution Perform pre-operation:

[0141]

[0142] Further adjust the feature dimension and compress the number of channels.

[0143] Instance normalization is used to eliminate statistical deviations within batches. The formula is:

[0144]

[0145] in, To calculate the instance mean of the channel, To calculate the instance variance of the channel, is a learnable scaling factor, is the learnable offset.

[0146] As you can understand, instance normalization independently calculates the mean and variance for each channel of a single sample, aiming to eliminate statistical bias across spatial locations. Unlike batch normalization, commonly used in deep convolutional neural networks, instance normalization does not rely on batch statistics but is calculated solely based on the local features of a single sample. This avoids the drawbacks of batch normalization, such as large statistical fluctuations and the susceptibility to noise in small batches.

[0147] Through the instance-normalized noise interference method, the model can effectively eliminate the noise impact on image data caused by dynamic lighting interference, sensor noise, etc. in industrial scenes, while retaining subtle feature differences related to defects, and achieve accurate detection of low-contrast defects such as slight smears and blurs in inkjet characters.

[0148] In an exemplary embodiment, Figure 8 The spatial dynamic perception discriminator shown uses depthwise separable convolution and dilated convolution to obtain local and global context features, including the following steps S801 to S803:

[0149] S801, the feature map output by the feature adapter Restore to original spatial arrangement characteristics , where b is the batch size, c is the number of channels of the low-level features, and w is the width of the feature map. .

[0150] It can be described specifically as the following formula:

[0151]

[0152] By restoring the spatial adjacency between blocks, it provides a structural basis for subsequent convolution operations.

[0153] S802, obtain original spatial arrangement features through depth-wise separable convolution Local features :

[0154]

[0155] in, is the depthwise convolution operation, is the depth convolution kernel, is the bias term.

[0156] Specifically, the depth convolution kernel refers to the use of a single-channel convolution kernel for each channel independently. In this embodiment, The size of is exemplarily chosen to be The parameter quantity of the comparison standard is The convolution kernel of the depth-separable convolution has only , reduced times.

[0157] S803, using dilated convolution to expand the receptive field and extract local features Global characteristics of :

[0158]

[0159] in, is the dilated convolution operation, is the dilated convolution kernel.

[0160] Dilated convolution is a special convolution operation that introduces a "hole" (interval) into the traditional convolution kernel. It adjusts the receptive field size by controlling the dilation rate without increasing the number of parameters. In this embodiment, the dilated convolution kernel is , the void ratio is 2, so Convolution kernel equivalent coverage The global features of the output Capturing long-range dependencies.

[0161] For the nonlinear distortion areas of cylindrical inkjet printing, dilated convolution can effectively model the global structure of curved characters, avoiding the missed defects caused by insufficient receptive field of traditional local convolution.

[0162] Through the lightweight spatial context modeling method in this embodiment, the model's joint perception capability of local details and global structures in inkjet characters is significantly enhanced while maintaining low computational cost.

[0163] In an exemplary embodiment, Figure 9 As shown, the local features are concatenated with the global features to generate spatially sensitive features, and the threshold is dynamically adjusted through a lightweight fully connected layer, including the following steps S901 to S903:

[0164] S901, local features and global features Perform splicing and fusion to generate spatially sensitive fusion features :

[0165]

[0166] Specifically, in this embodiment It is a local context feature extracted by depth-wise separable convolution, capturing texture details within a 3×3 neighborhood, such as character edge gradients. This is a global feature extracted through a dilated convolution with a dilation ratio of 2, capturing structural information within a 5×5 region, such as the overall shape of a character. Spatially sensitive fusion features contain multi-scale contextual composite features.

[0167] S902: Generate an adaptive threshold through a lightweight fully connected layer. The formula is:

[0168]

[0169] in, is the weight matrix of the lightweight fully connected layer, is the global feature dimension, is the bias term of the lightweight fully connected layer.

[0170] The spatially sensitive fusion features are processed through a fully connected layer to achieve a nonlinear mapping from feature complexity to threshold. A high threshold is output in the defect area to enhance the response, and a low threshold is output in the normal area to suppress noise.

[0171] S903, arrange the original space features With adaptive threshold Multiply the channels element by element to get the final discriminant score:

[0172]

[0173] in, is the weight matrix of the final discriminant layer, is the bias term of the final discriminant layer.

[0174] Adaptive Threshold Arrange features with the original space Element-by-element multiplication is performed to achieve a bidirectional adjustment effect by enhancing the response of the defect area and suppressing the background noise. The multiplication result is used as the modulated feature and is mapped to the pixel-level abnormality probability of each pixel point between 0 and 1 through a fully connected layer.

[0175] In this embodiment, the detection results on the same test set in the character inkjet coding dataset are shown in Table 1, where AUC is the prediction accuracy. The improved GLASS network inkjet coding character detection method has an accuracy improvement of 2.1% compared with the traditional GLASS network.

[0176] Table 1

[0177]

[0178] Figure 10 Comparison charts of the defect detection performance of the improved GLASS network and the original GLASS network on the same test set. The first image in each sub-image shows the original image data of the coded characters, and the second image shows the defect localization map generated after the defect detection method. The red and green markers in the defect localization map indicate the locations of the defects. In comparison image (a), the original GLASS network can only detect the defects on the right side and fails to detect the minor defects in the first line of text. The improved GLASS network of the present invention eliminates the problems originally caused by the average pooling operation, allowing such minor defects to be accurately detected. In the second row, because the discriminator of the original GLASS network consists of only a few simple linear layers, it can mistakenly detect some images without defects as defective images. The method of this embodiment enriches the discriminator of the GLASS network, reducing the original network's error rate. In the third row, when the defect is at the edge, the original GLASS network cannot accurately detect it. This is because the GLASS network uses a fixed tiling method and fills in the feature edges, which introduces irrelevant information and makes the network's defect detection ability insufficient at the edge. The present invention solves this problem by introducing dynamic offset learning tiling.

[0179] Based on the same inventive concept, the embodiments of the present application also provide a device for detecting defects in inkjet characters based on an improved GLASS network, which is used to implement the aforementioned method for detecting defects in inkjet characters based on an improved GLASS network. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of one or more embodiments of the device for detecting defects in inkjet characters based on an improved GLASS network provided below can be found in the limitations of the method for detecting defects in inkjet characters based on an improved GLASS network described above, and will not be repeated here.

[0180] In an exemplary embodiment, Figure 11As shown, a device 1100 for detecting defects in inkjet characters based on an improved GLASS network is provided, comprising: an image acquisition module and a defect detection module, wherein:

[0181] Image acquisition module 1101, used to obtain image data of the coding area;

[0182] Defect detection module 1102, used for inputting the image data into the improved GLASS network to detect and locate defects in the inkjet characters;

[0183] Wherein, the improved GLASS network includes:

[0184] A feature extractor, configured to extract multi-scale image features from the image data to obtain a multi-scale feature map;

[0185] A feature adapter comprising a deformable adaptive cutting network and a multi-scale dynamic attention fusion network, wherein the deformable adaptive cutting network is used to dynamically adjust the feature cutting position through a learnable offset and dynamically block-cut the multi-scale feature map; the multi-scale dynamic attention fusion network is used to perform channel-aligned projection on the multi-scale feature map, generate spatially adaptive dynamic attention weights, and realize weighted fusion of the multi-scale features;

[0186] The discriminator is used to discriminate the output result of the feature adapter and output defect detection and positioning.

[0187] Each module in the improved GLASS network-based inkjet character defect detection device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0188] Those skilled in the art will understand that Figure 11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0189] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), quantum computing-based data processing logic devices, artificial intelligence (AI) processors, and the like.

[0190] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0191] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A method for detecting defects in inkjet characters based on an improved GLASS network, characterized in that: The method comprises: Obtain image data of the coding area; Inputting the image data into the improved GLASS network to detect and locate defects in inkjet characters; Wherein, the improved GLASS network includes: A feature extractor, configured to extract multi-scale image features from the image data to obtain a multi-scale feature map; A feature adapter comprising a deformable adaptive cutting network and a multi-scale dynamic attention fusion network, wherein the deformable adaptive cutting network is used to dynamically adjust the feature cutting position through a learnable offset and dynamically block-cut the multi-scale feature map; the multi-scale dynamic attention fusion network is used to perform channel-aligned projection on the multi-scale feature map, generate spatially adaptive dynamic attention weights, and realize weighted fusion of the multi-scale features; The discriminator is used to discriminate the output result of the feature adapter and output defect detection and positioning.

2. The method according to claim 1, characterized in that The dynamically dividing and cutting the multi-scale feature map into blocks includes: The learnable cut block offset formula is: ; in, is the learnable cut block offset, is the convolution operation, is the convolution kernel, is the hyperbolic tangent activation function, A scaling factor that controls the magnitude of the offset.

3. The method according to claim 2, characterized in that The deformable adaptive cutting network also constrains the offset of the cutting block in the edge area of the image by the following formula: ; in, is the offset direction and amplitude of the cut block in the edge area of the image, is the normalized distance from the current cut block to the edge area of the image.

4. The method according to claim 1, wherein The performing channel alignment projection on the multi-scale feature map includes: The high-level features of the multi-scale feature map Project to low-dimensional space to generate high-level projection features ,in is the batch size, is the number of channels of the low-level feature, H is the height of the high-level projection feature, and W is the width of the high-level projection feature map; By using the cosine similarity loss function, the high-level projection features are constrained and the high-level features The consistency of , its objective function is: ; in, is global average pooling.

5. The method according to claim 1, wherein Generating spatially adaptive dynamic attention weights to achieve weighted fusion of the multi-scale features includes: Projecting features on high levels With low-level features Splicing to form splicing features ; The splicing feature The kernel performs a lightweight convolution operation and projects it into a new space to generate a two-dimensional attention weight: ; in, is the low-level feature weight, is the high-level feature weight, , Split is the channel splitting operation, and Softmax is the normalization operation; The low-level features With the high-level features Fusion, the formula is: ; in, is the element-wise multiplication operation, is the weighted fusion feature.

6. The method according to claim 1, characterized in that The multi-scale dynamic attention fusion network suppresses noise interference in the following way: Use 1×1 convolution to weight the fusion features Projecting to the new vector space, we get ; Instance normalization is used to eliminate statistical deviations within batches. The formula is: ; in, To calculate the instance mean of the channel, To calculate the instance variance of the channel, is a learnable scaling factor, is the learnable offset.

7. The method according to claim 1, characterized in that The discriminator is a spatial dynamic perception discriminator, comprising: Use depth-wise separable convolution and dilated convolution to obtain local and global features; The local features are concatenated with the global features to generate spatially sensitive features, and the threshold is dynamically adjusted through a lightweight fully connected layer to adjust the sensitivity of defect detection.

8. The method according to claim 7, characterized in that The use of depth-wise separable convolution and dilated convolution to obtain local and global context features includes: The feature map output by the feature adapter Restore to original spatial arrangement characteristics , where b is the batch size, c is the number of channels, and w is the width of the original spatial arrangement feature. ; The original spatial arrangement features are obtained through depth-wise separable convolution Local features : ; in, is the depthwise convolution operation, is the depth convolution kernel, is the bias term; Use dilated convolution to expand the receptive field and extract the local features Global characteristics of : ; in, is the dilated convolution operation, is the dilated convolution kernel.

9. The method according to claim 7, characterized in that The step of concatenating the local features with the global features to generate spatially sensitive features and dynamically adjusting the threshold value through a lightweight fully connected layer includes: For the local features and the global features Perform splicing and fusion to generate spatially sensitive fusion features : ; The adaptive threshold is generated by a lightweight fully connected layer, and its formula is: ; in, is the weight matrix of the lightweight fully connected layer, is the global feature dimension, is the bias term of the lightweight fully connected layer; Arrange features in the original space With the adaptive threshold Multiply the channels element by element to get the final discriminant score: ; in, is the weight matrix of the final discriminant layer, is the bias term of the final discriminant layer.

10. A device for detecting defects in inkjet characters based on an improved GLASS network, characterized in that: The device comprises: Image acquisition module, used to obtain image data of the coding area; A defect detection module, used for inputting the image data into the improved GLASS network to detect and locate defects in the inkjet characters; Wherein, the improved GLASS network includes: A feature extractor, configured to extract multi-scale image features from the image data to obtain a multi-scale feature map; A feature adapter comprising a deformable adaptive cutting network and a multi-scale dynamic attention fusion network, wherein the deformable adaptive cutting network is used to dynamically adjust the feature cutting position through a learnable offset and dynamically block-cut the multi-scale feature map; the multi-scale dynamic attention fusion network is used to perform channel-aligned projection on the multi-scale feature map, generate spatially adaptive dynamic attention weights, and realize weighted fusion of the multi-scale features; The discriminator is used to discriminate the output result of the feature adapter and output defect detection and positioning.

Citation Information

Patent Citations

  • Image retrieval method based on heterogeneous bilinear attention network

    CN110532409A

  • Segmented region target counting device, method and system based on rapid instance segmentation

    CN116306765A

  • Medical image segmentation method and system

    CN118799335A

  • Efficient segmentation of tumours from lung ct

    US20250061682A1

  • Laser cutting head for a machine tool

    WO2021156788A1