Offline writer identification method and device, electronic equipment and medium

By using the sliding window local attention and global residual modeling method in word-level offline writer recognition, the problem of difficult to capture the unique writing style of the writer in the prior art is solved, and higher recognition accuracy is achieved .

CN119399780AActive Publication Date: 2025-02-07SOUTH CHINA UNIV OF TECH

Patent Information

Application Number
CN202411371415.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-02-07
Estimated Expiration
2044-09-29

AI Technical Summary

Technical Problem

The prior art is difficult to fully capture the writer's unique writing style in word-level offline writer recognition, limiting the accuracy of the recognition model.

Method used

Using the method based on local attention and global residual modeling of sliding windows, local features are captured through local modeling modules, global features are extracted in identity branches, and integrated into global modules to form a stronger and more robust writing style. Characterization.

Benefits of technology

Effectively extracting robust feature representations from limited writing handwriting greatly improves the recognition accuracy, far exceeding the recognition accuracy of other methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119399780A_ABST
    Figure CN119399780A_ABST
Patent Text Reader

Abstract

The invention discloses an offline writer identification method and device, electronic equipment and a medium. The method comprises the following steps: acquiring handwritten word image data; converting the handwritten image into a grayscale image, performing binarization processing on the grayscale image, adjusting the size of the processed image to a preset size, and constructing a training set; constructing a handwriting recognition model, and training the handwriting recognition model by adopting the training set; wherein the handwriting recognition model comprises a local modeling module, an identical branch and a global module, the local modeling module is used for capturing local features, the identical branch is used for extracting global features, and the global module is used for integrating the local features and the global features; and inputting a handwritten image to be recognized into the trained handwriting recognition model to obtain a result of a final classification layer of the model, performing softmax probability calculation, and taking a writer with the maximum probability as a recognition result. According to the method, robust feature representation can be effectively extracted from limited handwriting, and the recognition precision far higher than that of other methods is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning and pattern recognition, and in particular to an offline writer recognition method, device, electronic device and medium. Background Art

[0002] As a unique behavioral biometric feature, handwriting is widely present in daily life, such as handwritten signatures, personal notes, legal documents, etc. Each person's writing style is unique in details, which makes handwriting play a vital role in identity recognition, forensic identification, financial security and other fields. With the advent of the digital age, the application of online handwriting is becoming more and more popular. However, due to the existence of physical handwritten documents, offline handwriting has a wide range of applications. Therefore, identifying the writer of handwriting, that is, offline writer recognition technology, is still an important and challenging topic.

[0003] At present, most offline writer recognition methods focus on processing the writing data of a whole page or a whole sentence, and have achieved a high recognition rate. However, in word-level offline writer recognition, due to the small amount of effective handwriting on a single word image, it is difficult to fully capture the writer's unique writing style, which limits the accuracy of the recognition model. Summary of the invention

[0004] In order to solve at least one of the technical problems existing in the prior art to a certain extent, the purpose of the present invention is to provide an offline writer identification method, device, electronic device and medium based on sliding window local attention and global residual modeling.

[0005] The first technical solution adopted by the present invention is:

[0006] An offline writer identification method comprises the following steps:

[0007] Get handwritten word image data;

[0008] Convert the handwritten image into a grayscale image, perform binarization on the grayscale image, adjust the processed image size to a preset size, and construct a training set;

[0009] Constructing a handwriting recognition model, and using a training set to train the handwriting recognition model; wherein the handwriting recognition model includes a local modeling module, an identity branch, and a global module, wherein the local modeling module is used to capture local features, the identity branch is used to extract global features, and the global module is used to integrate local and global features;

[0010] The handwritten image to be recognized is input into the trained handwriting recognition model to obtain the result of the final classification layer of the model, and softmax probability calculation is performed to take the writer with the highest probability as the recognition result.

[0011] Furthermore, the step of converting the handwritten image into a grayscale image, performing binarization processing on the grayscale image, adjusting the size of the processed image to a preset size, and constructing a training set includes:

[0012] Convert the handwritten image into a grayscale image and use a Gaussian filter to remove noise from the image;

[0013] Use the OTSU algorithm to perform adaptive binarization on the denoised image to obtain a binary handwriting image:

[0014] After adjusting the binary handwriting image to a preset size, it is combined with the label data to construct a training set.

[0015] Furthermore, the step of adjusting the binary handwriting image to a preset size includes:

[0016] First, the binary handwriting image is scaled while maintaining its original aspect ratio, and then white pixels are used to fill the left and right sides or the top and bottom sides of the binary handwriting image to reach a preset size.

