A method and apparatus for detecting defects in inkjet printed characters based on an improved GLASS network

By improving the deformable adaptive cutting and multi-scale dynamic attention fusion technology of the GLASS network, the problems of feature breakage and dimensional explosion in inkjet character detection are solved, and higher precision defect detection is achieved.

CN120496079BActive Publication Date: 2025-10-28HANGZHOU QOGORI TECH
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing inkjet character detection methods suffer from feature breakage during cross-block defect detection, noise introduced by edge filling, and dimensional explosion caused by multi-scale feature fusion, making it difficult to meet the lightweight deployment requirements of industrial equipment.

Method used

We employ a deformable adaptive cutting network and a multi-scale dynamic attention fusion network. By dynamically adjusting the feature cutting position through learnable offsets, we generate spatially adaptive dynamic attention weights to achieve multi-scale feature weighted fusion. We also use depthwise separable convolution and dilated convolution to extract local and global features and generate spatially sensitive features.

Benefits of technology

It effectively solves the problem of cross-block defect breakage during feature map cutting, reduces edge noise, avoids feature dimension explosion, and improves the accuracy and precision of inkjet character defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120496079B_ABST
    Figure CN120496079B_ABST
Patent Text Reader

Abstract

This application relates to a method and apparatus for detecting defects in inkjet-printed characters based on an improved GLASS network. The method includes: acquiring image data of the inkjet-printed area; inputting the image data into an improved GLASS network for detecting and locating defects in the inkjet-printed characters; wherein the improved GLASS network includes: a feature extractor for extracting multi-scale feature maps from the image data; a feature adapter including a deformable adaptive segmentation network for dynamically segmenting the multi-scale feature maps into blocks, and a multi-scale dynamic attention fusion network for weighted fusion of the multi-scale features; and a discriminator for discriminating the output of the feature adapter and outputting the defect detection and location. This method can improve the detection accuracy of inkjet-printed characters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of industrial vision inspection, and in particular to a method and apparatus for detecting defects in inkjet characters based on an improved GLASS network. Background Technology

[0002] With the large-scale development of the new energy industry, the detection of defects in inkjet-printed characters during the production of batteries and electronic components, such as minor code defects, broken lines, blurring, and broken sleeves, has become a critical aspect of quality control. These inkjet-printed character defects typically exhibit characteristics such as sub-millimeter scale, high requirements for cross-regional continuity, and complex distortion in curved surface imaging. Existing technologies, such as GLASS networks, combine multi-branch feature processing with a discriminator to achieve anomaly detection in inkjet-printed images.

[0003] However, the above methods have the following drawbacks in practical applications of inkjet character detection: First, the fixed-step cutting mechanism used for feature maps leads to the fragmentation of cross-block defect features, and noise introduced by edge padding further contaminates the feature representation; second, the multi-scale feature fusion adopts a static weight strategy, resulting in poor coupling between low-level details and high-level semantics, and direct splicing leads to feature dimension explosion, with high-frequency details being severely attenuated during fusion. These drawbacks make it difficult for existing inkjet character defect detection methods to meet the lightweight deployment requirements of industrial equipment. Therefore, a method that can improve the detection accuracy of inkjet character defects is needed. Summary of the Invention

[0004] To address the above issues, this application provides a method and apparatus for detecting defects in inkjet characters based on an improved GLASS network.

[0005] Firstly, this application provides a method for detecting defects in inkjet-printed characters based on an improved GLASS network, including:

[0006] Acquire image data of the inkjet printing area;

[0007] The image data is input into an improved GLASS network for inkjet character defect detection and localization.

[0008] The improved GLASS network includes:

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

[0010] The feature adapter 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 to dynamically segment 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 to generate spatially adaptive dynamic attention weights, thereby realizing weighted fusion of the multi-scale features.

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

[0012] In one embodiment, the multi-scale feature map is dynamically segmented into blocks, including:

[0013] The formula for the learnable cutting block offset is:

[0014]

[0015] in, The learnable cutting block offset. For convolution operations, For convolution kernel, The hyperbolic tangent activation function is used. This is a scaling factor to control the offset magnitude.

[0016] In one embodiment, the deformable adaptive cutting network further constrains the offset of the cutting blocks in the image edge region using the following formula:

