Two-dimensional code anti-counterfeit label authentication method and related device

By constructing and training a multi-scale dilated convolutional model, the problem of QR code authenticity verification in low-quality environments was solved, achieving fast and accurate QR code anti-counterfeiting detection and improving the model's robustness and identification ability.

CN120409512APending Publication Date: 2025-08-01CHONGQING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510479970.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-17
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

Existing technologies struggle to quickly and accurately identify the authenticity of QR codes in low-quality environments. Traditional detection methods are easily cracked and costly, and cannot effectively cope with complex lighting conditions and high counterfeiting risks.

Method used

By acquiring a collection of QR code images captured by different devices, performing segmentation and noise reduction processing, and then fusing a multi-scale dilated convolution model, an initial QR code anti-counterfeiting label authentication model is constructed and trained to form a target QR code anti-counterfeiting label authentication model for authenticity detection.

Benefits of technology

It achieves fast and accurate identification of QR code images in low-quality environments, improves the robustness and identification ability of the model, and can maintain high accuracy under complex lighting conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120409512A_ABST
    Figure CN120409512A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the field of image processing and computer vision, and provides a two-dimensional code anti-counterfeit label authentication method and a related device, and the method comprises the steps: obtaining two-dimensional code images shot by different image devices, and obtaining a two-dimensional code image set; performing segmentation and noise adding processing on each two-dimensional code image in the two-dimensional code image set to obtain a two-dimensional code data set; fusing the initial visual transformation model with multi-scale cavity convolution, and constructing an initial two-dimensional code anti-counterfeit label authentic identification model; training the initial two-dimensional code anti-counterfeit label authentic identification model according to the two-dimensional code data set to obtain a target two-dimensional code anti-counterfeit label authentic identification model; and the target two-dimensional code anti-counterfeit label authentic identification model is adopted to perform authentic identification on the image to be subjected to authentic identification to obtain a two-dimensional code anti-counterfeit label authentic identification result, so that the purpose of quickly and accurately performing authentic identification on the two-dimensional code image can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical fields of image processing and computer vision, and particularly to a method and related device for authenticating anti-counterfeiting labels of two-dimensional codes. Background Art

[0002] As a widely used two-dimensional bar code, the two-dimensional code has been widely used in fields such as electronic payment, product traceability, and identity verification due to its convenient storage and reading methods. However, with the rapid development and popularization of two-dimensional codes, in some low-quality production environments, it is impossible to determine the authenticity and validity of the used two-dimensional codes, thus unable to ensure the accuracy of the received or sent information. Therefore, how to quickly and accurately detect the authenticity of two-dimensional code images has become a hot research issue currently. Summary of the Invention

[0003] An embodiment of this application provides a method and related device for authenticating anti-counterfeiting labels of two-dimensional codes, which can train a target two-dimensional code anti-counterfeiting label authentication model based on a set of two-dimensional code images, so that the authenticity of an image to be authenticated can be detected through the target two-dimensional code anti-counterfeiting label authentication model, and an accurate two-dimensional code anti-counterfeiting label authentication result can be obtained, achieving the purpose of quickly and accurately detecting the authenticity of two-dimensional code images.

[0004] The first aspect of the embodiment of this application provides a method for authenticating anti-counterfeiting labels of two-dimensional codes, and the method includes:

[0005] Obtain two-dimensional code images captured by different imaging devices to obtain a set of two-dimensional code images;

[0006] Perform segmentation and noise addition processing on each two-dimensional code image in the set of two-dimensional code images for authenticating anti-counterfeiting labels of two-dimensional codes to obtain a set of two-dimensional code data;

[0007] Fuse a multi-scale dilated convolution with an initial visual transformation model to construct an initial two-dimensional code anti-counterfeiting label authentication model;

[0008] Train the initial two-dimensional code anti-counterfeiting label authentication model according to the set of two-dimensional code data for authenticating anti-counterfeiting labels of two-dimensional codes to obtain a target two-dimensional code anti-counterfeiting label authentication model;

[0009] Use the target two-dimensional code anti-counterfeiting label authentication model to authenticate the authenticity of an image to be authenticated, and obtain a two-dimensional code anti-counterfeiting label authentication result.

[0010] In this example, by obtaining the QR code images captured by different imaging devices, a set of QR code images is obtained, and each QR code image in the set of QR code images is segmented and noise-added to obtain a set of QR code data. Further, an initial visual transformation model is fused with multi-scale dilated convolutions to construct an initial QR code anti-counterfeiting label authentication model, and the initial QR code anti-counterfeiting label authentication model is trained according to the set of QR code data to obtain a target QR code anti-counterfeiting label authentication model. Thus, the target QR code anti-counterfeiting label authentication model can be used to perform authenticity detection on the image to be detected for authenticity, and a more accurate QR code anti-counterfeiting label authentication result can be obtained, achieving the purpose of quickly and accurately performing authenticity detection on QR code images.

[0011] The second aspect of the embodiments of the present application provides a QR code anti-counterfeiting label authentication device, and the device includes:

[0012] An acquisition unit, configured to obtain QR code images captured by different imaging devices to obtain a set of QR code images;

[0013] A first processing unit, configured to perform segmentation and noise-adding processing on each QR code image in the set of QR code images to obtain a set of QR code data;

[0014] A second processing unit, configured to fuse an initial visual transformation model with multi-scale dilated convolutions to construct an initial QR code anti-counterfeiting label authentication model;

[0015] A third processing unit, configured to train the initial QR code anti-counterfeiting label authentication model according to the set of QR code data to obtain a target QR code anti-counterfeiting label authentication model;

[0016] A fourth processing unit, configured to use the target QR code anti-counterfeiting label authentication model to perform authenticity detection on the image to be detected for authenticity to obtain a QR code anti-counterfeiting label authentication result.

[0017] The third aspect of the embodiments of the present application provides a terminal, including a processor, an input device, an output device, and a memory. The processor, the input device, the output device, and the memory are interconnected. Among them, the memory is used to store a computer program, and the computer program includes program instructions. The processor is configured to call the program instructions to execute the step instructions as described in the first aspect of the embodiments of the present application.

[0018] The fourth aspect of the embodiments of the present application provides a computer-readable storage medium. Among them, the computer-readable storage medium stores a computer program for electronic data exchange. Among them, the computer program enables a computer to execute some or all of the steps described in the first aspect of the embodiments of the present application.

[0019] A fifth aspect of the embodiments of the present application provides a computer program product. The computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in the first aspect of the embodiments of the present application. The computer program product may be a software installation package. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0021] Figure 1 FIG. [ID] is a schematic flowchart of a method for authenticating a two-dimensional code anti-counterfeiting label provided by an embodiment of the present application;

[0022] Figure 2 FIG. [ID] is a schematic structural diagram of a multi-scale dilated convolution module MDFA provided by an embodiment of the present application;

[0023] Figure 3 FIG. [ID] is a schematic network structure diagram of a target two-dimensional code anti-counterfeiting label authentication model provided by an embodiment of the present application;

[0024] Figure 4 FIG. [ID] is a schematic structural diagram of a terminal provided by an embodiment of the present application;

[0025] Figure 5 FIG. [ID] is a schematic structural diagram of a two-dimensional code anti-counterfeiting label authentication device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0026] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0027] In the description and claims of this application, as well as in the above-mentioned drawings, terms such as "first" and "second" are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally further include steps or units not listed, or may optionally further include other steps or units inherent to these processes, methods, products or devices.

[0028] The mention of "embodiment" in this application means that the specific features, structures or characteristics described in connection with the embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described in this application may be combined with other embodiments.