[0017] Furthermore, the local modeling module adopts the window self-attention mechanism and the sliding window self-attention mechanism in the Swin Transformer model to divide the word handwriting into blocks, and learns the local style features by calculating (sliding) window self-attention between word handwriting blocks;

[0018] The identity branch directly adds the block-based input to the local features extracted by the local modeling module, and adds the global features in a residual manner to introduce global writing style dependency; after the local features and the global features are fused, they are sent to the global module for deep integration; finally, the integrated features are input into the classification head to classify the writer's identity to complete the recognition.

[0019] Further, the local modeling module includes a plurality of Swin Transformer layers; the Swin Transformer layer includes a plurality of Swin Transformer blocks;

[0020] The Swin Transformer block includes a window multi-head self-attention mechanism, a sliding window multi-head self-attention mechanism and a feedforward network;

[0021] In the window multi-head self-attention mechanism, the input feature sequence is divided into multiple non-overlapping windows, and the multi-head self-attention is calculated separately between each window. On this basis, each window is slid by half the window length to obtain the sliding window multi-head self-attention mechanism, which introduces connections between adjacent non-overlapping windows in the previous layer and increases the receptive field. Finally, the features pass through a feedforward network composed of a multi-layer perceptron to become output and enter the next SwinTransformer layer for further feature extraction.

[0022] Furthermore, the identity branch includes a block embedding layer, an average pooling layer and a fully connected layer; the block embedding layer is used to cut the entire image into blocks, and then average pooling is performed to compress the spatial dimension, and finally a vector dimension mapping is performed through a fully connected layer to extract and integrate global features.

[0023] Furthermore, the method of inputting the handwriting image to be recognized into the trained handwriting recognition model, obtaining the result of the final classification layer of the model, and performing softmax probability calculation to select the writer with the highest probability as the recognition result includes:

[0024] The handwriting image to be recognized is input into the trained handwriting recognition model. The classification layer of the model outputs a vector whose dimension is equal to the number of writers in the training set, and each element corresponds to the raw score of a specific writer.

[0025] The softmax probability is calculated based on the output vector, and the category with the highest probability is selected as the final recognition result, that is, the handwritten image is attributed to the writer with the highest probability.

[0026] The second technical solution adopted by the present invention is:

[0027] An off-line writer identification device, comprising:

[0028] A data acquisition module, used for acquiring handwritten word image data;

[0029] An image processing module, used to convert a handwritten image into a grayscale image, perform binarization on the grayscale image, adjust the size of the processed image to a preset size, and construct a training set;

[0030] A model building module, used to build a handwriting recognition model, and train the handwriting recognition model using a training set; wherein the handwriting recognition model includes a local modeling module, an identity branch and a global module, wherein the local modeling module is used to capture local features, the identity branch is used to extract global features, and the global module is used to integrate local and global features;

[0031] The handwriting recognition module is used to input the handwriting image to be recognized into the trained handwriting recognition model, obtain the result of the final classification layer of the model, and perform softmax probability calculation to take the writer with the highest probability as the recognition result.

[0032] The third technical solution adopted by the present invention is:

[0033] An electronic device comprises a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, at least one program, the code set or the instruction set is loaded and executed by the processor to implement an offline writer identification method as described above.

[0034] The fourth technical solution adopted by the present invention is:

[0035] A computer-readable storage medium stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement an offline writer identification method as described above.

[0036] The fifth technical solution adopted by the present invention is:

[0037] A computer program product or a computer program includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the above-mentioned offline writer identification method.

[0038] The beneficial effects of the present invention are as follows: in the handwriting recognition model of the present invention, the local modeling module carefully captures the local dependencies between letter strokes through the (sliding) window multi-head self-attention mechanism, the identity branch extracts global features through global average pooling and a fully connected layer, and the global module integrates local and global features to form a more robust writing style representation, which can effectively extract robust feature representations from limited handwriting, and achieve recognition accuracy far exceeding other methods. In addition, the present invention uses sliding window local attention for the first time in this field, and comprehensively models local and global writing style features, providing new ideas for subsequent work in the field. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the embodiments of the present invention or the drawings of related technical solutions in the prior art are introduced below. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solutions of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0040] Figure 1 is a flowchart of the steps of an offline writer identification method in an embodiment of the present invention;

[0041] Figure 2 It is a structural diagram of a handwriting recognition model in an embodiment of the present invention. DETAILED DESCRIPTION

