Dongba text detection method based on Swin Transform

By applying Swin Transformer and FPEM modules in Dongba script detection, combined with the post-processing module, the problem of identifying the complex structure of Dongba script is solved, high-accuracy and efficient Dongba script detection is achieved, and the digitization of Dongba ancient books is improved. Analytical skills.

CN118537872APending Publication Date: 2024-08-23SOUTHWEST UNIV
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410505468.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-25
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing text detection methods are difficult to accurately identify and locate complex-structured Dongba text areas, especially in Dongba ancient books. Due to their unique pictographs and diverse distribution, detection accuracy and efficiency are low, and it is easy to Human intervention and errors occur.

Method used

The Dongba script detection method based on Swin Transformer is used, combined with the FPEM module and post-processing module, to improve the model's detection ability of Dongba script through multi-scale feature fusion and dynamic binarization threshold adjustment, and enhance the detection of complex backgrounds and changeable characters. Shape recognition ability.

Benefits of technology

Significantly improves the accuracy and efficiency of Dongba script detection, reduces manual intervention and error rates, can accurately locate and detect Dongba script, improves recognition and translation effects, and shows high precision, recall and harmonic mean F-measure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537872A
    Figure CN118537872A
Patent Text Reader

Abstract

The invention discloses a Dongba text detection method based on Swin Transform, and the method comprises the following steps: 1, collecting a Dongba text image, and building a Dongba text data set; 2, dividing the Dongba character image into a training set and a test set, and performing data enhancement processing; step 3, constructing a Dongba text detection model based on the Swin Transform; 4, inputting the training set into the Dongba text detection model in the step 3 for training to obtain a trained Dongba text detection model based on Swin Transformer; and 5, sending a to-be-detected image containing Dongba characters into the trained Dongba text detection model based on Swin Transformer obtained in the step 4, carrying out text detection, and outputting the Dongba characters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a Dongba script detection method based on Swin Transformer. Background Art

[0002] Dongba script, the unique writing system of the Naxi ethnic minority in Yunnan, China, is the only surviving systematic pictorial hieroglyphic script in the world, with a history of more than a thousand years. The origin of Dongba script can be traced back to the 9th century AD, when the Naxi society gradually prospered. In order to record folk legends, historical events and religious beliefs, the Naxi ancestors created this unique script. Dongba script has profound meanings. It depicts the history, culture and daily life of the Naxi people with vivid graphics and lines. In 2003, the ancient books and documents of the Naxi Dongba people were listed as "Memory of the World Heritage" by UNESCO, which fully reflects the precious value of Dongba script as a cultural heritage. Although the status of Dongba ancient books is so high, due to the lack of in-depth understanding of the relevant professional knowledge of Dongba ancient books, it is difficult for non-professionals to accurately translate Dongba ancient books. Therefore, it is particularly important to conduct digital analysis of Dongba ancient books, such as single character recognition, Dongba script retrieval, and machine translation research, which not only helps the inheritance and in-depth study of Dongba culture, but also has vital significance for the realization of the emergency protection of Dongba ancient books. In this process, accurately detecting Dongba characters is the first step, because its accuracy will directly determine the effects of recognition, retrieval and translation, and it is necessary to improve the detection accuracy.

[0003] Dongba ancient books are very different from modern books. Its main text is usually presented in three lines, each line is separated by a horizontal dividing line, and divided into multiple independent sentences by single or double vertical dividing lines. Dongba characters are diverse and extremely scattered. In addition, some ancient books contain not only horizontal and vertical dividing lines, but also decorated with outer borders or exquisite patterns. Due to their age, some ancient books have stains. Figure 1 An image of an ancient Dongba book is shown. Existing text detection methods, such as region-based methods, connected component-based methods, and texture-based methods, perform well when dealing with simple or standard text scenes, but when faced with complex and diverse structures such as Dongba text, it is often difficult to accurately identify the text region. Therefore, it is urgent to develop a text detection algorithm that can adapt to the characteristics of Dongba text. Summary of the invention

[0004] In view of the shortcomings of the prior art, the present invention proposes a Dongba script detection method based on Swin Transformer, which automatically detects and locates Dongba characters in Dongba ancient books through an algorithm, aims to improve detection accuracy and efficiency, and reduce manual intervention and error rate. The specific technical solution is as follows:

[0005] A Dongba script detection method based on Swin Transformer comprises the following steps:

[0006] Step 1: Collect Dongba script images and build a Dongba script dataset;

[0007] Step 2: Divide the Dongba script images into training set and test set, and perform data enhancement processing;