[0029] To better understand a method for authenticating a two-dimensional code anti-counterfeiting label provided by an embodiment of this application, the following first briefly introduces the scenario where the method for authenticating a two-dimensional code anti-counterfeiting label is applied. In recent years, with the development of multimedia images and information technology, two-dimensional code image information has been widely used as a medium for transmitting information. Two-dimensional code image data plays a very important role in modern society. However, on the one hand, currently, traditional algorithms for detecting the authenticity of two-dimensional codes are gradually unable to solve the problem of maliciously modifying the content of two-dimensional code image information; on the other hand, the means of forging two-dimensional codes are constantly evolving, posing a huge challenge to anti-counterfeiting technology. Traditional two-dimensional code anti-counterfeiting technologies, such as printing anti-counterfeiting, laser anti-counterfeiting, and material anti-counterfeiting, although can prevent forgery to a certain extent, with the continuous development of forgery technology, these methods face the risks of being easily cracked and replicated. For example, with the popularization of two-dimensional code printing technology, anti-counterfeiting labels are easily imitated, and the material anti-counterfeiting technology has high production costs and complex processes. Therefore, how to develop a technology that is efficient, low-cost, and can stably authenticate the authenticity of two-dimensional codes in a complex environment has become an urgent problem to be solved.

[0030] Based on the above technical problems, the present invention proposes a method and related device for authenticating a two-dimensional code anti-counterfeiting label, which can solve the problem of authenticating the authenticity of anti-counterfeiting codes in a low-quality environment, and can achieve the purpose of quickly and accurately detecting the authenticity of two-dimensional code images. By introducing a multi-scale feature fusion module, this method can effectively capture the detailed features of two-dimensional code images, and improve the model's ability to distinguish high-quality forged two-dimensional codes, and can still maintain a high level of discrimination accuracy in low-resolution and complex lighting environments, which is beneficial to improving the accuracy and effectiveness of the process of detecting the authenticity of two-dimensional code images.

[0031] Please refer toFigure 1 , Figure 1 This application provides a flowchart of a method for authenticating a QR code anti-counterfeiting label. The method includes:

[0032] S10: Obtain QR code images captured by different imaging devices to obtain a set of QR code images.

[0033] Among them, the set of QR code images may include one or more QR code images. The QR code image can be understood as the image obtained after shooting the QR code generated by the barcode generator with different imaging devices. The images captured by different imaging devices may have differences in resolution, clarity, color, etc., resulting in differences in the obtained QR code images, which helps to adapt to different actual scenarios during subsequent model training.

[0034] Optionally, this application uses eight different types of dedicated devices to collect a set of QR code images in a bright and stable environment. That is, taking the QR code images collected by eight different mobile devices in a clear and bright environment as an example for illustration, which does not limit this application.

[0035] S20: Perform segmentation and noise addition processing on each QR code image in the set of QR code images to obtain a set of QR code data.

[0036] The set of QR code data may include one or more QR code data. The QR code data can be understood as the data obtained after performing segmentation and noise addition processing on each QR code image. Segmentation can be understood as dividing each QR code image into multiple image blocks according to a fixed rule (for example, divided into 64 blocks, and each block can be 64×64 pixels). Each small block saves its position and the QR code label it belongs to, which not only facilitates subsequent model training to achieve the purpose of expanding the dataset, but also can simulate the characteristic changes of the QR code at different positions and enhance the model's ability to capture local details. Noise addition can be understood as adding various interference information to the image, such as blurring, noise, etc., to achieve the purpose of data enhancement, to simulate the complex environment that the QR code may encounter in reality, and let the model learn how to accurately identify the QR code under different interferences, enhancing the robustness of the model.

[0037] By dividing each QR code image in the QR code image dataset into multiple small blocks and adding different blur kernels to each segmented QR code image to generate a set of QR code data with blur interference, the set of QR code data can be further input into a deep neural network for training in subsequent steps, using an adversarial training strategy to improve the robustness of the model, enabling the model to effectively detect the QR code after blur processing, and then the trained deep neural network model can be used to detect the authenticity of new QR code images.

[0038] S30: Incorporate multi-scale dilated convolutions into the initial visual transformation model to construct an initial anti-counterfeiting model for QR code anti-counterfeiting labels.

[0039] Among them, the initial visual transformation model can be a detection model based on Vision Transformer. Vision Transformer usually consists of convolutional layers, pooling layers, fully connected layers, etc. It automatically extracts features in images through learning a large amount of data and performs object detection and classification. It is a target classification and detection algorithm based on deep learning. Multi-scale dilated convolution is a convolution technique that can sample at different intervals during convolution by setting different dilation rates (such as 6, 12, 18). Using convolution kernels with different dilation rates can capture features at different scales of the image, expand the receptive field, enhance the model's perception ability of image details of different sizes and complexities, and improve the model's extraction effect of QR code features.

[0040] The initial anti-counterfeiting model for QR code anti-counterfeiting labels can be understood as the model constructed by integrating the initial visual transformation model with multi-scale dilated convolutions. This initial anti-counterfeiting model for QR code anti-counterfeiting labels initially has the ability to distinguish the authenticity of QR code anti-counterfeiting labels, but it still needs to be further trained and optimized in the subsequent process.

[0041] Optionally, taking the initial visual transformation model as an improved Vision Transformer as an example, this application improves the initial visual transformation model to construct the anti-counterfeiting model for QR code anti-counterfeiting labels in this application, which can also be called the Vision Transformer detection model integrating multi-scale dilated convolutions. This application does not limit this. The specific steps can be as follows:

[0042] (1) Before the patch embedding module of the original Vision Transformer detection model, a multi-scale dilated convolution module can be first integrated. Exemplarily, first, the multi-scale module can consist of four convolutional blocks and a global average pooling layer. For example, a 1×1 convolutional kernel can be used to extract information between channels while keeping the spatial resolution unchanged; a 3x3 dilated convolution (dilation rate of 6) can be used to expand the receptive field and capture large-scale context information; a 3x3 dilated convolution (dilation rate of 12) can be used to further expand the receptive field and capture a larger range of context; a 3x3 dilated convolution (dilation rate of 18) can be used to capture the context information in the farthest range; the global statistical information of the feature map can be extracted through global average pooling operation, and then different sources of features can be integrated together using concatenation (Concat), so as to combine the expression capabilities of different features and obtain a convolutionally fused QR code feature image, which can provide rich feature representations for subsequent detection and classification tasks. This application does not limit this.

[0043] Since in the original model, block embedding is first performed, then the exhibit splicing operation is carried out, and then the feature extraction process is carried out, it may lead to poor detection effect for small target blocks. Therefore, in this application, a multi-scale fusion module is added before block embedding, which can directly process the input image, first enhance the feature expression, and then perform deeper feature processing and optimization, enabling it to have stronger feature extraction ability and at the same time improving the detection accuracy of small targets.

[0044] (2) Fusion of channel and spatial attention. The original Vision Transformer detection model usually splices the extracted features in the channel dimension when processing them. The method provided in this application merges and splices the extracted features in both the channel dimension and the spatial dimension. Exemplarily, first, global average pooling (Global Pooling) can be performed on the fused QR code feature image to obtain the global features of each channel; the importance weights of each channel can be learned through two fully connected layers (using the Rectified Linear Unit (ReLU) and the sigmoid function (such as the Sigmoid activation function) respectively); and the importance weights of each channel can be multiplied by the global features of each channel channel by channel to achieve channel weighting. Secondly, global pooling can be performed on the feature map after channel weighting in the channel dimension to obtain the spatial feature map; and through a 1x1 convolution and the Sigmoid activation function, the importance weights of each spatial position can be learned; thus, the importance weights of each spatial position can be multiplied by the spatial feature map element by element to achieve spatial weighting; finally, the output feature maps of the channel attention and spatial attention mechanisms are fused through an element addition (Add) operation to finally obtain the enhanced feature map, that is, the global attention feature map mentioned later.

[0045] It should be noted that the feature maps respectively calibrated in the channel and spatial dimensions are subjected to an element addition operation with the original fused QR code feature image, which can integrate and enhance the relevant features. The enhanced feature map can be reduced in dimension and integrated through a 1x1 convolutional layer to generate the final output feature map, that is, the global attention feature map. Through the channel and spatial attention mechanisms, the model can better match the features of the small targets to be detected, thereby improving the discrimination accuracy of the network.