[0042] Embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and are not to be construed as limitations of the present invention. For the step numbers in the following embodiments, they are only provided for the convenience of explanation, and the order between the steps is not limited in any way, and the execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.

[0043] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., and orientations or positional relationships indicated are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.

[0044] In the description of the present invention, "several" means one or more, "more" means more than two, "greater than", "less than", "exceed" etc. are understood as not including the number itself, and "above", "below", "within" etc. are understood as including the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

[0045] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention in combination with the specific content of the technical solution.

[0046] In view of the existing technical problems, in order to improve the performance of word-level offline writer recognition, the present invention proposes a classifier based on residual sliding window self-attention. This method innovatively combines the idea of ​​Swin Transformer, uses sliding window attention to mine local handwriting features, and combines the idea of ​​residual learning to extract global features. Through the joint modeling of local and global features, this method can extract robust feature representation under limited handwriting volume, greatly improving the recognition accuracy.

[0047] Example 1

[0048] like Figure 1 As shown, this embodiment provides an offline writer identification method, comprising the following steps:

[0049] S1, obtaining handwritten word image data;

[0050] S2, converting the handwritten image into a grayscale image, performing binarization processing on the grayscale image, adjusting the size of the processed image to a preset size, and constructing a training set;

[0051] S3, constructing a handwriting recognition model, and using a training set to train the handwriting recognition model; wherein the handwriting recognition model includes a local modeling module, an identity branch and a global module, the local modeling module is used to capture local features, the identity branch is used to extract global features, and the global module is used to integrate local and global features;

[0052] S4. Input the handwriting image to be recognized into the trained handwriting recognition model, obtain the result of the final classification layer of the model, and perform softmax probability calculation, and take the writer with the highest probability as the recognition result.

[0053] This embodiment uses sliding window self-attention to learn local features, uses input-output residuals to learn global features, and combines local and global features for joint modeling, thereby effectively enhancing the ability to represent the handwriter's unique writing style, thereby improving recognition accuracy.

[0054] The above method is explained in detail below with reference to the accompanying drawings and specific embodiments.

[0055] This embodiment provides an offline writer identification method based on sliding window local attention and global residual modeling, comprising the following steps:

[0056] Step 1. Data preparation: Obtain handwritten word image data.

[0057] Specifically, handwritten word images may be obtained from a plurality of public offline handwriting datasets.

[0058] Step 2: Data preprocessing: Convert the handwritten image into a grayscale image, remove noise using a Gaussian filter, perform binarization using the OTSU algorithm, and then adjust the image size to a fixed size.

[0059] In some embodiments, step S2 specifically includes the following steps:

[0060] Step 2.1: Convert the handwriting image into a binary image.

[0061] Step 2.2: Use a Gaussian filter with a kernel size of 3×3 to remove the smaller noise points in the handwriting image to make it smoother.

[0062] Step 2.3: Use the OTSU algorithm to adaptively binarize the handwriting image to obtain a binary handwriting image.

[0063] Step 2.4: Unify the image size. First, scale the image while maintaining its original aspect ratio. Then fill the left and right sides or top and bottom sides of the image with white pixels to reach the specified size.

[0064] Step 3: Model training: The processed handwriting image is input into the handwriting recognition model. The model includes a local modeling module for capturing local features, an identity branch for extracting global features, and a global module for integrating local and global features.

[0065] In some embodiments, see Figure 2 The handwriting recognition model includes a local modeling module, an identity branch, and a global module. The local modeling module adopts the window self-attention mechanism and the sliding window self-attention mechanism in the Swin Transformer model, and learns the local style features by calculating (sliding) window self-attention between word handwriting blocks. The identity branch directly adds the block-by-block input to the local features extracted by the local modeling module, adds the global features in a residual manner, and introduces global writing style dependencies. After the local features and the global features are added, they are sent to the global module for deep modeling. Finally, the features are input to the classification head to classify the writer's identity to complete the recognition.

[0066] As an implementation method, the structure of the local modeling module is shown in Table 1, and Table 2 lists the structure of the Swin Transformer block in its Swin Transformer layer.

[0067] Table 1 Structure of local modeling module

[0068] Network Layer Specific operations Output size enter Input Channel 1 192×96×1 Chunk embedding Embedding dimension 96, block size 4 1152×96 Swin Transformer Layer 2 Swin Transformer blocks 48×24×96 Swin Transformer Layer 2 Swin Transformer blocks 48×24×192 Swin Transformer Layer 6 Swin Transformer blocks 24×12×384 Swin Transformer Layer 2 Swin Transformer blocks 12×6×768