[0008] Step 3: Build a Dongba script detection model based on Swin Transformer;

[0009] Step 4: Input the training set into the Dongba script detection model in step 3 for training, and obtain a trained Dongba script detection model based on Swin Transformer;

[0010] Step 5: Send the image containing Dongba characters to be detected into the trained Dongba character detection model based on Swin Transformer obtained in step 4, perform text detection, and output Dongba characters.

[0011] Preferably, the Swin Transformer-based Dongba script detection model includes 1 Swin Transformer module, 2 FPEM modules, 1 addition layer, 1 splicing layer and 1 post-processing module;

[0012] The output segment of the input image is connected to the input end of the Swin Transformer module, the output end of the Swin Transformer module is connected to the input end of the first FPEM module, the output end of the first FPEM module is connected to the input end of the second FPEM module, the output end of the second FPEM module is connected to the input end of the addition module, the output end of the addition module is connected to the input end of the splicing layer, the output end of the splicing layer is connected to the input end of the differentiable binarization module, and the output end of the differentiable binarization module is used as the output end of the model.

[0013] Preferably, the FPEM module consists of 6 addition layers, the output terminals F2, F3, F4, and C5 of the Swin Transformer module form the input terminals of the FPEM, the input terminals C5 and F4 form the input terminal of the first addition layer, the output terminals C4 and F3 of the first addition layer are connected to the input terminal of the second addition layer, the output terminals C3 and F2 of the second addition layer are connected to the input terminal of the third addition layer, the output terminals C2 and C3 of the third addition layer are connected to the input terminal of the fourth addition layer, the output terminals C3_1 and C4 of the fourth addition layer are connected to the fifth addition layer, the output terminals C4_1 and C5 of the fifth addition layer are connected to the input terminal of the sixth addition layer, and the output terminals C5_1, C4_1, C3_1, and C2 of the sixth addition layer serve as the output terminals of the FPEM.

[0014] Preferably, the four output ends of the first FPEM form the four input ends of the second FPEM, the four output ends of the first FPEM and the four output ends of the second FPEM form the input ends of the addition layer, and the four output ends of the addition layer are connected to obtain one output end through a splicing layer.

[0015] Preferably, the post-processing module is composed of 2 3×3 convolutional layers, 4 batch normalization layers, 4 deconvolutional layers, 1 Sigmoid function, and 1 differentiable binarization operation;

[0016] The output of the concatenation layer forms the input of the post-processing module. The input forms two branches. The first branch forms the input of the first 3×3 convolutional layer. The output of the first 3×3 convolutional layer is connected to the input of the first batch normalization layer. The output of the first batch normalization layer is connected to the input of the first deconvolution layer. The output of the first deconvolution layer is connected to the input of the second batch normalization layer. The output of the second batch normalization layer is connected to the input of the second deconvolution layer. The output of the second deconvolution layer is connected to the input of the Sigmoid function. The output P of the function is connected to the input of the differentiable binarization; the second branch forms the input of the second 3×3 convolutional layer, the output of the second 3×3 convolutional layer is connected to the input of the third batch normalization layer, the output of the third batch normalization layer is connected to the input of the third deconvolution layer, the output of the third deconvolution layer is connected to the input of the fourth batch normalization layer, the output of the fourth batch normalization layer is connected to the input of the fourth deconvolution layer, the output T of the fourth deconvolution layer is connected to the input of the differentiable binarization, and the output of the differentiable binarization forms the output of the post-processing module.

[0017] The beneficial effects of the present invention are as follows: the core of the present invention is to utilize the powerful ability of Swin Transformer to extract complex text features, and at the same time combine the FPEM module to realize the effective fusion of multi-scale features, thereby enhancing the model's detection ability for Dongba script.

[0018] First, the application of Swin Transformer enables this method to deeply capture the detailed features of Dongba script, including but not limited to its unique shape and complex layout. This is crucial to improving detection accuracy, especially in scenes with complex backgrounds or variable text shapes. Furthermore, by introducing the FPEM module, this method can cascade and fuse features of different scales, which not only retains detailed information, but also enhances the model's detection capabilities for texts of different sizes. The retention of this multi-scale information is the key to understanding and accurately locating Dongba script. Finally, through a post-processing module, the present invention dynamically adjusts the binarization threshold of each pixel, further improving the distinction between the foreground Dongba script and the background. The text detection method constructed by this method can accurately locate and detect Dongba script. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 This is an image of an ancient Dongba book. The arrow points to the dividing line, the square framed is a decorative pattern, and the circle is a stain.

[0020] Figure 2 It is a basic flow chart of the Dongba script detection method based on Swin Transformer of the present invention.