[0017]

[0018] in, The offset direction and magnitude of the cut-off blocks in the image edge region. This is the normalized distance from the current cut block to the image edge region.

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

[0020] High-level features of the multi-scale feature map Projecting to a lower-dimensional space to generate higher-level projection features ,in For batch size, H is the number of channels for 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] The high-rise projection features are constrained using a cosine similarity loss function. and the aforementioned high-level features The consistency of the objective function is:

[0022]

[0023] in, This 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] High-rise projection characteristics With low-level features splicing, forming splicing features ;

[0026] The splicing feature The kernel performs lightweight convolution operations and projects onto a new space, generating two-dimensional attention weights:

[0027]

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

[0029] The low-level features With the aforementioned high-level features The fusion formula is:

[0030]

[0031] in, For element-wise multiplication budget, This is a weighted fusion feature.

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

[0033] The weighted fused features are processed using 1×1 convolutions. Projecting onto the new vector space, we obtain ;

[0034] Instance normalization is used to eliminate within-batch statistical bias, and the formula is as follows:

[0035]

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

[0037] In one embodiment, the discriminator is a spatial dynamic perception discriminator, including:

[0038] Using depthwise separable convolution and dilated convolution, local and global features are obtained;

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

[0040] In one embodiment, depthwise separable convolution and dilated convolution are used to obtain local and global context features, including:

[0041] The feature map output by the feature adapter Restored to the original spatial arrangement features 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 depthwise separable convolution. Local features :

[0043]

[0044] in, For depthwise convolution operations, For depthwise convolution kernels, For bias terms;

[0045] The receptive field is expanded using dilated convolution to extract the local features. global features :

[0046]

[0047] in, For dilated convolution operations, It is a hollow convolution kernel.

[0048] In one embodiment, 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:

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

[0050]

[0051] An adaptive threshold is generated using a lightweight fully connected layer, and the formula is as follows:

[0052]

[0053] in, This is the weight matrix of the lightweight fully connected layer. For global feature dimensions, This refers to the bias term of the lightweight fully connected layer;

[0054] Original spatial arrangement features With the adaptive threshold Element-by-element multiplication and channel multiplication yield the final discrimination score:

[0055]

[0056] in, This is the weight matrix for the final discriminant layer. This is the bias term for the final discrimination layer.

[0057] Secondly, this application also provides a defect detection device for inkjet characters based on an improved GLASS network, comprising:

[0058] The image acquisition module is used to acquire image data of the inkjet printing area;

[0059] The defect detection module is used to input the image data into an improved GLASS network for the detection and localization of defects in the inkjet characters.

[0060] The improved GLASS network includes:

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

[0062] The feature adapter 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 to dynamically segment 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 to generate spatially adaptive dynamic attention weights, thereby realizing weighted fusion of the multi-scale features.

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

[0064] The aforementioned inkjet character defect detection method and apparatus based on the improved GLASS network solves the problem of cross-block defect breakage during feature map cutting by dynamically wrapping the defect region with learnable offsets in the deformable adaptive cutting network. It constrains the cutting block offsets of the image edge region, reduces sampling of invalid filling areas, and eliminates edge noise. The multi-scale dynamic attention fusion network effectively improves the accuracy of inkjet character defect detection by compressing high-level features to the same dimension as low-level features, avoiding feature dimension explosion. Attached Figure Description

[0065] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0066] Figure 1 This is an application environment diagram of the inkjet character defect detection method in one embodiment;

[0067] Figure 2 This is a flowchart of a method for detecting defects in inkjet-printed characters in one embodiment;

[0068] Figure 3 A flowchart of a deformable adaptive cutting network in one embodiment;

[0069] Figure 4 This is a comparison of the visualization effects of the cutting blocks in one embodiment;

[0070] Figure 5 This is a flowchart of channel alignment projection in one embodiment;

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

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

[0073] Figure 8 This is a flowchart illustrating the acquisition of local and global context features in one embodiment;

[0074] Figure 9 This is a flowchart illustrating the dynamic adjustment of a threshold using a lightweight fully connected layer in one embodiment.

[0075] Figure 10 This is a comparison chart of defect detection results in one embodiment;

[0076] Figure 11This is a structural block diagram of a defect detection device in one embodiment. Detailed Implementation