[0046] Specifically, this application improves the initial Vision Transformer detection model to construct a Vision Transformer QR code anti-counterfeiting label authentication model integrating multi-scale dilated convolution, which can include using a multi-scale dilated convolution module to perform feature extraction on the input image before image input. As Figure 2 shown Figure 2Schematic diagram of the multi-scale dilated feature aggregation (MDFA) module provided in this application. For the related steps of the multi-scale dilated feature aggregation module, please refer to the following formula:

[0047] (1) Multi-scale feature extraction

[0048] F = Concat(Conv2D1(X), Conv2D2(X), Conv2D3(X), Conv2D4(X), AvgPool2D(X))

[0049] Where F represents the final feature map, such as the fused QR code feature image mentioned later; X represents the input image X, such as the image to be authenticated or QR code data; Conv2D1(X) represents the convolution operation on the input image X with the first kernel size (such as 1x1); Conv2D2(X) represents the convolution operation on the input image X with the second kernel size (such as 3x3); Conv2D3(X) represents the convolution operation on the input image X with the second kernel size (such as 5x5); Conv2D4(X) represents the convolution operation on the input image X with the second kernel size (such as 7x7); AvgPool2D(X) represents the average pooling operation on the input image X.

[0050] (2) Channel calibration

[0051]

[0052] F channel = F · F' c

[0053] Where F' c is the channel attention weight, also known as the channel importance weight; F is the input feature map, such as the fused QR code feature image mentioned later; σ is processed through an activation function; W1 is mapped through a fully connected layer, such as mapped through the first fully connected layer; W2 is mapped through a fully connected layer, such as mapped through the second fully connected layer; ReLU is processed through a rectified linear unit; H is the height of the feature map; W is the width of the feature map; F c,i,j represents the channel value at position (i, j) in the feature map; i is the height index; j is the width index; F channel is the output feature map after channel calibration, such as the channel feature map mentioned later.

[0054] That is to say, global average pooling can be performed on each channel to calculate the average value of each channel Subsequently, the pooled result is input into the fully connected layer W1 for mapping to generate intermediate features; finally, the weights of the channel attention are adjusted through another fully connected layer W2, and the result is restricted to the range of [0-1] through the activation function σ.

[0055] (3) Spatial calibration

[0056] F spatial = σ(Conv2D(F, k = 1))

[0057] F spatial_recal = F · F spatial

[0058] Among them, F spatial is the spatial attention weight, which can also be called the spatial importance weight; σ is processed through the activation function; Conv2D() represents the operation of two-dimensional convolution; F is the input feature map, such as the fused QR code feature image to be mentioned later; k represents the convolution kernel; k = 1 means the convolution kernel size is 1×1; F spatidl_recal is the weight enhancement for each position of the input feature map, that is, weighted in the spatial dimension.

[0059] The above spatial calibration formula describes the calculation process of the spatial attention mechanism. For example, a 1×1 convolution operation can be used on the input feature map F to obtain the spatial attention map F spatial , which is equivalent to calculating the weight for each pixel position, and also restricting the range to [0-1] using the activation function. The output spatial attention F spatial is the feature map that adjusts the importance of each spatial position, and F spatial_recal represents the process of spatial dimension weighting.

[0060] Extract different information features through multiple layers of convolution, then use global average pooling to extract global statistical information, and after splicing, obtain the feature map that fuses multi-scale features. Subsequently, through the global attention mechanism, the channel and spatial dimension attention calibration of the first part of the fused feature map is performed, so that the model can pay more attention to key features.

[0061] S40: Train the initial QR code anti-counterfeiting label authentication model according to the QR code data set to obtain the target QR code anti-counterfeiting label authentication model.

[0062] The target QR code anti-counterfeiting label authentication model can be understood as training the initial QR code anti-counterfeiting label authentication model using the QR code data set to adjust the parameters of the model, so that the model is more accurate in authenticity judgment, that is, the optimized version model obtained after training. This target QR code anti-counterfeiting label authentication model can be used for actual QR code authenticity detection.

[0063] Among them, the QR code data set can be divided into a training set, a validation set, and / or a test set according to a preset ratio, so as to train the initial QR code anti-counterfeiting label authentication model through the training set, the validation set, and the test set to obtain a target QR code anti-counterfeiting label authentication model. The preset ratio can be understood as the ratio of the training set, the validation set, and / or the test set for model training that is set in advance. Optionally, the preset ratio can be set by the user himself or default set by the system, and this application does not limit this. Exemplarily, in the embodiments of this application, the QR code data set can be divided into a training set and a validation set according to a ratio of 8:2 to implement the training of the initial QR code anti-counterfeiting label authentication model, and this application does not limit this.

[0064] S50: Use the target QR code anti-counterfeiting label authentication model to perform authenticity detection on the image to be detected for authenticity, and obtain the QR code anti-counterfeiting label authentication result.

[0065] Among them, the image to be detected for authenticity can be a QR code image that needs to be judged for authenticity. The image to be detected for authenticity can come from actual production, sales and other links and is the input data of the target QR code anti-counterfeiting label authentication model. Optionally, preprocessing operations can be performed on the image to be detected for authenticity to improve the image quality and reduce the interference of irrelevant information, so that it is more suitable for the model to process and analyze, and provide a more reliable data basis for subsequent model training and detection. The preprocessing can include but is not limited to operations such as removing noise, adjusting the image size, and normalizing pixel values, and this application does not limit this.

[0066] The QR code anti-counterfeiting label authentication result can be understood as the result output after processing the image to be detected for authenticity by the target QR code anti-counterfeiting label authentication model. The QR code anti-counterfeiting label authentication result can indicate the authenticity of the detected QR code, thus ensuring the authenticity and security of the QR code and helping to provide a reliable basis for related applications or subsequent operations.

[0067] In this embodiment, by obtaining QR code images taken by different imaging devices, a QR code image set is obtained, and each QR code image in the QR code image set is segmented and noise-added to obtain a QR code data set. Further, the initial visual transformation model is fused with multi-scale dilated convolutions to construct an initial QR code anti-counterfeiting label authentication model, and the initial QR code anti-counterfeiting label authentication model is trained according to the QR code data set to obtain a target QR code anti-counterfeiting label authentication model. Thus, the target QR code anti-counterfeiting label authentication model can be used to perform authenticity detection on the image to be detected for authenticity, and a more accurate QR code anti-counterfeiting label authentication result can be obtained, and the purpose of quickly and accurately performing authenticity detection on the QR code image can be achieved.

[0068] In a possible implementation manner, the process of using the target QR code anti-counterfeiting label authenticity verification model to perform authenticity verification on the image to be verified and obtain the authenticity verification result of the QR code anti-counterfeiting label is actually the detailed process of how the target QR code anti-counterfeiting label authenticity verification model further processes the data, and it is also the detailed process of how the initial QR code anti-counterfeiting label authenticity verification model further processes the data when training the initial QR code anti-counterfeiting label authenticity verification model according to the QR code data set. Specifically, using the target QR code anti-counterfeiting label authenticity verification model to perform authenticity verification on the image to be verified and obtain the authenticity verification result of the QR code anti-counterfeiting label may include the following steps:

[0069] A1. Use the target QR code anti-counterfeiting label authenticity verification model to perform fused multi-scale feature extraction on the image to be verified to obtain a fused QR code feature image;

[0070] A2. Use the target QR code anti-counterfeiting label authenticity verification model to perform channel and spatial attention fusion processing on the fused QR code feature image to obtain a global attention feature map;

[0071] A3. Use the target QR code anti-counterfeiting label authenticity verification model to perform segmentation embedding processing on the global attention feature map to obtain a one-dimensional feature map;

