A seal character recognition method and system based on Swin Transformer
By using a Swing Transformer-based method for recognizing stamped characters, grayscale transformation and DBNet model are employed to segment character images. Features are extracted by progressively downsampling the height in Swing Transformer, which solves the problems of low accuracy and efficiency in stamped character recognition and achieves efficient and automated recognition and input.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2024-02-27
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies struggle to effectively recognize stamped characters, especially due to interference from the metal material, low contrast, and the low accuracy and efficiency caused by complex structural models.
A method for recognizing stamped characters based on the Swin Transformer is adopted. The character image is segmented by combining grayscale transformation and cropping preprocessing with the DBNet model. The Swin Transformer is used to extract features by progressively downsampling the height while keeping the width unchanged. The feature sequence is decoded using CTC loss and the model is fine-tuned to improve the recognition accuracy.
It improves the accuracy and efficiency of embossed character recognition, reduces computational load, is suitable for industrial applications, reduces labor and material costs, and supports automated recognition and data entry.
Smart Images

Figure CN117975463B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition technology, and in particular to a method and system for recognizing stamped characters based on Swing Transformer. Background Technology
[0002] With the development of industrial production technology and the expansion of production scale, a large number of standardized industrial components are difficult to distinguish and manage by appearance, thus requiring additional markings, such as barcode labels and stamped serial numbers. Compared to barcodes and QR codes, which can be obtained by direct scanning, stamped serial numbers require manual input or the use of scene text recognition technology, such as CNN-RNN-based models and vision-language models, to be entered into the production management system for digitization.
[0003] However, the unique textures produced by metal cutting and surface treatment, the strong reflections of highly reflective metal surfaces, and the low contrast of the stamped characters relative to the background can all interfere with recognition, making it difficult for traditional deep learning-based scene text recognition methods, such as CNN-RNN-based models, to achieve ideal results on stamped images.
[0004] Meanwhile, the stamp number is composed of randomly arranged Latin letters and numbers, lacking clear semantic information. Therefore, the visual-language model has difficulty integrating semantic information into visual information, resulting in unsatisfactory recognition accuracy. Furthermore, due to its large parameters and complex structure, the visual-language model has low recognition efficiency, making it difficult to meet the needs of efficiency-oriented industrial production management.
[0005] Therefore, pure vision models are more suitable for recognizing stamped characters, such as various visual Transformers based on attention mechanisms. Among them, the Swin Transformer adopts a hierarchical design, downsampling and extracting features step by step. Its structure is relatively simple, and it uses window attention and moving window attention mechanisms to reduce computation, balancing performance and efficiency. It is suitable as an encoder to extract image features for scene text recognition.
[0006] In fact, there are precedents for using the Swing Transformer to recognize document text, handwritten text, and stamped text, proving the feasibility of this technical approach. However, these precedents did not change the encoder's downsampling structure. The input text image is halved in both width and height dimensions. Since stamped characters are mostly horizontally distributed, the width dimension contains the positional information of the characters. This leads to the downsampling in the width dimension being prone to over-compressing the character positional information, mixing the image features of adjacent characters, and producing incorrect recognition results, such as recognizing adjacent identical characters as a single character, or recognizing adjacent different characters as the same character.
[0007] Therefore, reducing interference in stamped images, fully exploring the visual information of stamped images, optimizing stamped character recognition methods and model structures, and improving the accuracy and efficiency of stamped character recognition are technical problems that urgently need to be solved in this field. Summary of the Invention
[0008] The purpose of this invention is to address the shortcomings of existing text recognition technologies in recognizing stamped characters by providing a method and system for recognizing stamped characters based on Swing Transformer.
[0009] To achieve this objective, the present invention adopts the following technical solution:
[0010] In a first aspect, the present invention proposes a method for recognizing stamped characters based on Swing Transformer, comprising the following steps:
[0011] Step 1: Acquire the workpiece stamp image through the acquisition terminal, and unify the format and simplify the data through preprocessing such as grayscale transformation, cropping, and compression;
[0012] Step 2: Segment the workpiece stamp image using the DBNet model to obtain the stamp character image, and construct a training dataset, dividing the training dataset into a pre-training part and a fine-tuning part;
[0013] Step 3: Use the Swin Transformer model to extract features from the pre-trained part of the stamped character image by progressive height downsampling. In the progressive height downsampling process, only the height dimension is compressed while the width dimension remains unchanged, and finally the feature sequence of the stamped character image is generated.
[0014] Step 4: Obtain the recognition result by decoding the feature sequence of the stamped character image based on CTC loss, and train the SwinTransformer model until convergence;
[0015] Step 5: Test the model on the stamped character images in the fine-tuned section, and continue training and fine-tuning the Swing Transformer model for images that are misidentified;
[0016] Step 6: Use the fine-tuned model to identify the new workpiece stamp.
[0017] Furthermore, when acquiring the workpiece stamp image through the acquisition terminal, a light-shielding and supplementary lighting module is configured to provide lighting conditions for the industrial camera to capture the high-reflectivity workpiece stamp image.
[0018] Furthermore, the preprocessing steps for grayscale transformation, cropping, and compression include:
[0019] The arithmetic mean of the RGB channel brightness values of each pixel in the color image captured by the industrial camera is used as the grayscale value of that pixel for grayscale transformation. Unnecessary areas other than the stamped area are cropped out, and the image quality is compressed to reduce the resolution.
[0020] Furthermore, the DBNet model uses MobileNetv3 as the backbone network, utilizes the FPN structure to extract multi-scale features from the input workpiece stamp image and stitches them together to obtain a feature map; based on the feature map, a convolutional layer and two transposed convolutional layers are used to obtain the predicted probability map and threshold map, respectively, and the DB algorithm is used to calculate the binarization threshold, setting pixels below the threshold to 0 and pixels above the threshold to 1 to obtain an approximate binary map, and segmenting to obtain the stamp character image.
[0021] Further, step 3 includes:
[0022] (3.1) The input stamped character image is transformed into an embedding vector representing the character components by dividing it into blocks;
[0023] (3.2) The three-stage height-level downsampling Swin Transformer module is used to extract features sequentially. The first stage consists of position embedding and multiple Swin Transformer blocks. The second and third stages consist of a block fusion module and multiple Swin Transformer blocks. The position embedding adds position encoding by element-wise addition to incorporate the position information of each character component. The block fusion module performs a 3×3 convolution with a height stride of 2 and a width stride of 1 on the input character component vector and performs batch normalization.
[0024] (3.3) After global pooling, the height dimension of the output features of the third stage Swin Transformer module is compressed to 1 dimension, and then transformed into a feature sequence to be decoded through a fully connected layer.
[0025] Furthermore, the CTC loss is used to maximize the probability of correctly identifying the feature sequence of the stamped character image as genuine stamped text, and the probability is calculated using the following formula:
[0026]
[0027]
[0028] Where π is the original recognition result sequence, and B is the transformation that removes delimiters and repeating characters from the recognition result sequence, π∈B -1 (l) represents the set of all π that can be transformed into the real stamped text l by B transformation, and T is the width of the feature sequence x of the stamped character image. This represents the occurrence of the character π in the sequence π at position t in the probability vector after softmax normalization. t The probability value.
[0029] Furthermore, the Swing Transformer model is fine-tuned using the methods described in steps 3-4.
[0030] Secondly, this invention proposes a embossed character recognition system based on Swing Transformer, which performs the aforementioned embossed character recognition method based on Swing Transformer.
[0031] Thirdly, the present invention proposes an electronic device including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-described method for recognizing stamped characters based on Swing Transformer.
[0032] Thirdly, the present invention proposes a computer-readable storage medium storing a computer program that is executed by a processor to implement the above-described method for recognizing stamped characters based on Swing Transformer.
[0033] By adopting the above technical solution, the present invention has the following beneficial effects:
[0034] This invention uses a data acquisition terminal equipped with a light-shielding and light-filling module to acquire images of steel stamps, creating good lighting conditions and adjusting the corresponding camera parameters. This reduces interference from the steel stamp material, ensures that the characters on the steel stamps are clearly identifiable, and improves the quality of training data.
[0035] This invention uses the Swing Transformer to extract character features from stamped images. As a pure vision model, it can fully exploit the visual information in stamped images without extracting semantic information. It has a relatively simple structure, high training and inference efficiency, and is suitable for industrial applications.
[0036] This invention addresses the characteristic that text in stamped images is mostly horizontally distributed by improving the structure of the Swing Transformer model. It achieves block embedding through two consecutive convolutions, which can gradually increase the feature dimension, facilitate feature fusion, and improve recognition performance. By downsampling and compressing the height dimension while keeping the width dimension unchanged, it can extract multi-level features of stamped characters, reduce recognition errors caused by excessive compression of positional information, and reduce computational load.
[0037] This invention uses images with incorrect recognition to continue training and fine-tuning the model, which can further improve the recognition accuracy, correct the recognition results of stamped characters, and adapt to various stamped texts on workpieces with different models and ranges.
[0038] This invention uses a steel stamp character recognition system to perform the recognition method. It has low resource consumption, is simple to operate, and is suitable for linkage with MES system to realize the function of automatically recognizing and entering steel stamp numbers, thereby reducing the factory's labor, time and material costs and promoting industrial automation and informatization. Attached Figure Description
[0039] Figure 1 This is a flowchart illustrating a method for recognizing stamped characters based on Swing Transformer proposed in this invention.
[0040] Figure 2 This is a schematic diagram of the overall structure of the Swing Transformer model in this invention.
[0041] Figure 3 This is a schematic diagram of the internal structure of the Swing Transformer block in this invention. Detailed Implementation
[0042] The following description is intended to disclose the present invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art. The basic principles of the invention defined in the following description can be applied to other embodiments, modifications, improvements, equivalents, and other technical solutions that do not depart from the spirit and scope of the invention.
[0043] It is understood that the term "a" should be understood as "at least one" or "one or more", that is, in one embodiment, the number of an element can be one, while in another embodiment, the number of the element can be multiple, and the term "a" should not be understood as a limitation on the number.
[0044] Please refer to Figures 1 to 3 This invention discloses a method for recognizing stamped characters based on Swing Transformer, such as... Figure 1 As shown, the method mainly includes the following steps:
[0045] Step S1: Acquire the workpiece stamp image through the acquisition terminal, and perform preprocessing such as grayscale transformation, cropping, and compression to unify the format and simplify the data. Specific steps are as follows:
[0046] S101 uses the light-shielding module of the acquisition terminal to block the steel stamp on the workpiece, turns on the supplementary light module, reduces interference from external light sources, and creates stable lighting conditions and shooting environment.
[0047] S102, Adjust camera parameters to ensure that the stamped characters are clearly identifiable. Parameters include focal length, exposure, and gain. Use the camera to capture an image of the original workpiece stamp.
[0048] S103, perform preprocessing to unify the format and simplify the data. Preprocessing includes taking the arithmetic mean of the brightness values of each pixel's RGB channels as the grayscale value of that pixel for grayscale transformation, cropping to remove useless areas outside the stamped area, and compressing the image quality to reduce the resolution.
[0049] The preprocessed unified image format facilitates subsequent model training and learning of the stamped image representation, and the simplified data reduces the computational load of subsequent models, thereby improving efficiency.
[0050] Step S2 involves obtaining the feature map, probability map, and threshold map of the workpiece stamp image using DBNet, and segmenting the stamp character images to construct the training dataset. The specific steps are as follows:
[0051] S201 uses the backbone network, namely the lightweight CNN network MobileNetv3, to extract features from the stamped image and obtain feature maps at multiple scales.
[0052] S202 uses a feature pyramid network structure to upsample and stack feature maps at different scales and then stitch them together, thereby fusing multi-scale features.
[0053] S203, based on the fused multi-scale features, uses one convolutional layer and two transposed convolutional layers respectively to obtain the predicted probability map and threshold map;
[0054] S204, Calculate the adaptive binarization threshold using the DB algorithm. The specific calculation method is as follows:
[0055]
[0056] Where P is a probability graph, P ij Let be the pixel in the i-th row and j-th column of the probability map, and T be the threshold map. ij Let be the pixel in the i-th row and j-th column of the threshold image, and k be the gain factor, which is set to 50 based on experience.
[0057] S205, will be below this threshold Pixels above this threshold are set to 0. Set the pixel value to 1 to obtain an approximate binary image, and segment it to obtain the stamped character image;
[0058] S206, label the real text corresponding to the stamped characters, and construct the training dataset.
[0059] Step S3 involves dividing the stamped character image into blocks and converting them into embedding vectors, which are then fed into the Swing Transformer module for step-by-step height downsampling to extract character features. For example... Figure 2 As shown, the specific steps are as follows:
[0060] S301, the input stamped character image is transformed into an embedding vector representing the character components by block division. Specifically, the image is divided into 4×4 image blocks, and two consecutive 3×3 convolutions with a stride of 2 are performed and batch normalization is performed, so that the height and width of the image are halved twice, while the channels are increased to D0 dimension, with D0 being 64. Each image block is transformed into the corresponding value in the embedding vector, and the output feature dimension is H / 4×W / 4×D0.
[0061] S302 employs a three-stage height-gradual downsampling Swin Transformer module to extract features. The first stage consists of position embedding and multiple Swin Transformer blocks. The second and third stages consist of a block fusion module and multiple Swin Transformer blocks. Position embedding incorporates positional information from each character component by adding positional codes element-wise. The block fusion module performs a 3×3 convolution with a height stride of 2 and a width stride of 1 on the input character component vector, followed by batch normalization. Two, six, and two Swin Transformer blocks are used in each stage, respectively. Each Swin Transformer block is composed of multiple modules, alternately using window attention and moving window attention mechanisms, such as... Figure 3 As shown, the specific process is as follows:
[0062] S3021, In the channel dimension, perform layer normalization on the input character component vector;
[0063] S3022, divide the window and calculate the window attention within each window;
[0064] S3023 adds attention to the input vector of S3021 by element-wise addition to perform a skip connection;
[0065] S3024, perform layer normalization on the current character component vector in the channel dimension;
[0066] S3025, Project the current vector using a multilayer perceptron;
[0067] S3026 adds the projection to the output vector of S3023 by element-wise addition to perform a skip connection;
[0068] S3027, repeat the process from S3021 to S3026, except that window attention is changed to moving window attention, which adds relative position encoding to the traditional attention;
[0069] S303, at the end of the third stage, global average pooling is used to further compress the height dimension of the character component vector to 1 dimension, and then it is transformed into a feature sequence to be decoded through a fully connected layer;
[0070] The block fusion module downsamples and compresses the height dimension to extract multi-level features of the stamped characters, while not affecting the block layout in width. This adapts to the characteristic that the text in stamped images is mostly horizontally distributed and reduces the amount of computation. Since the block embedding in step S301 before the first stage has already significantly compressed the image resolution, to prevent over-compression, the block fusion module is not set in the first stage, but at the beginning of the second and third stages.
[0071] The Swing Transformer block restricts self-attention computation to non-overlapping local windows to reduce computational load, while allowing cross-window connections to enable information interaction and improve performance.
[0072] Step S4: Decode the feature sequence based on CTC loss to obtain the recognition result, and train the model using the Adam optimizer.
[0073] The CTC loss is designed to adjust the model parameters to maximize the probability of correctly identifying the feature sequence x as the real stamped text l. The probability is calculated as follows:
[0074]
[0075] Where π is the original recognition result sequence, and B is the transformation that removes delimiters and repeating characters from the recognition result sequence, π∈B -1 (l) represents the set of all π that can be obtained from l through the B transformation.
[0076] The probability of identifying π from x is calculated as follows:
[0077]
[0078] Where T is the width of the feature sequence x, and y is the probability vector of x after softmax normalization. t Let be the column vector of probability distribution for the t-th character. This represents the probability value of the character corresponding to π appearing at position t.
[0079] The Adam optimizer parameters are kept at commonly used default values, namely, the exponential decay rate β1 is 0.9, β2 is 0.999, and the learning rate α is 0.001. An additional L2 regularization with a weight decay parameter of 0.00003 is added to appropriately reduce the parameters learned by the model during training and alleviate overfitting.
[0080] Step S5: Test the model on the new workpiece stamp, and continue to train and fine-tune the model for images that are incorrectly identified, so as to further improve the recognition accuracy.
[0081] The testing process involves repeatedly executing steps S1 to S4 for new workpiece stamps, namely, acquiring new workpiece stamp images, segmenting stamp character images, extracting character feature vectors, and decoding to obtain recognition results; filtering out stamp images with incorrect recognition to form a new training dataset, continuing to train and fine-tune the model, and further improving the recognition accuracy.
[0082] The fine-tuned model can be used in practical applications, that is, to generate the feature sequence to be decoded corresponding to the stamped character by executing steps S1 to S3, and then to obtain the recognition result based on the CTC loss decoding feature sequence in step S4.
[0083] Corresponding to the above embodiment of the method for recognizing stamped characters based on Swing Transformer, this application also provides an embodiment of a system for recognizing stamped characters based on Swing Transformer.
[0084] The stamped character recognition system includes:
[0085] The data acquisition module is used to acquire workpiece stamp images through the acquisition terminal, and to unify and simplify the data through preprocessing such as grayscale transformation, cropping, and compression.
[0086] A steel stamp character image segmentation module is used to segment workpiece steel stamp images using a DBNet model to obtain steel stamp character images; and to construct a training dataset based on the segmented steel stamp character images and their real steel stamp text during the training phase, dividing the training dataset into a pre-training part and a fine-tuning part.
[0087] The Swin Transformer model module is used to extract features of stamped character images from the pre-trained or fine-tuned parts by progressively downsampling the height of the Swin Transformer model. During the progressive height downsampling process, only the height dimension is compressed while the width dimension remains unchanged, ultimately generating a feature sequence of the stamped character image.
[0088] The model training and fine-tuning module is used to decode feature sequences based on CTC loss to obtain recognition results, and to train or fine-tune the Swin Transformer model until convergence.
[0089] The stamp recognition module is used to identify new workpiece stamps using a finely tuned model.
[0090] The stamped character recognition system communicates with the acquisition terminal via a port. It can configure various parameters of the camera within the acquisition terminal, receive stamped images of the workpiece acquired by the acquisition terminal, and use a SwinTransformer-based stamped character recognition method provided in the above embodiment to recognize the stamped characters and obtain the stamped number text. To facilitate integration with the MES system, the system can specify the legal length of the stamped characters and automatically input the legal stamped number text into the MES system via keystrokes, achieving automatic recognition and input of the stamped number, thus freeing up manpower. To facilitate analysis of the stamped image and recognition results and further optimize the recognition method, the system also implements the functions of recording recognition result logs and uploading stamped images and recognition results to a cloud server.
[0091] The system embodiments of the present invention can be applied to any device with data processing capabilities, such as a computer or other similar device. The system embodiments can be implemented in software, hardware, or a combination of both. Taking software implementation as an example, as a logical device, it is formed by the processor of any data processing device loading the corresponding computer program instructions from non-volatile memory into memory for execution.
[0092] This invention also provides an electronic device, including a memory and a processor;
[0093] The memory is used to store computer programs;
[0094] The processor is used to implement the above-described method for recognizing stamped characters based on Swing Transformer when executing the computer program.
[0095] The processes described above with reference to the flowcharts in the embodiments disclosed in this invention can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), it performs the functions defined in the methods of this application. It should be noted that the computer-readable medium described above in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wire segments, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless segments, wire segments, optical fibers, RF, etc., or any suitable combination thereof.
[0096] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, electronic devices, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0097] Those skilled in the art should understand that the embodiments of the present invention described above and shown in the accompanying drawings are merely examples and do not limit the present invention. The purpose of the present invention has been fully and effectively achieved. The functions and structural principles of the present invention have been shown and explained in the embodiments. Without departing from the stated principles, the implementation of the present invention may have any variations or modifications.
Claims
1. A method for recognizing stamped characters based on Swing Transformer, characterized in that, Includes the following steps: Step 1: Acquire the workpiece stamp image through the acquisition terminal, and unify the format and simplify the data through preprocessing such as grayscale transformation, cropping, and compression; Step 2: Segment the workpiece stamp image using the DBNet model to obtain the stamp character image, and construct a training dataset, dividing the training dataset into a pre-training part and a fine-tuning part; Step 3: Use the Swin Transformer model to extract features from the pre-trained part of the stamped character image by progressive height downsampling. In the progressive height downsampling process, only the height dimension is compressed while the width dimension remains unchanged, and finally the feature sequence of the stamped character image is generated. Step 4: Obtain the recognition result by decoding the feature sequence of the stamped character image based on CTC loss, and train the SwinTransformer model until convergence; Step 5: Test the model on the stamped character images in the fine-tuned section, and continue training and fine-tuning the Swing Transformer model for images that are misidentified; Step 6: Use the fine-tuned model to identify the new workpiece stamp.
2. The method for recognizing stamped characters based on Swing Transformer according to claim 1, characterized in that, When acquiring workpiece stamp images through the acquisition terminal, a light-shielding and supplementary lighting module is configured to provide lighting conditions for the industrial camera to capture high-reflectivity workpiece stamp images.
3. The method for recognizing stamped characters based on Swing Transformer according to claim 1, characterized in that, The preprocessing steps of grayscale transformation, cropping, and compression include: The arithmetic mean of the RGB channel brightness values of each pixel in the color image captured by the industrial camera is used as the grayscale value of that pixel for grayscale transformation. Unnecessary areas other than the stamped area are cropped out, and the image quality is compressed to reduce the resolution.
4. The method for recognizing stamped characters based on Swing Transformer according to claim 1, characterized in that, The DBNet model uses MobileNetv3 as its backbone network. It uses the FPN structure to extract multi-scale features from the input workpiece stamp image and stitches them together to obtain a feature map. Based on the feature map, a predicted probability map and a threshold map are obtained by using one convolutional layer and two transposed convolutional layers respectively. The DB algorithm is used to calculate the binarization threshold, and pixels below the threshold are set to 0, while pixels above the threshold are set to 1 to obtain an approximate binary map. The stamp character image is then segmented.
5. The method for recognizing stamped characters based on Swing Transformer according to claim 1, characterized in that, Step 3 includes: (3.1) The input stamped character image is transformed into an embedding vector representing the character components by dividing it into blocks; (3.2) The three-stage height-level downsampling Swin Transformer module is used to extract features sequentially. The first stage consists of position embedding and multiple Swin Transformer blocks. The second and third stages consist of a block fusion module and multiple Swin Transformer blocks. The position embedding adds position encoding by element-wise addition to incorporate the position information of each character component. The block fusion module performs a 3×3 convolution with a height stride of 2 and a width stride of 1 on the input character component vector and performs batch normalization. (3.3) After global pooling, the height dimension of the output features of the third stage Swin Transformer module is compressed to 1 dimension, and then transformed into a feature sequence to be decoded through a fully connected layer.
6. The method for recognizing stamped characters based on Swing Transformer according to claim 1, characterized in that, The CTC loss is used to maximize the probability of correctly identifying the feature sequence of the stamped character image as genuine stamped text. The probability is calculated using the following formula: Where π is the original recognition result sequence, and B is the transformation that removes delimiters and repeating characters from the recognition result sequence, π∈B -1 (l) represents the set of all π that can be transformed into the real stamped text l by B transformation, and T is the width of the feature sequence x of the stamped character image. This represents the occurrence of the character π in the sequence π at position t in the probability vector after softmax normalization. t The probability value.
7. The method for recognizing stamped characters based on Swing Transformer according to claim 1, characterized in that, The Swin Transformer model was fine-tuned using the methods described in steps 3-4.
8. A embossed character recognition system based on Swin Transformer, comprising the embossed character recognition method based on Swin Transformer as described in any one of claims 1 to 7, characterized in that, The stamped character recognition system includes: The data acquisition module is used to acquire workpiece stamp images through the acquisition terminal, and to unify and simplify the data through preprocessing such as grayscale transformation, cropping, and compression. A steel stamp character image segmentation module is used to segment workpiece steel stamp images using a DBNet model to obtain steel stamp character images; and to construct a training dataset during the training phase based on the segmented steel stamp character images and their real steel stamp text, dividing the training dataset into a pre-training part and a fine-tuning part. The Swin Transformer model module is used to extract features of stamped character images from the pre-trained or fine-tuned parts by progressively downsampling the height of the Swin Transformer model. During the progressive height downsampling process, only the height dimension is compressed while the width dimension remains unchanged, ultimately generating a feature sequence of the stamped character image. The model training and fine-tuning module is used to decode feature sequences based on CTC loss to obtain recognition results, and to train or fine-tune the Swin Transformer model until convergence. The stamp recognition module is used to identify new workpiece stamps using a finely tuned model.
9. An electronic device, characterized in that, The method includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the embossed character recognition method based on any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program that is executed by a processor to implement the Swing Transformer-based stamp character recognition method according to any one of claims 1 to 7.