[0077] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0078] The inkjet character defect detection method based on an improved GLASS network provided in this application can be applied to, for example... Figure 1 The application environment is shown. Terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed in the cloud or on other network servers. Terminal 102 includes a data acquisition unit, including but not limited to industrial cameras, smart sensors, embedded inspection devices, etc., to acquire real-time images of the battery surface markings. Terminal 102 can be, but is not limited to, various computers, laptops, smartphones, tablets, and IoT devices. Server 104, as the core processing unit, can be deployed as a standalone physical server, a distributed cluster, or a cloud server for improving GLASS network model training, parameter optimization, and defect detection tasks. The data storage system can be integrated onto server 104 or deployed as a cloud database to store training samples, historical detection results, and model parameters.

[0079] In one exemplary embodiment, a method for detecting defects in inkjet-printed characters based on an improved GLASS network is provided, which can be applied to... Figure 1 The computer equipment in the description is as follows: Figure 2 As shown, the procedure includes the following steps S201 to S202:

[0080] S201, acquire image data of the inkjet printing area.

[0081] Specifically, a data acquisition system, including intelligent terminal devices such as industrial cameras, is used to acquire raw image data containing the inkjet-printed characters. To improve the accuracy of defect identification, the raw image data should contain as complete the inkjet-printed characters as possible. If the image contains too many edge areas, the character area can be identified and cropped out.

[0082] During the training and evaluation phases of the network, 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. Abnormalities include minor defects such as splintering, broken lines, blurring, and misalignment. The training set is used to train the improved GLASS network, and the test set is used to evaluate the trained network.

[0083] S202, the image data is input into an improved GLASS network for inkjet character defect detection and localization.

[0084] The improved GLASS network includes: a feature extractor for extracting multi-scale image features from the image data to obtain a multi-scale feature map; a feature adapter including 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 to dynamically segment 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 to generate spatially adaptive dynamic attention weights, thereby achieving weighted fusion of the multi-scale features; and a discriminator for judging the output of the feature adapter and outputting defect detection and localization.

[0085] It should be noted that the GLASS network is an unsupervised anomaly detection network based on anomaly synthesis. Its core framework includes a normal branch, a global anomaly synthesis branch (GAS), and a local anomaly synthesis branch (LAS): The GAS branch synthesizes near-normally distributed anomaly features in the feature space through gradient-guided Gaussian noise and truncated projection, enhancing the detection capability for weak defects; the LAS branch generates diverse anomalies at the image level through texture overlay, improving the anomaly coverage. The three branches share a feature extractor and feature adapter, and the multi-branch defect detection network is jointly trained end-to-end through a discriminator.

[0086] This invention improves the feature extractor in the GLASS network by using 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, enabling it to extract rich image features and obtain multi-scale feature maps of the original image data.

[0087] Since feature extractors are typically pre-trained under different data distributions, their output multi-scale feature maps may not be perfectly suitable for character defect detection tasks. 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 conform to the current defect detection task objectives. 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, and 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, because the original GLASS network uses a fixed step size for cutting, the cutting position lacks flexibility. For small defects spanning multiple blocks, this cutting method forcibly severs the defect features, preventing the model from capturing the defect morphology. Therefore, 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. Dynamic offset learning introduces a learnable offset to the position of each cut block, allowing the network to dynamically adjust the sampling grid during training, enabling the cut blocks to avoid defect boundaries or completely cover the defect area. The adaptive patch positioning mechanism allows the coverage of each cut block to adaptively adjust according to the input content, avoiding rigid cutting with a fixed step size.

[0089] The Multi-scale Dynamic Attention Fusion Network (MDAFN) includes Channel-Aligned Projection and Dynamic Attention Weights mechanisms. Channel-Aligned Projection projects high-level features from the input feature map into a low-dimensional space, ensuring that the projected high-level features retain their high-dimensional semantic information. This high-level projected features, carrying high-dimensional semantic features, are then concatenated with the low-level features, preventing spatial dimensionality explosion caused by direct concatenation. The Dynamic Attention Weights mechanism first inputs the concatenated features into a lightweight convolutional network, then performs a Split operation to obtain dynamic attention weights. This dynamically allocates weights between high-dimensional and low-level features based on the complexity of local region features (such as texture abrupt changes or defect edges). Finally, the obtained dynamic attention weights are multiplied element-wise by both the high-level and low-level features to obtain the fused features.