[0072] A4. Use the target QR code anti-counterfeiting label authenticity verification model to perform encoding processing on the one-dimensional feature map to obtain an encoded feature map;

[0073] A5. Use the target QR code anti-counterfeiting label authenticity verification model to perform feature mapping processing on the encoded feature map to obtain the authenticity verification result of the QR code anti-counterfeiting label.

[0074] Among them, the fused QR code feature image can be understood as the feature image obtained after performing fused multi-scale feature extraction on the image to be verified. The fused multi-feature feature extraction can also be called the feature extraction of fused multi-scale dilated convolution, that is, by using different convolution kernels and dilation rates (such as 1×1 convolution kernel, 3×3 dilated convolution, dilation rates of 6, 12, 18, etc.) and global average pooling operations to capture the features of the image to be verified at different scales, and then integrating the captured features, the obtained fused QR code feature image can provide rich information for subsequent judgment.

[0075] The global attention feature map can be understood as the feature map obtained after performing channel and spatial attention fusion processing on the fused QR code feature image. The channel and attention fusion processing can also be understood as the global attention mechanism processing, that is, first performing global pooling on each channel of the fused QR code feature image and processing it through two fully connected network multi-layer perceptrons (MLPs) to generate channel attention weights and multiplying them with the fused QR code feature image channel by channel; then summing the processed image in the channel dimension to obtain the spatial feature map, generating the spatial attention weights through the Sigmoid activation function, and multiplying them with the spatial feature map pixel by pixel; finally, performing channel weighting on the feature image calibrated by channel and spatial attention to obtain the above-mentioned global attention feature map, so that the model can pay more attention to key features.

[0076] The one-dimensional feature map can be understood as the feature map obtained after performing segmentation and embedding processing on the global attention feature map. This segmentation and embedding processing can be understood as the Patch Embedding operation, that is, dividing the global attention feature map into multiple non-overlapping small patches, each small patch is mapped to a specified dimensional space through a linear transformation, and position encoding is added to be transformed into multiple one-dimensional vectors, and further obtain the one-dimensional feature map to facilitate subsequent processing.

[0077] The encoded feature map can be understood as the feature map obtained after performing encoding processing on the one-dimensional feature map. This encoding processing can be understood as using a Transformer Encoder, such as first normalizing the one-dimensional feature map, then capturing the global feature relationship through the multi-head attention mechanism, further extracting deep features through the feed-forward neural network, using residual connections and layer normalization for stable training during this period, and using Dropout to enhance the generalization ability, so as to obtain the encoded feature map.

[0078] Optionally, the encoded feature map can be further processed through an MLP Head. First, it is mapped to the task-related feature space through a fully connected layer for dimensionality reduction, then the Gaussian error linear unit is used to introduce non-linear transformation, Dropout is used in the intermediate layer to improve generalization, and finally, the feature representation is adjusted through one or two fully connected layers to obtain the authenticity verification result of the QR code anti-counterfeiting label.

[0079] In a possible implementation, using the target QR code anti-counterfeiting label authenticity verification model to perform fused multi-scale feature extraction on the image to be verified for authenticity to obtain the fused QR code feature image refers to the specific process of fused multi-scale feature extraction. Specifically, using the target QR code anti-counterfeiting label authenticity verification model to perform authenticity verification on the image to be verified for authenticity to obtain the authenticity verification result of the QR code anti-counterfeiting label may include the following steps:

[0080] B1. Using the target two-dimensional code anti-counterfeiting label authentication model, extract the channel information from the image to be authenticated and detected to obtain a channel feature image;

[0081] B2. Using the target two-dimensional code anti-counterfeiting label authentication model, extract the large-scale information from the image to be authenticated and detected to obtain a large-scale feature image;

[0082] B3. Using the target two-dimensional code anti-counterfeiting label authentication model, extract the far-range information from the image to be authenticated and detected to obtain a far-range feature image;

[0083] B4. Using the target two-dimensional code anti-counterfeiting label authentication model, perform global average pooling on the image to be authenticated and detected to obtain a global feature image;

[0084] B5. Using the target two-dimensional code anti-counterfeiting label authentication model, splice the channel feature image, the large-scale feature image, the far-range feature image, and the global feature image to obtain a fused two-dimensional code feature image.

[0085] In image processing, an image usually consists of multiple channels. For example, a common red-green-blue (RGB) image has three channels: red (R), green (G), and blue (B). Channel information extraction can be to extract features with channel significance from each channel of the image to be authenticated and detected. Specifically, the target two-dimensional code anti-counterfeiting label authentication model can use operations such as convolution kernels to perform convolution operations on each channel to explore the relationships and patterns between pixels within the channel, so as to capture the unique information carried by different channels, such as color distribution, texture features, etc. Among them, the channel feature image can be understood as the image obtained after channel information extraction. This channel feature image retains the important features of the original image on each channel, which can help the model better understand the local and overall features of the image and play an important role in subsequent judgment of the authenticity of the two-dimensional code.

[0086] Large-scale information extraction can focus on features and structures in a larger range of the image. The target two-dimensional code anti-counterfeiting label authentication model can use convolution kernels with larger sizes or convolution operations with larger receptive fields to capture the feature information in a larger area of the image. For example, in a two-dimensional code image, large-scale information may include the overall layout of the two-dimensional code, the approximate distribution of modules, etc. Large-scale information helps the target two-dimensional code anti-counterfeiting label authentication model grasp the features of the image from a macroscopic level and avoid ignoring the overall features due to only focusing on local details. The large-scale feature image can be understood as the result of large-scale information extraction. It contains the feature information of the image at a large scale, can reflect the macroscopic structure and overall features of the image, and provides an important basis for subsequent authenticity judgment.

[0087] Far-range information extraction can emphasize the relationships and features among pixels that are farther away in the image. The target QR code anti-counterfeiting label authentication model can adopt special convolutional structures, such as dilated convolution, etc., to expand the receptive field of the convolutional kernel, so as to be able to obtain the correlation information among pixels at long distances in the image. In the QR code image, far-range information can help the model discover the long-range dependence relationships among QR code modules, and this relationship may be a feature that is difficult for counterfeit QR codes to imitate. The far-range feature image can be understood as the image obtained after far-range information extraction, which contains the feature information among pixels at long distances in the image and has a unique role in identifying the authenticity of QR codes.

[0088] Global average pooling processing can perform an average calculation on each channel of the image over the entire spatial dimension. Specifically, for each channel, the sum of all pixel values in the channel is added and divided by the total number of pixels to obtain a scalar value. Through global average pooling, the spatial information of the image can be compressed to obtain the global feature representation of each channel, which can reduce the number of model parameters while retaining the global feature information of the image. The global feature image can be understood as the image obtained after global average pooling processing, and it can use a lower-dimensional vector to represent the global features of the image, which can reflect the overall statistical information of the image, such as average color, overall brightness, etc., and provides information at the global level for subsequent feature fusion.

[0089] Concatenation processing can be to concatenate the channel feature image, large-scale feature image, far-range feature image, and global feature image in the channel dimension. For example, if each feature image has a certain number of channels, the number of channels of the image obtained after concatenation will be the sum of the channels of these feature images. Through concatenation, feature information at different scales and in different ranges can be integrated together to form a more comprehensive and richer feature representation. After concatenation processing, a fused QR code feature image can be obtained, which combines channel information, large-scale information, far-range information, and global information, contains richer features, can provide a more comprehensive and accurate basis for subsequent authenticity detection, and helps to improve the discrimination ability of the model.