[0069] Table 2 Structure of Swin Transformer block

[0070]

[0071] The local modeling module contains multiple Swin Transformer layers, each of which contains multiple Swin Transformer blocks. Taking one of the Swin Transformer layers as an example, it first reduces the length of the image feature to 1 / 2 of the original and the dimension of the feature to twice the original through block fusion. The Swin Transformer block consists of window multi-head self-attention, sliding window multi-head self-attention and feedforward network. Both mechanisms use the multi-head self-attention mechanism proposed by Transformer, weighting the features by the autocorrelation similarity of the handwriting features, adaptively enhancing the discriminative parts and weakening the parts with less information. In the window multi-head self-attention mechanism, the input feature sequence is divided into multiple non-overlapping windows, and the multi-head self-attention is calculated separately between each window. On this basis, the sliding window self-attention mechanism is obtained by sliding each window by half the window length, so that the adjacent non-overlapping windows of the previous layer are connected, which increases the receptive field. These two methods reduce the computational cost of attention calculation, because the attention mechanism only considers a pair of windows instead of the entire sequence, and can also effectively focus on local features. Finally, the features will pass through a feedforward network composed of a multi-layer perceptron to become output and enter the next Swin Transformer layer for further feature extraction.

[0072] After multiple Swin Transformer layers, the model can effectively extract the local features of the word image and send the features to the next part of the network for processing. The final feature shape output by the local modeling module is 1×768.

[0073] As an implementation, the identity branch uses a block embedding layer to cut the entire image into blocks, then performs average pooling to compress the spatial dimension, and finally uses a fully connected layer to map the 256-dimensional vector to 768 dimensions. The structure of the identity branch is shown in Table 3:

[0074] Table 3 Structure of the identity branch

[0075] Network Layer Specific operations Output size enter - 192×96×1 Chunk embedding Embedding dimension 256, block size 4 1152×256 Average Pooling - 1×256 Fully connected layer Input channels: 256, output channels: 768 1×768

[0076] As an implementation method, after extracting local features and global features, the global module adds and fuses the two, and inputs the fused features into the global module for deep feature extraction. Finally, these extracted features are sent to the classification layer to output the final result of writer recognition. The structure of the global module is shown in Table 4:

[0077] Table 4 Structure of the global module

[0078]

[0079] As an optional implementation, during the training process of the handwriting recognition model, cross entropy is used as a loss function to optimize the result of writer recognition and update the model parameters through gradient feedback.

[0080] The training parameters are as follows:

[0081] 1) Iteration number: 100; number of iterations per generation: 245;

[0082] 2) Optimizer: AdamW; Learning rate: 0.0001; Weight decay: 0.00001.

[0083] As an optional implementation, in order to further improve the performance of the model, the handwriting recognition model is first pre-trained using a word recognition task, and then the pre-trained weights are used as a basis for further training on a writer recognition task.

[0084] Step 4: Model reasoning: Input the handwritten image to be recognized into the model, obtain the result of the model's final classification layer and perform softmax probability calculation, and take the writer with the highest probability as the recognition result.

[0085] The handwriting image to be recognized is input into the model. The last layer (classification layer) of the handwriting recognition model will output a vector whose dimension is equal to the number of writers in the training set, and each element corresponds to the raw score of a specific writer. In order to convert these raw scores into an interpretable probability distribution, we apply the softmax function to the output vector. The softmax function converts the raw scores into probability values ​​ranging from 0 to 1, maintaining the relative size relationship between the scores, while ensuring that the sum of the probabilities of all categories (i.e. writers) is equal to 1. In this probability distribution, each element represents the probability that the input handwriting image belongs to the corresponding writer. Finally, we select the category with the highest probability as the final recognition result, that is, the handwriting image is attributed to the writer with the highest probability.

[0086] In summary, the method of the present invention has at least the following advantages and beneficial effects compared to the prior art:

[0087] (1) This paper proposes a residual sliding window self-attention classifier for word-level offline writer recognition, especially for enhancing writer recognition in the case of limited handwriting. Compared with traditional convolutional neural network (CNN) or recurrent neural network (RNN) methods, this paper can more effectively combine local and global features, greatly improve the recognition accuracy, and show significant performance advantages on word-level handwriting data.

[0088] (2) The present invention innovatively introduces a local modeling module to capture local handwriting features. This module effectively models the relationship between adjacent strokes through the (sliding) window multi-head self-attention mechanism of SwinTransformer, overcomes the limitations of traditional CNN in dealing with sparse connections, and enhances the model's ability to fine-tune modeling of local writing style features.