[0090] The discriminator is used for anomaly detection and defect localization based on features. During network training, the discriminator receives dynamically fused feature maps from the feature adapter, outputs anomaly probabilities, and achieves accurate defect identification.

[0091] In this embodiment, the problem of cross-block defect breakage during feature map cutting is solved by dynamically wrapping the defect region with learnable offsets in the deformable adaptive cutting network. The offset of the cutting block in the image edge region is constrained, the sampling of invalid filling area 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, avoids feature dimension explosion, and can improve the accuracy of character inkjet code detection.

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

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

[0094]

[0095] in, The learnable cutting block offset. For convolution operations, For convolution kernel, The hyperbolic tangent activation function is used. This is a scaling factor to control the offset magnitude.

[0096] It's understandable that the original GLASS network uses a fixed-step cutting method, 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 a preset step size and padding. For small defects that span multiple blocks (such as a broken wire defect crossing two block boundaries), the cutting operation forcibly cuts off the defect features, causing the model to fail to fully capture the defect morphology. Therefore, in the dynamic block cutting process of the deformable adaptive cutting network, a learnable offset is introduced for the position of each cut block. .

[0097] Specifically, the input image is processed by a feature extractor to generate an initial multi-scale feature map. During initialization, the image is first divided into segments with a fixed step size to form a uniform grid. The size of each segment is [missing information]. For each cut block, for the feature Perform convolution. Apply the hyperbolic tangent activation function to the output value after convolution, constraining the value to the interval [-1, 1]. Then compare the above result with... Multiply, A scaling factor to control the offset magnitude. For example, in this embodiment... This indicates that the offset range is expanded to [-1.5, 1.5] pixels to avoid excessive deformation of the sampling grid, which could lead to feature distortion. During network training, this offset can be adaptively adjusted through learning.

[0098] Learnable offset The coverage area of ​​each cut block will also be adaptively adjusted according to the input content to avoid rigid cutting with a fixed step size. Specifically, this is manifested as follows:

[0099]

[0100] in, For the first Original cut blocks, For the first The offset of the original cutting block of the block. Generate blocks that overlap and cover each other after offsetting, eliminating cutting gaps.

[0101] As can be understood, in the above formula, the covered area equals the union of all cut blocks plus their offsets. After adjusting the position of each block using learnable offsets, the covered area still maintains the overlap between blocks.

[0102] The method in this embodiment uses convolution to learn the image content, enabling the cutting block to avoid defect boundaries or completely wrap the defect area. For example, when there is a broken line defect across the block in the inkjet printing, the cutting position is adjusted to completely capture the defect, and it is more adaptable to the extreme aspect ratio of long strip inkjet printing areas.

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

[0104]

[0105] in, The offset direction and magnitude of the cut-off blocks in the image edge region. This is the normalized distance from the current cut block to the image edge region.

[0106] In the original GLASS network, a fixed-padding strategy (Zero-Padding) is used to maintain the consistency of the output size. This strategy leads to asymmetric padding in the inkjet printing image, especially in long strip input images, where the horizontal padding is much larger than the vertical padding, resulting in unnatural edge features in the edge regions.

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

[0108] In one specific embodiment, the deformable adaptive segmentation network of the feature adapter simultaneously uses the learnable offsets from the above embodiments to segment the feature map and imposes segmentation block constraints on image edge regions, such as... Figure 3 As shown, the process includes the following steps S301 to S303:

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

[0110] S302 dynamically segments the multi-scale feature map output by the feature extractor into blocks.

[0111] S303, constraint on the offset of the cutting block in the edge region of the image.

[0112] The specific implementation details can be combined with the above embodiments, and will not be repeated in this embodiment.

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

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

[0115] S501, which integrates high-level features from multi-scale feature maps. Projecting to a lower-dimensional space to generate higher-level projection features ,in For batch size, H represents the number of channels in the low-level features, H represents the height of the feature map, and W represents the width of the feature map.