[0090] Exemplarily, taking the authenticity detection image to enter the fused multi-scale dilated convolution structure as an example for illustration, this structure includes a first part of the fused multi-scale dilated convolution part, and the second part is the channel and spatial attention fusion (see the detailed description of the next embodiment). First, for the first part of the fused multi-scale dilated convolution, the fused multi-scale dilated convolution architecture realizes feature extraction at different scales through five parallel convolutional branches. Each branch is configured with a different dilation rate to expand the receptive field and capture spatial information in different ranges: the first branch uses a 1x1 convolutional kernel, without changing the spatial scale, and directly extracts features; the second branch uses a 3x3 convolutional kernel with a dilation rate of 6 to moderately expand the receptive field; the third branch uses a 3x3 convolutional kernel with a dilation rate of 12 to further expand the receptive field to capture more extensive context information; the fourth branch uses a 3x3 convolutional kernel with a dilation rate of 18 to provide the widest receptive field; the fifth branch uses an additional global average pooling branch to extract global context features and enhance the model's ability to understand the overall layout. This application does not limit this.

[0091] In a possible implementation manner, the target two-dimensional code anti-counterfeiting label authentication model is used to perform channel and spatial attention fusion processing on the fused two-dimensional code feature image to obtain a global attention feature map, which refers to the specific process of performing channel and spatial attention fusion processing. Specifically, using the target two-dimensional code anti-counterfeiting label authentication model to perform channel and spatial attention fusion processing on the fused two-dimensional code feature image to obtain a global attention feature map may include the following steps:

[0092] C1. Using the target two-dimensional code anti-counterfeiting label authentication model, perform global average pooling processing on the fused two-dimensional code feature image based on the channel attention mechanism to obtain a channel global feature map;

[0093] C2. Using the target two-dimensional code anti-counterfeiting label authentication model, determine the channel importance weight based on the fully connected layer;

[0094] C3. Using the target two-dimensional code anti-counterfeiting label authentication model, perform channel weighting processing according to the channel global feature map and the channel importance weight to obtain a channel feature map;

[0095] C4. Using the target two-dimensional code anti-counterfeiting label authentication model, perform summation processing on the channel feature map in the channel dimension to obtain a spatial feature map;

[0096] C5. Using the target two-dimensional code anti-counterfeiting label authentication model, generate a spatial attention weight based on the activation function;

[0097] C6. Using the target two-dimensional code anti-counterfeiting label authentication model, perform spatial weighting processing according to the spatial feature map and the spatial attention weight to obtain a spatial feature map;

[0098] C7. Using the target two-dimensional code anti-counterfeiting label authentication model, fuse the channel feature map, the spatial feature map, and the fused two-dimensional code feature image to obtain a global attention feature map.

[0099] After obtaining the fused two-dimensional code feature image, it can further enter the second part of the fused multi-scale dilated convolution structure, namely channel and spatial attention fusion, for channel and spatial attention fusion processing. Exemplarily, since the previous steps have generated five different branches to extract features of different scales, they can be concatenated in the channel dimension to synthesize a comprehensive feature map, and this merged comprehensive feature map can be calibrated by two attention mechanisms.

[0100] First, the comprehensive feature map can be globally average pooled (GlobalPooling) through the channel attention mechanism to obtain the global features of each channel. Then, two fully connected layers (ReLU and Sigmoid activation functions can be used respectively) are used to learn the importance weights of each channel. Finally, these weights are multiplied by the original feature map channel by channel to achieve channel weighting. Second, the comprehensive feature map can be globally pooled in the channel dimension to obtain a spatial feature map. And through a 1x1 convolution and a Sigmoid activation function, the importance weights of each spatial position can be learned. Further, these weights can be multiplied by the original feature map element by element to achieve spatial weighting.

[0101] The output feature maps of the channel attention and spatial attention mechanisms and the fused two-dimensional code feature image can be fused through an element addition (Add) operation to finally obtain an enhanced feature map, that is, the global attention feature map. At this time, the feature maps calibrated by the channel and the space respectively are subjected to an element addition operation with the original merged feature map to integrate and enhance the relevant features. The enhanced feature map can finally be reduced in dimension and integrated through a 1x1 convolutional layer to generate the final output feature map, that is, the global attention feature map.

[0102] In a possible implementation manner, using the target two-dimensional code anti-counterfeiting label authentication model to perform encoding processing on the one-dimensional feature map to obtain an encoded feature map refers to the specific process of encoding processing. Specifically, using the target two-dimensional code anti-counterfeiting label authentication model to perform encoding processing on the one-dimensional feature map to obtain an encoded feature map may include the following steps:

[0103] D1. Using the target two-dimensional code anti-counterfeiting label authentication model to perform normalization processing on the one-dimensional feature map to obtain a normalized feature map;

[0104] D2. Using the target QR code anti-counterfeiting label authentication model, perform multi-head attention calculation on the normalized feature map to obtain a multi-head attention feature map;

[0105] D3. Using the target QR code anti-counterfeiting label authentication model, perform deep feature extraction processing on the multi-head attention feature map using a feed-forward neural network to obtain a deep feature map;

[0106] D4. Using the target QR code anti-counterfeiting label authentication model, perform stable training on the deep feature map through residual connection and layer normalization to obtain a stable feature map;

[0107] D5. Using the target QR code anti-counterfeiting label authentication model, perform random dropout processing on the stable feature map using the random dropout method to obtain an encoded feature map.

[0108] Optionally, the global attention feature map output from the previous step can be input into an image patch embedding (PatchEmbedding) layer to be further segmented into N non-overlapping patches, each patch having a size of P×P. The formula can be seen as follows:

[0109]

[0110] where, Z0 represents the initial embedding vector, which can be composed of a classification token, patch embedding, and position encoding; x class represents the class embedding vector; represents the first image patch after segmentation; represents the second image patch after segmentation; represents the Nth image patch after segmentation; N represents the number of image patches; E pos represents the position encoding; E represents the linear mapping matrix; C is the number of channels; D is the dimension; N is the number of image patches; P is the side length of the image patch.

[0111] It should be noted that each patch is mapped to a D-dimensional space after linear transformation E, and E pos is a matrix of (N + 1)×D, which can be added to the embedding of each patch to introduce position information to make up for the lack of Transformer for spatial order.

[0112] Further, in the encoding process, that is, in the Encoder Block stage, first, a normalization layer (Layer Norm) can be used to perform a normalization operation on the input features, improving the numerical stability of the model and avoiding gradient vanishing or explosion. Then, a multi-head attention layer (Multi-Head Attention) can be used to map the input features through query (Query, Q), key (Key, K), and value (Value, V) matrices respectively. The steps for calculating the attention weights can be seen in the following formula:

[0113]

[0114] Among them, Attention(Q, K, V) represents the attention weights; Q represents the information to be focused on currently; K represents all the information that can be focused on; V represents the content to be actually extracted; K T represents the transpose of all the information that can be focused on; represents the dimension of all the information that can be focused on (i.e., Key); softmax represents the activation function.

[0115] In the multi-head self-attention mechanism, each attention head can independently execute the above process. Specifically, the calculation formula for a single attention head can be seen as follows:

[0116]

[0117] Among them, head i represents the attention weights of the i-th attention head; Q represents the Query matrix obtained by linearly transforming the original input; represents the Query weight matrix of the i-th head; K represents the Key matrix obtained by linearly transforming the original input; represents the Key weight matrix of the i-th head; V represents the Value matrix obtained by linearly transforming the original input; represents the Value weight matrix of the i-th head; Attention() represents the operation of calculating the attention weights, and the formula can be seen in the foregoing content.

[0118] When processing the multi-head attention feature map, the feed-forward neural network can be composed of multiple fully connected layers. By performing a non-linear transformation on the input multi-head attention feature map, the deep semantic information of the features can be further extracted. The deep feature map can be understood as the feature map obtained by performing deep feature extraction processing on the multi-head attention feature map using the feed-forward neural network. This deep feature map can contain more abstract and representative information, which helps the model make a more accurate judgment on the authenticity of the QR code anti-counterfeiting label.