[0021] Figure 3 It is a structural diagram of the text detection model constructed by the present invention.

[0022] Figure 4 This is a schematic diagram of the Swin Transformer module.

[0023] Figure 5 is a schematic diagram of the FPEM module.

[0024] Figure 6 is a schematic diagram of the post-processing module.

[0025] Figure 7 This is a visual comparison chart of the detection results of different methods. DETAILED DESCRIPTION

[0026] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present invention.

[0027] As attached Figure 2-6 As shown in FIG. 1 , a Dongba script detection method based on Swin Transformer is shown in FIG. 1 , and the specific steps are as follows:

[0028] S1: Collect 400 images of Dongba ancient texts respectively. This embodiment is based on the data of Harvard-Yenching Library.

[0029] S2: Use the PPOCRLabel tool to accurately label the text area in the Dongba ancient book image. The labeling tool can label the Dongba ancient book data with multiple points without limiting the number of points. And save the labeling information in txt format.

[0030] S3: Divide the dataset into a training set and a test set in a ratio of 8:2. The training set contains 320 images with 19,332 Dongba handwritten characters, and the test set contains 80 images with 4,934 Dongba handwritten characters.

[0031] S4: Build a Dongba script detection model based on Swin Transformer and set model parameters.

[0032] Dongba script detection model based on Swin Transformer, such as Figure 2 , including Swin Transformer module, FPEM module, addition layer, concatenation layer and post-processing module.

[0033] 1. Swin Transformer module

[0034] See also Figure 3,The Swin Transformer module consists of 1 Patch Partition layer, 1 LinearEmbedding layer, 3 Linear Merging layers and 6 Swin Transformer Blocks layers. In the SwinTransformer module, the output end of the input image is connected to the PatchPartition layer as the input end of the Swin Transformer module, the output end of the Patch Partition layer is connected to the input end of the Linear Embedding layer, the output end of the LinearEmbedding layer is connected to the input end of the first Swin Transformer Blocks layer, the output end F2 of the first SwinTransformer Blocks layer is connected to the input end of the first Linear Merging layer, the output end of the first LinearMerging layer is connected to the input end of the second Swin Transformer Blocks layer, the output end F3 of the second SwinTransformer Blocks layer is connected to the input end of the second LinearMerging layer, the output end of the second LinearMerging layer is connected to the input end of the third Swin Transformer Blocks layer, the output end of the third SwinTransformer Blocks layer is connected to the input end of the fourth Swin Transformer Blocks layer, the output end of the fourth Swin Transformer Blocks layer is connected to the input end of the fifth Swin Transformer Blocks layer, the output end F4 of the fifth Swin Transformer Blocks layer is connected to the input end of the third Linear Merging layer, and the third Linear The output end of the Merging layer is connected to the input end of the sixth Swin Transformer Blocks layer, and the output ends C5, F4, F2, and F3 of the sixth Swin Transformer Blocks layer form the four output ends of the Swin Transformer module.

[0035] 2. FPEM module

[0036] See also Figure 4, the FPEM module consists of 6 addition layers. The output terminals F2, F3, F4, and C5 of the Swin Transformer module form the input terminals of the FPEM. The input terminals C5 and F4 form the input terminals of the first addition layer, the output terminals C4 and F3 of the first addition layer are connected to the input terminals of the second addition layer, the output terminals C3 and F2 of the second addition layer are connected to the input terminals of the third addition layer, the output terminals C2 and C3 of the third addition layer are connected to the input terminals of the fourth addition layer, the output terminals C3_1 and C4 of the fourth addition layer are connected to the fifth addition layer, the output terminals C4_1 and C5 of the fifth addition layer are connected to the input terminals of the sixth addition layer, and the output terminals C5_1, C4_1, C3_1, and C2 of the sixth addition layer are used as the output terminals of the FPEM. The four output terminals of the first FPEM are concatenated to obtain one output terminal.

[0037] See also Figure 3 The four output ends of the first FPEM form the four input ends of the second FPEM, the four output ends of the first FPEM and the four output ends of the second FPEM form the input end of the addition layer, and the four output ends of the addition layer are concatenated to obtain one output end.

[0038] 3. Post-processing module