[0116] In the original GLASS network, after the feature extractor extracts multi-scale feature maps, low-level features are concatenated with high-level features using a simple channel-wise concatenation. However, directly concatenating low-dimensional and high-dimensional features leads to an explosion in the dimensionality of the feature space. For example, if the low-level features are 512-dimensional, focusing on detailed textures, and the high-level features are 1024-dimensional, carrying semantic information, the dimensionality will directly increase to 1536 dimensions after direct concatenation. The model will find it difficult to effectively mine cross-scale correlation features, and the semantic information of the high-level features will be "submerged" by the low-level details, making it difficult for the discriminator to capture defective semantic features such as broken lines and blurriness.

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

[0118]

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

[0120] S502, constrain the high-rise projection features using the cosine similarity loss function. and the aforementioned high-level features The consistency of the objective function is:

[0121]

[0122] in, This 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 dimensionality of data in both length and width by averaging each feature map across each channel. Cosine similarity assesses the similarity between two feature vectors by calculating the cosine of the angle between them. Therefore, the higher the similarity between feature vectors, the closer the cosine value is to 1, and the closer the objective function, i.e., the cosine similarity loss function, is to 0.

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

[0125] In this embodiment, the channel alignment projection technique minimizes the objective function. This forces high-rise projection features global semantic vector and To achieve the greatest possible similarity, avoid the loss of original semantic information due to dimensional compression.

[0126] In one exemplary embodiment, such as 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, Projection characteristics of high-rise buildings With low-level features splicing, forming splicing features .

[0128] Low-level features High-rise projection characteristics After direct splicing, splicing features are generated. , This represents the number of channels after compression. In this step, the splicing features can fuse cross-scale information, providing a global perspective for the next step of weight generation.

[0129] S602, splicing features The kernel performs a lightweight convolution operation and projects it onto a new space, generating two-dimensional attention weights. The formula is:

[0130]

[0131] in, For low-level feature weights, For high-level feature weights, 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. Understandably, 1... 1. The essence of convolution is to linearly combine the channels of the input feature map. It can integrate the number of channels to the same number of channels as the convolution kernel while keeping the length and height of the input feature map unchanged. This achieves the effect of integrating information from different channels while maintaining spatial dimension compression, thereby greatly reducing the amount of computation.

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

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

[0135]

[0136] in, For element-wise multiplication budget, This is a weighted fusion feature.

[0137] Figure 7 The network structure of the multi-scale dynamic attention fusion network in the above embodiments is illustrated. The above formula achieves spatial alignment between weights and features, dynamically allocating weights based on the complexity of local region features (such as texture abrupt changes or defective edges). If defects exist in regions rich in detail, such as broken lines at character edges, then... Weight enhancement, thereby strengthening low-level features The response; if the semantics of a local area are clear, but there is large-scale pollution and the characters are generally blurred, then Increased weights enhance high-level features. The response.

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

[0139] The weighted fused features are processed using 1×1 convolutions. Projecting onto the new vector space, we obtain ;

[0140] Before normalization, the weighted fused features are first processed by 1×1 convolution. Perform the following preliminary operations:

[0141]

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

[0143] Instance normalization is used to eliminate within-batch statistical bias, and the formula is as follows:

[0144]

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

[0146] It is understandable that instance normalization calculates the mean and variance independently for each channel of a single sample, aiming to eliminate statistical biases between spatial locations. Unlike batch normalization commonly used in deep convolutional neural networks, it does not rely on batch statistics but is calculated based solely on the local features of a single sample. This avoids the drawbacks of batch normalization, such as large fluctuations in statistics and the introduction of noise, in small-batch scenarios.

[0147] By using instance normalization for noise interference, the model can effectively eliminate the noise impact on image data caused by dynamic lighting interference and sensor noise in industrial scenarios, while retaining subtle feature differences related to defects, thus achieving accurate detection of low-contrast defects such as slight scratching and blurring in inkjet characters.

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

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

[0150] Specifically, it can be described by the following formula:

[0151]

[0152] By restoring the spatial adjacency relationships between blocks, a structural basis is provided for subsequent convolution operations.

[0153] S802 obtains the original spatial arrangement features through depthwise separable convolution. Local features :

[0154]

[0155] in, For depthwise convolution operations, For depthwise convolution kernels, This is a bias term.