[0119] In the processing of deep feature maps, a residual connection can directly add the input to the output after being processed by a feedforward neural network, that is, output = input + output of the feedforward neural network, so that the network can more easily learn the identity mapping during training, thereby accelerating the convergence speed of the model and helping to train deeper neural networks. Layer normalization can normalize the input of a neural network layer, such as calculating the mean and variance of all neurons of the same layer for each sample and performing normalization processing on the input. Layer normalization can reduce the problem of internal covariate shift, improving the stability and training efficiency of the model.

[0120] A stable feature map can be understood as a feature map obtained by processing a deep feature map through a residual connection and layer normalization. The stable feature map has been improved in terms of numerical stability and the convergence of model training, and is more conducive to the subsequent processing of the model.

[0121] Dropout is a regularization technique that can be used to prevent overfitting. When processing a stable feature map, Dropout can set the outputs of some neurons in the feature map to 0 according to a preset probability (e.g., a probability of 0.5), so that the model does not overly rely on neurons during training, thereby improving the generalization ability of the model. After randomly discarding the stable feature map using the Dropout method, an encoded feature map can be obtained, which contains feature representations suitable for the task of authenticating anti-counterfeiting QR code labels and will be used as the input for subsequent feature mapping processing to obtain the final authentication result.

[0122] In a possible implementation, using the target QR code anti-counterfeiting label authentication model to perform feature mapping processing on the encoded feature map to obtain the QR code anti-counterfeiting label authentication result refers to the specific process of feature mapping. Specifically, using the target QR code anti-counterfeiting label authentication model to perform feature mapping processing on the encoded feature map to obtain the QR code anti-counterfeiting label authentication result may include the following steps:

[0123] E1. Using the target QR code anti-counterfeiting label authentication model to perform dimensionality reduction processing on the encoded feature map to obtain a dimensionality-reduced feature map;

[0124] E2. Using the target QR code anti-counterfeiting label authentication model to perform non-linear transformation processing on the dimensionality-reduced feature map to obtain a non-linear feature map;

[0125] E3. Using the target QR code anti-counterfeiting label authentication model to perform random dropout processing on the non-linear feature map to obtain a generalized feature map;

[0126] E4. Using the target QR code anti-counterfeiting label authentication model to perform feature adjustment processing on the generalized feature map to obtain the QR code anti-counterfeiting label authentication result.

[0127] Among them, the dimensionality reduction process can be carried out through a dimensionality reduction algorithm (such as through a multi-layer perceptron head) to reduce the dimension of the encoded feature map, remove redundant information, simplify the data structure, and at the same time retain key features, which helps to improve the computational efficiency and generalization ability of the model. The dimensionality-reduced feature map can be the feature map obtained after the dimensionality reduction process, and its dimension is relatively reduced compared to the encoded feature map, and the data is more concise.

[0128] The non-linear transformation process can be to process the dimensionality-reduced feature map using a non-linear activation function (such as the Gaussian error linear unit, etc.), so that the model can learn complex non-linear relationships in the data, thereby increasing the expression ability of the model. The non-linear feature map can be the feature map obtained after the non-linear transformation process, which contains richer non-linear feature information and helps the model to more accurately identify the authenticity of the two-dimensional code anti-counterfeiting label.

[0129] The random dropout process (Dropout) can be to randomly set the outputs of some neurons in the non-linear feature map to 0 according to a preset probability to avoid the model's over-reliance on neurons, prevent overfitting, and enhance the generalization ability of the model. The generalized feature map can be understood as the feature map obtained after the random dropout process. At this time, the model's adaptability to different data is improved, and the risk of overfitting is reduced.

[0130] The feature adjustment process can be to further process the generalized feature map through operations such as one or two fully connected layers to adjust the feature representation to make it more suitable for judging the authenticity of the two-dimensional code anti-counterfeiting label. The final output obtained after the feature adjustment process, that is, the result of authenticating the two-dimensional code anti-counterfeiting label, can indicate the authenticity of the two-dimensional code being detected.

[0131] Specifically, the encoded feature image can be passed through a multi-layer perceptron head (MLP Head) to map the output vector of the encoded image to a specific task space to determine and obtain the result of authenticating the two-dimensional code anti-counterfeiting label, and this application does not limit this.

[0132] In the MLP Head stage, first, the input high-dimensional features can be mapped to the hidden layer space through a linear layer (Linear), and then an activation function (GELU) is introduced to make the model express more complex functional relationships, so as to preserve important output features and at the same time reduce unimportant feature responses. The following formula can be referred to:

[0133]

[0134] Among them, GELU(x) represents the step of performing non-linear transformation processing; x is the input value of the non-linear transformation processing; used to adjust the scaling of the input; 0.044715x 3It is a cubic term used to introduce non-linearity; tanh represents the hyperbolic tangent function, which is used to map the input to the range [-1, 1].

[0135] Optionally, through regularization techniques, the model can be prevented from overfitting by randomly masking a part of the neurons (i.e., setting some outputs to zero). The role of the second linear layer is to perform a linear transformation again, further processing the hidden features into output features, and the last regularization further enhances the generalization ability.

[0136] Please refer to Figure 3 , Figure 3 which is a schematic diagram of the network structure of the target QR code anti-counterfeiting label authentication model provided by this application. The relevant processing steps of the target QR code anti-counterfeiting label authentication model can be referred to the foregoing detailed description, and this application will not elaborate here. The present invention uses dilated convolution to increase the receptive field of the convolution kernel without increasing the number of parameters, enabling the model to effectively capture local information at different scales. The introduction of multi-scale dilated convolution can enhance the model's perception of scale features in different regions of the image, improve the local information modeling ability, and avoid the limitation of relying solely on the global self-attention mechanism for feature capture; dilated convolution can capture local and global information of the image at different scales, and by changing the dilation rate, multi-scale features from details to coarseness can be captured at different levels. After combining multi-scale dilated convolution with Vision Transformer, the model can simultaneously focus on local details and global context information, which plays an important role in enhancing the feature expression ability of the image; dilated convolution can increase the receptive field while reducing the computational cost, avoiding the computational cost brought by directly increasing the size of the convolution kernel, and effectively improving the performance and perception ability of the model.

[0137] Consistent with the above embodiments, please refer to Figure 4 , Figure 4 which is a schematic diagram of the structure of a terminal provided by an embodiment of this application. As Figure 4 shown, it includes a processor, an input device, an output device, and a memory. The processor, input device, output device, and memory are interconnected. Among them, the memory is used to store a computer program, and the computer program includes program instructions. The processor is configured to call the program instructions, and the above program includes instructions for performing the following steps;

[0138] Obtain QR code images captured by different imaging devices to obtain a set of QR code images;

[0139] Perform segmentation and noise addition processing on each QR code image in the set of QR code images to obtain a set of QR code data;

[0140] Fuse a multi-scale dilated convolution into the initial visual transformation model to construct an initial anti-counterfeiting model for QR code anti-counterfeiting labels;

[0141] Train the initial anti-counterfeiting model for QR code anti-counterfeiting labels according to the QR code data set to obtain a target anti-counterfeiting model for QR code anti-counterfeiting labels;

[0142] Use the target anti-counterfeiting model for QR code anti-counterfeiting labels to perform authenticity detection on the image to be detected for authenticity, and obtain the authenticity detection result of the QR code anti-counterfeiting label.

[0143] In this example, by obtaining QR code images captured by different imaging devices, a QR code image set is obtained, and each QR code image in the QR code image set is segmented and noise-added to obtain a QR code data set. Further, a multi-scale dilated convolution is fused into the initial visual transformation model to construct an initial anti-counterfeiting model for QR code anti-counterfeiting labels, and the initial anti-counterfeiting model for QR code anti-counterfeiting labels is trained according to the QR code data set to obtain a target anti-counterfeiting model for QR code anti-counterfeiting labels. Thus, the target anti-counterfeiting model for QR code anti-counterfeiting labels can be used to perform authenticity detection on the image to be detected for authenticity, and a more accurate authenticity detection result of the QR code anti-counterfeiting label can be obtained, and the purpose of quickly and accurately performing authenticity detection on the QR code image can be achieved.