[0089] (3) The present invention proposes an identity branch and a global module for extracting and integrating global features. The identity branch encodes the entire image through global average pooling and a fully connected layer to obtain global writing style features; the global module deeply integrates local and global features to form a more robust feature representation.

[0090] (4) The present invention uses pre-training technology to effectively transfer relevant knowledge to the writer identification task by pre-training the model on the word recognition task. This method significantly improves the performance of the model on the target task, especially when dealing with limited data.

[0091] Example 2

[0092] This embodiment provides an offline writer identification device, comprising:

[0093] A data acquisition module, used for acquiring handwritten word image data;

[0094] An image processing module, used to convert a handwritten image into a grayscale image, perform binarization on the grayscale image, adjust the size of the processed image to a preset size, and construct a training set;

[0095] A model building module, used to build a handwriting recognition model, and train the handwriting recognition model using a training set; wherein the handwriting recognition model includes a local modeling module, an identity branch and a global module, wherein the local modeling module is used to capture local features, the identity branch is used to extract global features, and the global module is used to integrate local and global features;

[0096] The handwriting recognition module is used to input the handwriting image to be recognized into the trained handwriting recognition model, obtain the result of the final classification layer of the model, and perform softmax probability calculation to take the writer with the highest probability as the recognition result.

[0097] Since the device is an offline writer identification device of the embodiment of the present invention, and the principle of solving the problem by the device is similar to that of Figure 1 The method shown is similar, so the implementation of the device can refer to the implementation process of the above method embodiment, and the repeated parts will not be repeated.

[0098] Example 3

[0099] An embodiment of the present invention further provides an electronic device, the electronic device comprising a processor and a memory, the memory storing at least one instruction, at least one program, a code set or an instruction set, the at least one instruction, the at least one program, the code set or the instruction set being loaded and executed by the processor to implement the following Figure 1 An offline writer identification method is shown.

[0100] It is understood that the memory may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory includes a non-transitory computer-readable storage medium. The memory may be used to store instructions, programs, codes, code sets, or instruction sets. The memory may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data created according to the use of the server, etc.

[0101] The processor may include one or more processing cores. The processor uses various interfaces and lines to connect the various parts of the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory, and calling data stored in the memory. Optionally, the processor can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor can integrate one or a combination of a central processing unit (CPU) and a modem. Among them, the CPU mainly processes the operating system and application programs; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor, but implemented separately through a chip.

[0102] Since the electronic device is an electronic device corresponding to an offline writer identification method of an embodiment of the present invention, and the principle of solving the problem by the electronic device is similar to that of the method, the implementation of the electronic device can refer to the implementation process of the above method embodiment, and the repeated parts will not be repeated.

[0103] Example 4

[0104] The embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, the at least one program, the code set or instruction set is loaded and executed by a processor to implement the following Figure 1 An offline writer identification method is shown.

[0105] Those skilled 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 related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0106] Since the storage medium is a storage medium corresponding to an offline writer identification method of an embodiment of the present invention, and the principle of solving the problem by the storage medium is similar to that of the method, the implementation of the storage medium can refer to the implementation process of the above-mentioned method embodiment, and the repeated parts will not be repeated.

[0107] Example 5

[0108] In some possible implementations, various aspects of the method of the embodiment of the present invention may also be implemented in the form of a program product, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of an offline writer identification method according to various exemplary embodiments of the present application described above in this specification. The executable computer program code or "code" for executing each embodiment may be written in a high-level programming language such as C, C++, C#, Smalltalk, Java, JavaScript, Visual Basic, structured query language (e.g., Transact-SQL), Perl, or in various other programming languages.

[0109] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0110] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0111] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable ordinary technicians in the field to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent changes or modifications made based on the essence of the content of the present invention should be included in the protection scope of the present invention.

Claims

1. An offline writer identification method, characterized in that: The following steps are involved: Get handwritten word image data; Convert the handwritten image into a grayscale image, perform binarization on the grayscale image, adjust the processed image size to a preset size, and construct a training set; Constructing a handwriting recognition model, and using a training set to train the handwriting recognition model; wherein the handwriting recognition model includes a local modeling module, an identity branch, and a global module, wherein the local modeling module is used to capture local features, the identity branch is used to extract global features, and the global module is used to integrate local and global features; The handwritten image to be recognized is input into the trained handwriting recognition model to obtain the result of the final classification layer of the model, and softmax probability calculation is performed to take the writer with the highest probability as the recognition result.