[0156] Specifically, a depthwise convolution kernel refers to a single-channel convolution kernel used independently for each channel. In this embodiment, The size is selected as an example. The number of parameters compared to the standard is... The convolution kernel, the depthwise separable convolution has only a few parameters. Reduced times.

[0157] S803 utilizes dilated convolution to expand the receptive field and extract local features. global features :

[0158]

[0159] in, For dilated convolution operations, It is a hollow convolution kernel.

[0160] Dilated convolution is a special convolution operation that introduces "holes" (spacing) into a traditional convolution kernel. The receptive field size is adjusted by controlling the dilation rate without increasing the number of parameters. In this embodiment, the dilated convolution kernel is... With a void ratio of 2, it makes Convolution kernel equivalent coverage The region. In the output global features. Capture long-range dependencies.

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

[0162] The lightweight spatial context modeling method in this embodiment significantly enhances the model's ability to jointly perceive local details and global structure in inkjet characters while maintaining low computational cost.

[0163] In one exemplary embodiment, such as Figure 9 As shown, 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 the following steps S901 to S903:

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

[0165]

[0166] Specifically, in this embodiment It captures texture details, such as character edge gradients, within a 3×3 neighborhood by extracting local contextual features through depthwise separable convolution. It extracts global features through dilated convolutions with a dilation rate of 2, capturing structural information within a 5×5 region, such as the overall shape of a character. Spatial-sensitive fusion features include multi-scale contextual composite features.

[0167] S902 generates an adaptive threshold through a lightweight fully connected layer, and its formula is as follows:

[0168]

[0169] in, This is the weight matrix for a lightweight fully connected layer. For global feature dimensions, This is the bias term for a lightweight fully connected layer.

[0170] The spatially sensitive fusion features are processed through a fully connected layer to achieve a non-linear mapping from feature complexity to threshold. A high threshold is output in defective regions to enhance the response, while a low threshold is output in normal regions to suppress noise.

[0171] S903, the original spatial arrangement features With adaptive threshold Element-by-element multiplication and channel multiplication yield the final discrimination score:

[0172]

[0173] in, This is the weight matrix for the final discriminant layer. This is the bias term for the final discrimination layer.

[0174] Adaptive threshold Features of the original spatial arrangement Element-wise multiplication achieves a two-way adjustment effect through defect region response enhancement and background noise suppression. The multiplication result serves as the modulated feature, which is then passed through a fully connected layer and mapped to the pixel-level anomaly probability of each pixel's value between 0 and 1.

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

[0176] Table 1

[0177]

[0178] Figure 10 This image compares 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 is the original image data of the spray-printed characters, and the second row is the defect localization map generated after the defect detection method. Red and green markers in the defect localization map indicate the location of the defects. In comparison image (a), the original GLASS network can only detect defects on the right side and fails to detect the minor defects in the first row of text. The improved GLASS network of this invention eliminates the problems caused by the average pooling operation, enabling accurate detection of such minor defects. In the second row, because the discriminator of the original GLASS network consists of only a few simple linear layers, it may misdetect some images without defects as defective images. The method in this embodiment enriches the discriminator of the GLASS network, reducing the false positive rate of the original network. In the third row, when defects are at the edges, the original GLASS network cannot detect them accurately because the GLASS network uses a fixed block method, filling in the feature edges to complete the detection, thus introducing irrelevant information and resulting in insufficient edge defect detection capability. This invention introduces dynamic offset learning blocks to solve this problem.

[0179] Based on the same inventive concept, this application also provides a coding character defect detection device for implementing the above-mentioned coding character defect detection method based on an improved GLASS network. The solution provided by this device is similar to the implementation described in the above method. Therefore, the specific limitations of one or more coding character defect detection device embodiments based on an improved GLASS network provided below can be found in the limitations of the coding character defect detection method based on an improved GLASS network described above, and will not be repeated here.

[0180] In one exemplary embodiment, such as Figure 11As shown, a defect detection device 1100 for inkjet printing 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 is used to acquire image data of the inkjet printing area;

[0182] Defect detection module 1102 is used to input the image data into an improved GLASS network for inkjet character defect detection and localization;

[0183] The improved GLASS network includes:

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

[0185] The feature adapter 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 to dynamically segment 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 to generate spatially adaptive dynamic attention weights, thereby realizing weighted fusion of the multi-scale features.

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