[0144] The above mainly introduces the solution of the embodiment of the present application from the perspective of the execution process of the method side. It can be understood that in order for the terminal to implement the above functions, it includes the corresponding hardware structure and / or software module for executing each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments provided in this article, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0145] The embodiment of the present application can divide the functions of the terminal according to the above method examples. For example, each function unit can be divided corresponding to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of a software function unit. It should be noted that the division of units in the embodiment of the present application is illustrative, only a logical function division, and there can be other division methods in actual implementation.

[0146] Consistent with the above, please refer to Figure 5 , Figure 5This application provides a schematic structural diagram of a two-dimensional code anti-counterfeiting label authentication device. As Figure 5 shown, the device includes:

[0147] An acquisition unit 101, configured to acquire two-dimensional code images captured by different imaging devices to obtain a two-dimensional code image set;

[0148] A first processing unit 102, configured to perform segmentation and noise addition processing on each two-dimensional code image in the two-dimensional code image set to obtain a two-dimensional code data set;

[0149] A second processing unit 103, configured to fuse a multi-scale dilated convolution with an initial visual transformation model to construct an initial two-dimensional code anti-counterfeiting label authentication model;

[0150] A third processing unit 104, configured to train the initial two-dimensional code anti-counterfeiting label authentication model according to the two-dimensional code data set to obtain a target two-dimensional code anti-counterfeiting label authentication model;

[0151] A fourth processing unit 105, configured to use the target two-dimensional code anti-counterfeiting label authentication model to perform authenticity detection on an image to be detected for authenticity, and obtain a two-dimensional code anti-counterfeiting label authentication result.

[0152] In a possible implementation manner, the fourth processing unit 105, configured to use the target two-dimensional code anti-counterfeiting label authentication model to perform authenticity detection on an image to be detected for authenticity, and obtain a two-dimensional code anti-counterfeiting label authentication result, specifically includes:

[0153] Using the target two-dimensional code anti-counterfeiting label authentication model to perform multi-scale feature extraction on the image to be detected for authenticity to obtain a fused two-dimensional code feature image;

[0154] Using the target two-dimensional code anti-counterfeiting label authentication model to perform channel and spatial attention fusion processing on the fused two-dimensional code feature image to obtain a global attention feature map;

[0155] Using the target two-dimensional code anti-counterfeiting label authentication model to perform segmentation and embedding processing on the global attention feature map to obtain a one-dimensional feature map;

[0156] Using the target two-dimensional code anti-counterfeiting label authentication model to perform encoding processing on the one-dimensional feature map to obtain an encoded feature map;

[0157] Using the target two-dimensional code anti-counterfeiting label authentication model to perform feature mapping processing on the encoded feature map to obtain a two-dimensional code anti-counterfeiting label authentication result.

[0158] In a possible implementation manner, the fourth processing unit 105 is configured to use the target two-dimensional code anti-counterfeiting label authenticity verification model to perform fusion multi-scale feature extraction on the image to be verified for authenticity, so as to obtain a fused two-dimensional code feature image, and specifically:

[0159] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to extract channel information from the image to be verified for authenticity, so as to obtain a channel feature image;

[0160] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to extract large-scale information from the image to be verified for authenticity, so as to obtain a large-scale feature image;

[0161] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to extract far-range information from the image to be verified for authenticity, so as to obtain a far-range feature image;

[0162] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to perform global average pooling processing on the image to be verified for authenticity, so as to obtain a global feature image;

[0163] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to splice the channel feature image, the large-scale feature image, the far-range feature image, and the global feature image, so as to obtain a fused two-dimensional code feature image.

[0164] In a possible implementation manner, the fourth processing unit 105 is configured to use the target two-dimensional code anti-counterfeiting label authenticity verification model to perform encoding processing on the one-dimensional feature map, so as to obtain an encoded feature map, and specifically:

[0165] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to perform normalization processing on the one-dimensional feature map, so as to obtain a normalized feature map;

[0166] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to perform multi-head attention calculation on the normalized feature map, so as to obtain a multi-head attention feature map;

[0167] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to perform deep feature extraction processing on the multi-head attention feature map by using a feed-forward neural network, so as to obtain a deep feature map;

[0168] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to perform stable training on the deep feature map through residual connection and layer normalization, so as to obtain a stable feature map;

[0169] Use the target two-dimensional code anti-counterfeiting label authenticity verification model to perform random dropout processing on the stable feature map by using a random dropout method, so as to obtain an encoded feature map.

[0170] In a possible implementation, the fourth processing unit 105 is configured to perform feature mapping processing on the encoded feature map by using the target QR code anti-counterfeiting label authentication model, so as to obtain a QR code anti-counterfeiting label authentication result, specifically:

[0171] Perform dimensionality reduction processing on the encoded feature map by using the target QR code anti-counterfeiting label authentication model to obtain a dimensionality-reduced feature map;

[0172] Perform non-linear transformation processing on the dimensionality-reduced feature map by using the target QR code anti-counterfeiting label authentication model to obtain a non-linear feature map;

[0173] Perform random dropout processing on the non-linear feature map by using the target QR code anti-counterfeiting label authentication model to obtain a generalized feature map;

[0174] Perform feature adjustment processing on the generalized feature map by using the target QR code anti-counterfeiting label authentication model to obtain a QR code anti-counterfeiting label authentication result.

[0175] In a possible implementation, the fourth processing unit 105 is configured to perform channel and spatial attention fusion processing on the fused QR code feature image by using the target QR code anti-counterfeiting label authentication model to obtain a global attention feature map, specifically:

[0176] Perform global average pooling processing on the fused QR code feature image by using the target QR code anti-counterfeiting label authentication model based on the channel attention mechanism to obtain a channel global feature map;

[0177] Determine channel importance weights based on a fully connected layer by using the target QR code anti-counterfeiting label authentication model;

[0178] Perform channel weighting processing on the channel global feature map and the channel importance weights by using the target QR code anti-counterfeiting label authentication model to obtain a channel feature map;

[0179] Perform summation processing on the channel feature map in the channel dimension by using the target QR code anti-counterfeiting label authentication model to obtain a spatial feature map;

[0180] Generate spatial attention weights based on an activation function by using the target QR code anti-counterfeiting label authentication model;

[0181] Perform spatial weighting processing on the spatial feature map and the spatial attention weights by using the target QR code anti-counterfeiting label authentication model to obtain a spatial feature map;

[0182] Using the target two-dimensional code anti-counterfeiting label authentication model, the channel feature map, the spatial feature map, and the fused two-dimensional code feature image are fused to obtain a global attention feature map.

[0183] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, and the computer program enables a computer to execute some or all of the steps of any one of the two-dimensional code anti-counterfeiting label authentication methods described in the foregoing method embodiments.

[0184] An embodiment of the present application also provides a computer program product, where the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program enables a computer to execute some or all of the steps of any one of the two-dimensional code anti-counterfeiting label authentication methods described in the foregoing method embodiments.

[0185] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0186] In the above embodiments, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0187] In several embodiments provided by the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are merely illustrative ones. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be in an electrical or other form.

[0188] The unit described as a separated component may or may not be physically separated, and the component displayed as a unit may or may not be a physical unit, that is, it can be located in one place, or it can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0189] In addition, in each embodiment of the application, each functional unit can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software program module.

[0190] If the above integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The aforementioned memory includes: USB flash drives, read-only memory (ROM), random access memory (RAM), mobile hard disks, magnetic disks, or optical discs and other various media that can store program codes.

[0191] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing relevant hardware through a program. This program can be stored in a computer-readable memory, and the memory can include: flash drives, read-only memories, random access memories, magnetic disks, or optical discs, etc.

[0192] The above has introduced the embodiments of the present application in detail. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.

Claims