2. The offline writer identification method according to claim 1, characterized in that: The method of converting the handwritten image into a grayscale image, performing binarization processing on the grayscale image, adjusting the size of the processed image to a preset size, and constructing a training set includes: Convert the handwritten image into a grayscale image and use a Gaussian filter to remove noise from the image; Use the OTSU algorithm to perform adaptive binarization on the denoised image to obtain a binary handwriting image: After adjusting the binary handwriting image to a preset size, it is combined with the label data to construct a training set.

3. The offline writer identification method according to claim 2, characterized in that: The step of adjusting the binary handwriting image to a preset size includes: First, the binary handwriting image is scaled while maintaining its original aspect ratio, and then white pixels are used to fill the left and right sides or the top and bottom sides of the binary handwriting image to reach a preset size.

4. The offline writer identification method according to claim 1, characterized in that: The local modeling module adopts the window self-attention mechanism and sliding window self-attention mechanism in the Swin Transformer model to divide the word handwriting into blocks, and learns the local style features by calculating the window self-attention between the word handwriting blocks; The identity branch directly adds the block-based input to the local features extracted by the local modeling module, and adds the global features in a residual manner to introduce global writing style dependency; after the local features and the global features are fused, they are sent to the global module for deep integration; finally, the integrated features are input into the classification head to classify the writer's identity to complete the recognition.

5. An offline writer identification method according to claim 1 or 4, characterized in that: The local modeling module includes multiple Swin Transformer layers; the Swin Transformer layer includes multiple Swin Transformer blocks; the Swin Transformer block includes a window multi-head self-attention mechanism, a sliding window multi-head self-attention mechanism and a feedforward network; In the window multi-head self-attention mechanism, the input feature sequence is divided into multiple non-overlapping windows, and the multi-head self-attention is calculated separately between each window. On this basis, each window is slid by half the window length to obtain the sliding window multi-head self-attention mechanism, which introduces connections between adjacent non-overlapping windows in the previous layer and increases the receptive field. Finally, the features are output through a feedforward network composed of a multi-layer perceptron and enter the next Swin Transformer layer for further feature extraction.

6. An offline writer identification method according to claim 1 or 4, characterized in that: The identity branch includes a block embedding layer, an average pooling layer, and a fully connected layer; The entire image is cut into blocks using a block embedding layer, and then average pooling is performed to compress the spatial dimension. Finally, a fully connected layer is used to map the vector dimension to extract and integrate global features.

7. The offline writer identification method according to claim 1, characterized in that: The handwriting image to be recognized is input into the trained handwriting recognition model to obtain the result of the final classification layer of the model and perform softmax probability calculation. The writer with the highest probability is selected as the recognition result, including: The handwriting image to be recognized is input into the trained handwriting recognition model. The classification layer of the model outputs a vector whose dimension is equal to the number of writers in the training set, and each element corresponds to the raw score of a specific writer. The softmax probability is calculated based on the output vector, and the category with the highest probability is selected as the final recognition result, that is, the handwritten image is attributed to the writer with the highest probability.

8. An off-line writer identification device, characterized in that: include: A data acquisition module, used for acquiring handwritten word image data; An image processing module, used to convert the handwritten image into a grayscale image, perform binarization on the grayscale image, adjust the size of the processed image to a preset size, and construct a training set; A model building module, used to build a handwriting recognition model, and train the handwriting recognition model using a training set; wherein the handwriting recognition model includes a local modeling module, an identity branch and a global module, wherein the local modeling module is used to capture local features, the identity branch is used to extract global features, and the global module is used to integrate local and global features; The handwriting recognition module is used to input the handwriting image to be recognized into the trained handwriting recognition model, obtain the result of the final classification layer of the model, and perform softmax probability calculation to take the writer with the highest probability as the recognition result.

9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the method described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Off-line English handwriting recognition method based on attention mechanism

    CN112686345A

  • Cross-modal character handwriting verification method, system and equipment and storage medium

    CN115620312A

  • Target detection method and system based on Transform and fusion attention mechanism

    CN115908772A

  • Off-line handwritten sample generation method based on multi-feature fusion

    CN115984879A

  • Method and system for identifying handwritten fonts based on AI technology

    CN118314588A

Cited By

  • Handwriting recognition method, computer equipment and readable storage medium

    CN122223729A

  • Handwriting recognition method, computer device and readable storage medium

    CN122223729B