[0039] See also Figure 5 The post-processing module consists of 2 3×3 convolutional layers, 4 batch normalization layers, 4 deconvolutional layers, 1 Sigmoid function, and 1 differentiable binarization operation. The output of the concatenation layer forms the input of the post-processing module. The input forms two branches. The first branch forms the input of the first 3×3 convolutional layer. The output of the first 3×3 convolutional layer is connected to the input of the first batch normalization layer. The output of the first batch normalization layer is connected to the input of the first deconvolution layer. The output of the first deconvolution layer is connected to the input of the second batch normalization layer. The output of the second batch normalization layer is connected to the input of the second deconvolution layer. The output of the second deconvolution layer is connected to the input of the Sigmoid function. The output P of the function is connected to the input of the differentiable binarization; the second branch forms the input of the second 3×3 convolutional layer, the output of the second 3×3 convolutional layer is connected to the input of the third batch normalization layer, the output of the third batch normalization layer is connected to the input of the third deconvolution layer, the output of the third deconvolution layer is connected to the input of the fourth batch normalization layer, the output of the fourth batch normalization layer is connected to the input of the fourth deconvolution layer, the output T of the fourth deconvolution layer is connected to the input of the differentiable binarization, and the output of the differentiable binarization forms the output of the post-processing module.

[0040] After building the deep learning model, you need to set the initial parameters of the network.

[0041] In this embodiment, the network parameters set include: the batch size of all samples is 6, the number of iterations is 20; the initial learning rate is 0.001;

[0042] S5: Input the labeled training set in step 3 into the Dongba script detection model based on Swin Transformer constructed in step 4 for training, use the loss function for back propagation to update the network parameters, and optimize the model through stochastic gradient descent to obtain the trained Dongba script detection model based on Swin Transformer.

[0043] The loss function L consists of three parts, specifically the probability map loss L p , threshold map loss L t And the binary graph loss function L b Add them together and the calculation method is as follows:

[0044] L=L b +α×L p +β×L t

[0045] Among them, L b represents the binary image loss, L p represents the probability map loss, L t represents the threshold map loss, α is set to 5, and β is set to 10.

[0046] L p The binary cross entropy loss function is used to focus on the identification of positive samples, ensuring that the model can accurately distinguish between text and non-text areas. The formula is as follows:

[0047]

[0048] Among them, Sl represents a set that contains the indexes of all positive samples, x i Represents the pixel value in the predicted segmentation map, y i Represents the pixel value in the ground truth segmentation map.

[0049] L b The purpose of using diceloss is to minimize the difference between the predicted segmentation map and the true segmentation map, thereby improving the segmentation accuracy of the model. Its expression is as follows:

[0050]

[0051] Among them, x i Represents the pixel value in the predicted segmentation map, y i represents the pixel value in the true segmentation map (ground truth), and S is the set of all pixels.

[0052] Lt uses L1 loss to quantify the gap between the predicted threshold map and the true threshold, and further refines the adaptability of the model to different Dongba text area thresholds. Its expression is:

[0053]

[0054] Among them, Rd represents the area between the original text box and the expanded text box. is the threshold map label, is the predicted threshold map.

[0055] S6: Send the Dongba script image to be detected to the trained SwinTransformer-based Dongba script detection model obtained in step S5 for detection, and obtain the detection result of the Dongba script image to be detected.

[0056] The recall rate R (recall), precision rate P (precision) and harmonic mean F-measure are used as evaluation indicators of Dongba script detection to illustrate the effect of the present invention:

[0057] Recall R (recall) represents the proportion of the ground truth content that is detected, and is calculated as follows. Precision P (precision) is the proportion of the detected text that is correct, and is calculated as follows. The harmonic mean F-measure combines precision and recall, and is calculated as follows:

[0058]

[0059] Among them, TP represents the total number of text regions correctly predicted by the model, FP represents the total number of text regions incorrectly predicted, and FN represents the total number of text regions that cannot be predicted.

[0060] Table 1 is a comparison table of Precision, Recall and F-measure of different methods. As can be seen from Table 1, the proposed method has improved Precision, Recall and F-measure compared with the classic MaskRCNN, TextSnake, PSENet and DBNet networks.

[0061] Table 1 Comparison of Precision, Recall and F-measure of different methods

[0062]

[0063]

[0064] Note: The bold indicates the best value in each column

[0065] As can be seen from Table 1, the network architecture introduced in this article has achieved an excellent performance of more than 80% in terms of Precision, Recall and F-measure, which are 84.29%, 81.23% and 82.73% respectively, showing its performance advantage. High Precision indicates that the model has a high proportion of correct objects in the identified objects, reducing misidentification; high Recall indicates that the model can identify most of the real positive samples, reducing missed identification. A high value of F-measure means that the model maintains a high integrity while maintaining a high accuracy, balancing the relationship between Precision and Recall.