1. A method for authenticating a two-dimensional code anti-counterfeiting label, characterized in that, The method includes: Obtaining QR code images captured by different imaging devices to obtain a set of QR code images; Performing segmentation and noise addition processing on each QR code image in the set of QR code images to obtain a set of QR code data; Fusing a multi-scale dilated convolution into an initial visual transformation model to construct an initial QR code anti-counterfeiting label authentication model; Training the initial QR code anti-counterfeiting label authentication model according to the set of QR code data to obtain a target QR code anti-counterfeiting label authentication model; Using the target QR code anti-counterfeiting label authentication model to perform authenticity detection on an image to be authenticated to obtain a QR code anti-counterfeiting label authentication result.

2. The anti-counterfeiting method for the two-dimensional code anti-counterfeiting label according to claim 1, wherein The step of using the target QR code anti-counterfeiting label authentication model to perform authenticity detection on an image to be authenticated to obtain a QR code anti-counterfeiting label authentication result includes: Using the target QR code anti-counterfeiting label authentication model to perform multi-scale feature extraction on the image to be authenticated to obtain a fused QR code feature image; Using the target QR code anti-counterfeiting label authentication model to perform channel and spatial attention fusion processing on the fused QR code feature image to obtain a global attention feature map; Using the target QR code anti-counterfeiting label authentication model to perform segmentation and embedding processing on the global attention feature map to obtain a one-dimensional feature map; Using the target QR code anti-counterfeiting label authentication model to perform encoding processing on the one-dimensional feature map to obtain an encoded feature map; Using the target QR code anti-counterfeiting label authentication model to perform feature mapping processing on the encoded feature map to obtain a QR code anti-counterfeiting label authentication result.

3. The anti-counterfeiting method for the two-dimensional code anti-counterfeiting label according to claim 2, wherein, The step of using the target QR code anti-counterfeiting label authentication model to perform multi-scale feature extraction on the image to be authenticated to obtain a fused QR code feature image includes: Using the target QR code anti-counterfeiting label authentication model to extract channel information from the image to be authenticated to obtain a channel feature image; Using the target QR code anti-counterfeiting label authentication model to extract large-scale information from the image to be authenticated to obtain a large-scale feature image; Using the target QR code anti-counterfeiting label authentication model to extract long-range information from the image to be authenticated to obtain a long-range feature image; Using the target QR code anti-counterfeiting label authentication model to perform global average pooling on the image to be authenticated to obtain a global feature image; Using the target QR code anti-counterfeiting label authentication model to splice the channel feature image, the large-scale feature image, the long-range feature image, and the global feature image to obtain a fused QR code feature image.

4. The method for authenticating a two-dimensional code anti-counterfeiting label according to claim 3, characterized in that The step of using the target QR code anti-counterfeiting label authentication model to perform encoding processing on the one-dimensional feature map to obtain an encoded feature map includes: Using the target QR code anti-counterfeiting label authentication model to perform normalization processing on the one-dimensional feature map to obtain a normalized feature map; Using the target QR code anti-counterfeiting label authentication model to perform multi-head attention calculation on the normalized feature map to obtain a multi-head attention feature map; Using the target QR code anti-counterfeiting label authentication model, deep feature extraction processing is performed on the multi-head attention feature map by using a feed-forward neural network to obtain a deep feature map; Using the target QR code anti-counterfeiting label authentication model, stable training is performed on the deep feature map through residual connection and layer normalization to obtain a stable feature map; Using the target QR code anti-counterfeiting label authentication model, random dropout processing is performed on the stable feature map by using the random dropout method to obtain an encoded feature map.

5. The method for authenticating a two-dimensional code anti-counterfeiting label according to any one of claims 1-4, characterized in that Using the target QR code anti-counterfeiting label authentication model, feature mapping processing is performed on the encoded feature map to obtain the QR code anti-counterfeiting label authentication result, including: Using the target QR code anti-counterfeiting label authentication model, dimensionality reduction processing is performed on the encoded feature map to obtain a dimensionality-reduced feature map; Using the target QR code anti-counterfeiting label authentication model, non-linear transformation processing is performed on the dimensionality-reduced feature map to obtain a non-linear feature map; Using the target QR code anti-counterfeiting label authentication model, random dropout processing is performed on the non-linear feature map to obtain a generalized feature map; Using the target QR code anti-counterfeiting label authentication model, feature adjustment processing is performed on the generalized feature map to obtain the QR code anti-counterfeiting label authentication result.

6. The anti-counterfeiting method for the two-dimensional code anti-counterfeiting label according to claim 5, wherein Using the target QR code anti-counterfeiting label authentication model, channel and spatial attention fusion processing is performed on the fused QR code feature image to obtain a global attention feature map, including: Using the target QR code anti-counterfeiting label authentication model, global average pooling processing is performed on the fused QR code feature image based on the channel attention mechanism to obtain a channel global feature map; Using the target QR code anti-counterfeiting label authentication model, the channel importance weight is determined based on the fully connected layer; Using the target QR code anti-counterfeiting label authentication model, channel weighting processing is performed according to the channel global feature map and the channel importance weight to obtain a channel feature map; Using the target QR code anti-counterfeiting label authentication model, summation processing is performed on the channel feature map in the channel dimension to obtain a spatial feature map; Using the target QR code anti-counterfeiting label authentication model, spatial attention weights are generated based on the activation function; Using the target QR code anti-counterfeiting label authentication model, spatial weighting processing is performed according to the spatial feature map and the spatial attention weights to obtain a spatial feature map; Using the target QR code anti-counterfeiting label authentication model, the channel feature map, the spatial feature map, and the fused QR code feature image are fused to obtain a global attention feature map.

7. A device for authenticating a two-dimensional code anti-counterfeiting label, characterized in that, The device includes: An acquisition unit, configured to acquire QR code images captured by different imaging devices to obtain a QR code image set; A first processing unit, configured to perform segmentation and noise addition processing on each QR code image in the QR code image set to obtain a QR code data set; A second processing unit, configured to fuse a multi-scale dilated convolution with an initial visual transformation model to construct an initial QR code anti-counterfeiting label authentication model; A third processing unit, configured to train the initial QR code anti-counterfeiting label authentication model according to the QR code data set to obtain a target QR code anti-counterfeiting label authentication model; A fourth processing unit, configured to use the target QR code anti-counterfeiting label authentication model to perform authenticity detection on the image to be authenticated, so as to obtain an authentication result of the QR code anti-counterfeiting label.

8. The anti-counterfeiting device for two-dimensional code anti-counterfeiting labels according to claim 7, characterized in that, The fourth processing unit is configured to use the target QR code anti-counterfeiting label authentication model to perform authenticity detection on the image to be authenticated, so as to obtain an authentication result of the QR code anti-counterfeiting label, and specifically configured to: Use the target QR code anti-counterfeiting label authentication model to perform fused multi-scale feature extraction on the image to be authenticated, so as to obtain a fused QR code feature image; Use the target QR code anti-counterfeiting label authentication model to perform channel and spatial attention fusion processing on the fused QR code feature image, so as to obtain a global attention feature map; Use the target QR code anti-counterfeiting label authentication model to perform segmentation embedding processing on the global attention feature map, so as to obtain a one-dimensional feature map; Use the target QR code anti-counterfeiting label authentication model to perform encoding processing on the one-dimensional feature map, so as to obtain an encoded feature map; Use the target QR code anti-counterfeiting label authentication model to perform feature mapping processing on the encoded feature map, so as to obtain an authentication result of the QR code anti-counterfeiting label.

9. A terminal, characterized in that, It includes a processor, an input device, an output device and a memory. The processor, the input device, the output device and the memory are interconnected. Among them, the memory is used to store a computer program, and the computer program includes program instructions. The processor is configured to call the program instructions to execute the method according to any one of claims 1-6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and the computer program includes program instructions. When the program instructions are executed by the processor, the processor is caused to execute the method according to any one of claims 1-6.