[0187] Each module in the aforementioned inkjet character defect detection device based on the improved GLASS network can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as 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 is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0189] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, 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 many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0190] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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-printed characters based on an improved GLASS network, characterized in that, The method includes: Acquire image data of the inkjet printing area; The image data is input into an improved GLASS network for inkjet character defect detection and localization. The improved GLASS network includes: A feature extractor is used to extract multi-scale image features from the image data to obtain a multi-scale feature map; The feature adapter 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 to dynamically segment 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 to generate spatially adaptive dynamic attention weights, thereby realizing weighted fusion of the multi-scale features. The discriminator is used to discriminate the output results of the feature adapter and output defect detection and location.

2. The method according to claim 1, characterized in that, The dynamic block segmentation of the multi-scale feature map includes: The formula for the learnable cutting block offset is: ; in, The learnable cutting block offset. For convolution operations, For convolution kernel, The hyperbolic tangent activation function is used. This is a scaling factor to control the offset magnitude.

3. The method according to claim 2, characterized in that, The deformable adaptive cutting network also constrains the offset of the cutting blocks in the image edge region using the following formula: ; in, The offset direction and magnitude of the cut-off blocks in the image edge region. This is the normalized distance from the current cut block to the image edge region.

4. The method according to claim 1, characterized in that, The channel-aligned projection of the multi-scale feature map includes: High-level features of the multi-scale feature map Projecting to a lower-dimensional space to generate higher-level projection features ,in For batch size, H is the number of channels for 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. The high-rise projection features are constrained using a cosine similarity loss function. and the aforementioned high-level features The consistency of the objective function is: ; in, This is global average pooling.

5. The method according to claim 1, characterized in that, The dynamically adaptive attention weights in the generation space enable weighted fusion of the multi-scale features, including: High-rise projection characteristics With low-level features splicing, forming splicing features ; The splicing feature The kernel performs lightweight convolution operations and projects onto a new space, generating two-dimensional attention weights: ; in, For low-level feature weights, For high-level feature weights, Split is the channel splitting operation, and Softmax is the normalization operation; The low-level features With the aforementioned high-level features The fusion formula is: ; in, This is an element-wise multiplication operation. This is a 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 ways: The weighted fused features are processed using 1×1 convolutions. Projecting onto the new vector space, we obtain ; Instance normalization is used to eliminate within-batch statistical bias, and the formula is as follows: ; in, To calculate the instance mean of the channel, To calculate the instance variance of the channel, A learnable scaling factor. This is a learnable offset.

7. The method according to claim 1, characterized in that, The discriminator is a spatial dynamic perception discriminator, comprising: Using depthwise separable convolution and dilated convolution, local and global features are obtained; The local features are concatenated with the global features to generate spatially sensitive features. 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 depthwise separable convolution and dilated convolution to obtain local and global context features includes: The feature map output by the feature adapter Restored to the original spatial arrangement features 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 depthwise separable convolution. Local features : ; in, For depthwise convolution operations, For depthwise convolution kernels, For bias terms; The receptive field is expanded using dilated convolution to extract the local features. global features : ; in, For dilated convolution operations, It is a hollow 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 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. : ; An adaptive threshold is generated using a lightweight fully connected layer, and the formula is as follows: ; in, This is the weight matrix of the lightweight fully connected layer. For global feature dimensions, This refers to the bias term of the lightweight fully connected layer; Original spatial arrangement features With the adaptive threshold Element-by-element multiplication and channel multiplication yield the final discrimination score: ; in, This is the weight matrix for the final discriminant layer. This is the bias term for the final discrimination layer.

10. A device for detecting defects in inkjet-printed characters based on an improved GLASS network, characterized in that, The device includes: The image acquisition module is used to acquire image data of the inkjet printing area; The defect detection module is used to input the image data into an improved GLASS network for the detection and localization of defects in the inkjet characters. The improved GLASS network includes: A feature extractor is used to extract multi-scale image features from the image data to obtain a multi-scale feature map; The feature adapter 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 to dynamically segment 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 to generate spatially adaptive dynamic attention weights, thereby realizing weighted fusion of the multi-scale features. The discriminator is used to discriminate the output results of the feature adapter and output defect detection and location.

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