[0066] Figure 7 The detection results of different methods are shown in Figure 2. Figure 7 It can be seen that compared with MaskRCNN, TextSnake, PSENet and DBNet, the detection effect of this method is close to the real label, and it can completely detect the Dongba script in the image.

Claims

1. A Dongba script detection method based on Swin Transformer, characterized in that: The following steps are involved: Step 1: Collect Dongba script images and build a Dongba script dataset; Step 2: Divide the Dongba script images into training set and test set, and perform data enhancement processing; Step 3: Build a Dongba script detection model based on Swin Transformer; Step 4: Input the training set into the Dongba script detection model in step 3 for training, and obtain a trained Dongba script detection model based on SwinTransformer; Step 5: Send the image containing Dongba characters to be detected into the trained Dongba character detection model based on SwinTransformer obtained in step 4, perform text detection, and output Dongba characters.

2. The Dongba script detection method based on Swin Transformer according to claim 1, characterized in that: The Swin Transformer-based Dongba script detection model includes 1 Swin Transformer module, 2 FPEM modules, 1 addition layer, 1 concatenation layer and 1 post-processing module; The output segment of the input image is connected to the input end of the Swin Transformer module, the output end of the Swin Transformer module is connected to the input end of the first FPEM module, the output end of the first FPEM module is connected to the input end of the second FPEM module, the output end of the second FPEM module is connected to the input end of the addition module, the output end of the addition module is connected to the input end of the splicing layer, the output end of the splicing layer is connected to the input end of the differentiable binarization module, and the output end of the differentiable binarization module is used as the output end of the model.

3. The Dongba script detection method based on Swin Transformer according to claim 2, characterized in that: The FPEM module consists of 6 addition layers, the output terminals F2, F3, F4, and C5 of the Swin Transformer module form the input terminals of the FPEM module, the input terminals C5 and F4 form the input terminals of the first addition layer, the output terminals C4 and F3 of the first addition layer are connected to the input terminals of the second addition layer, the output terminals C3 and F2 of the second addition layer are connected to the input terminals of the third addition layer, the output terminals C2 and C3 of the third addition layer are connected to the input terminals of the fourth addition layer, the output terminals C3_1 and C4 of the fourth addition layer are connected to the fifth addition layer, the output terminals C4_1 and C5 of the fifth addition layer are connected to the input terminals of the sixth addition layer, and the output terminals C5_1, C4_1, C3_1, and C2 of the sixth addition layer serve as the output terminals of the FPEM module.

4. The Dongba script detection method based on Swin Transformer according to claim 2 is characterized in that: The four output ends of the first FPEM module form the four input ends of the second FPEM module, the four output ends of the first FPEM module and the four output ends of the second FPEM module form the input end of the addition layer, and the four output ends of the addition layer are connected to obtain one output end through the splicing layer.

5. The Dongba script detection method based on Swin Transformer according to claim 2 is characterized in that: The post-processing module consists of 2 3×3 convolutional layers, 4 batch normalization layers, 4 deconvolutional layers, 1 Sigmoid function, and 1 differentiable binarization operation; The output of the concatenation layer forms the input of the post-processing module. The input forms two branches. The first branch forms the input of the first 3×3 convolutional layer. The output of the first 3×3 convolutional layer is connected to the input of the first batch normalization layer. The output of the first batch normalization layer is connected to the input of the first deconvolution layer. The output of the first deconvolution layer is connected to the input of the second batch normalization layer. The output of the second batch normalization layer is connected to the input of the second deconvolution layer. The output of the second deconvolution layer is connected to the input of the Sigmoid function. The output P of the function is connected to the input of the differentiable binarization; the second branch forms the input of the second 3×3 convolutional layer, the output of the second 3×3 convolutional layer is connected to the input of the third batch normalization layer, the output of the third batch normalization layer is connected to the input of the third deconvolution layer, the output of the third deconvolution layer is connected to the input of the fourth batch normalization layer, the output of the fourth batch normalization layer is connected to the input of the fourth deconvolution layer, the output T of the fourth deconvolution layer is connected to the input of the differentiable binarization, and the output of the differentiable binarization forms the output of the post-processing module.

Citation Information

Patent Citations

  • Image double-pyramid multivariate feature extraction network, image segmentation method, system and medium

    CN113537004A

  • Target detection method and system based on attention mechanism and feature cross fusion

    CN115035361A

  • Construction method of double-branch remote sensing image defogging network

    CN115578280A

  • Character detection method, character detection model training method, character detection model training device, character detection model training system and readable storage medium

    CN116206313A

  • Chart attached drawing processing method and device and electronic equipment

    CN116246136A