Text detection model training method, device, apparatus, and medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU SHIYUAN ELECTRONICS CO LTD
- Filing Date
- 2022-03-10
- Publication Date
- 2026-08-07
AI Technical Summary
然而,在生成label时,现有的文本行kernel mask(核标记)生成方式在对文本框尺寸较小的文本进行缩放时,容易出现kernel消失的情况,导致文本检测模型无法对这部分尺寸较小的文本进行训练,降低了文本检测模型的对小尺寸文本的泛化能力
Smart Images

Figure CN116777928B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and for example to a method, apparatus, device, and medium for training a text detection model. Background Technology
[0002] With the development of computer technology, text detection is being applied in an increasing number of image processing scenarios. To improve the accuracy of text detection, existing technologies typically employ text segmentation methods to distinguish between adjacent lines of text. During text segmentation, the prediction of text line kernels can be introduced to locate the text lines. However, when generating labels, existing methods for generating text line kernel masks are prone to kernel disappearance when scaling text with small text boxes. This prevents text detection models from being trained on these smaller texts, reducing the model's generalization ability to small-sized text. Summary of the Invention
[0003] The purpose of this application is to provide a training method, apparatus, device, and medium for a text detection model, which can improve the generalization ability of the text detection model to text of different sizes, thereby improving the accuracy of text detection.
[0004] To achieve the above objectives, this application adopts the following technical solution:
[0005] This paper presents a training method for a text detection model, including:
[0006] Obtain an initial image containing the text to be detected, and generate a corresponding text box for the text to be detected to obtain a text box image;
[0007] The text box image is subjected to a first image shrinking process, and a first kernel marker is generated for each text box to obtain a first mask image;
[0008] The text box image is subjected to a second image shrinking process, and a second kernel marker is generated for each text box to obtain a second mask image. The scaling factor of the first image shrinking process and the second image shrinking process are different.
[0009] The maximum value of each pixel in the first mask image and the second mask image is selected to obtain the target mask image, and the target mask image is input into the text detection model to be trained for model training.
[0010] This application also provides a training device for a text detection model, comprising:
[0011] The image acquisition unit is used to acquire an initial image containing the text to be detected, and generate a corresponding text box for the text to be detected, thereby obtaining a text box image;
[0012] The first shrinking unit is used to perform a first image shrinking process on the text box image, and generate a first kernel marker for each text box to obtain a first mask image.
[0013] The second shrinking unit is used to perform a second image shrinking process on the text box image, generate a second kernel marker for each text box, and obtain a second mask image, wherein the scaling factor of the first image shrinking process and the second image shrinking process are different;
[0014] The model training unit is used to select the maximum value of each pixel in the first mask image and the second mask image to obtain the target mask image, and input the target mask image into the text detection model to be trained for model training.
[0015] This application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the training method for a text detection model as described in any of the above claims and / or the steps of the training method for a text detection model as described in any of the above claims.
[0016] This application also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the training method for a text detection model as described in any of the preceding claims and / or the steps of the training method for a text detection model as described in any of the preceding claims.
[0017] This application discloses a training method for a text detection model. Preliminary text segmentation is achieved by generating text boxes from an initial image. By obtaining kernel labels for the text boxes at different scaling factors, suitable kernel labels are generated for text boxes of different sizes in the image. Based on a first and second mask image containing kernel labels of different sizes, the maximum value of each pixel is selected, maximizing the kernel label region of the text boxes in the target mask image. This avoids the situation where small-sized text boxes disappear during scaling, improving the generalization ability of the text detection model for text of different sizes, enhancing the detection capability of the text detection model, and thus improving the accuracy of text detection. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating a training method for a text detection model according to one embodiment.
[0019] Figure 2 This is a schematic diagram of a shrink processing method according to one embodiment;
[0020] Figure 3 This is a schematic diagram of the training device structure for a text detection model according to an embodiment;
[0021] Figure 4 This is a schematic block diagram of the structure of a computer device according to one embodiment.
[0022] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0024] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this specification means the presence of features, integers, steps, operations, elements, modules, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, modules, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any modules and all combinations of one or more associated listed items.
[0025] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0026] Reference Figure 1 This is a flowchart illustrating a training method for a text detection model disclosed in this scheme, including:
[0027] S1: Obtain an initial image containing the text to be detected, and generate a corresponding text box for the text to be detected to obtain a text box image;
[0028] S2: Perform a first image shrinkage process on the text box image, and generate a first kernel marker for each text box to obtain a first mask image;
[0029] S3: Perform a second image shrinkage process on the text box image, generate a second kernel marker for each text box, and obtain a second mask image, wherein the scaling factor of the first image shrinkage process and the second image shrinkage process are different;
[0030] S4: Select the maximum value of each pixel in the first mask image and the second mask image to obtain the target mask image, and input the target mask image into the text detection model to be trained for model training.
[0031] As described in step S1 above, the initial image is an image containing several lines of text to be detected. After obtaining the initial image, a convolutional neural network can be used to generate corresponding text boxes for the text to be detected. In the actual detection process, the size, spacing, and arrangement of the text to be detected in the initial image may vary. Therefore, the generated text boxes also vary in size according to the text to be detected. If the image segmentation method in the prior art is used, when there are small text boxes in the input image, if the shrinkage coefficient is large, the small text boxes may be eliminated, causing the text detection model to be unable to train on this part of the data, thereby affecting the model's generalization performance for small-sized text. The purpose of this embodiment is to improve the model's generalization ability in the case of text boxes of different sizes.
[0032] As described in step S2 above, the text box image is subjected to a first image shrinkage process to obtain a single-channel rectangle with the same size as the original text box image, namely the first mask image kernel mask map. In the first mask image, each text box corresponds to a first kernel marker. The first kernel marker is marked by using a first identifier for text areas and a second identifier for non-text areas. In specific implementations, the first identifier is usually 1 and the second identifier is usually 0.
[0033] As described in step S3 above, the text box image is subjected to a second image shrinkage process with different scaling factors to obtain a single-channel rectangle with the same size as the original text box image, namely the second mask image kernel mask map. At this time, although the size of the first mask image and the second mask image is the same, the scaling ratio of the kernel markers corresponding to the text boxes is different. In the second mask image, each text box corresponds to a second kernel marker. The marking method of the second kernel marker is to use a first identifier to mark the text area and a second identifier to mark the non-text area. In a specific implementation, the first identifier is usually 1 and the second identifier is usually 0.
[0034] As described in step S4 above, after obtaining the first and second mask images with different scaling factors, the text boxes at the same position in the two mask images are compared, and the maximum value is selected pixel by pixel to obtain the target mask image. The specific method for selecting the maximum value pixel by pixel is as follows: the corresponding identifiers of the pixels in the two mask images are compared in turn. If the current pixel in one mask image is the first identifier, that is, marked as a text area, and the current pixel in the other mask image is the second identifier, that is, a non-text area, then the pixel is selected as the first identifier, that is, finally marked as the first identifier, thereby maximizing the selection of the text area and avoiding the situation where small text boxes are cleared after shrinking.
[0035] In summary, preliminary text segmentation was achieved by generating text boxes from the initial image. By obtaining kernel labels for the text boxes at different scaling factors, it was ensured that appropriate kernel labels could be generated for text boxes of different sizes in the image. Based on the first and second mask images containing kernel labels of different sizes, the maximum value of each pixel was selected, which maximized the kernel label region of the text boxes in the target mask image. This avoided the situation where small-sized text boxes disappeared directly during scaling, improved the generalization ability of the text detection model to text of different sizes, enhanced the detection capability of the text detection model, and thus improved the accuracy of text detection.
[0036] In one embodiment, the step of performing a first image shrinking process on the text box image and generating a first kernel marker for each text box to obtain a first mask image includes:
[0037] In the text box image, the pixels inside the text box are marked as 1, and the pixels outside the text box are marked as 0. The marked text box image is then shrunk according to the first scaling factor to obtain the first kernel mark.
[0038] The first mask image is obtained based on the first kernel marker of each of the text boxes.
[0039] As mentioned above, refer to Figure 2 This is a schematic diagram of a shrinking process provided in this embodiment, and the specific shrinking method is as follows:
[0040]
[0041] Among them, b o For the outer border, b s denoted as the inner border, m as the number of pixels the outer border shrinks inward, Area as the area, r as a decimal between [0, 1), and Perimeter as the side length.
[0042] The size of the first mask image is the same as the original text box image. The text box area is shrunk using the first scaling factor as the shrinkage rate. Under the first kernel mark, the text area is marked as 1 and the non-text area is marked as 0. The shrink operation shrinks inward, making the outer area marked as 1 become 0. The purpose is to facilitate the differentiation of adjacent text boxes that are too close together. After shrinking, the relative distance between adjacent text boxes in the first mask image will be increased, avoiding the situation of text sticking together.
[0043] In one embodiment, the step of performing a second image shrinking process on the text box image and generating a second kernel marker for each text box to obtain a second mask image includes:
[0044] In the text box image, the pixels inside the text box are marked as 1, and the pixels outside the text box are marked as 0. The marked text box image is then shrunken according to the second scaling factor to obtain the second kernel mark, wherein the second scaling factor is less than the first scaling factor.
[0045] The second mask image is obtained based on the second core marker of each of the text boxes.
[0046] As described above, in this embodiment, the method of shrinking the marked text box image according to the second scaling factor is the same as that provided in the above embodiment, that is, the following formula is also used for shrinking:
[0047]
[0048] The dimensions of the second mask image are the same as the original text box image and the first mask. Figure 1The text box area is shrunk using a second scaling factor. Generally, the second scaling factor is smaller than the first scaling factor, so the text area shrunk under the second scaling factor will be larger than the text area shrunk under the first scaling factor. The ratio of the second scaling factor to the first scaling factor can be adjusted according to the actual application so that the text area that is eliminated after shrinking under the first scaling factor will not be eliminated after shrinking under the second scaling factor.
[0049] In one embodiment, the step of selecting the maximum value of each pixel in the first mask image and the second mask image to obtain the target mask image includes:
[0050] Obtain the target size of the training samples of the text detection model;
[0051] The first mask image is resized based on the target size to obtain the first target mask image;
[0052] The second mask image is resized based on the target size to obtain the second target mask image;
[0053] The target mask image is obtained by selecting the maximum value pixel by pixel from the first target mask image and the second mask image.
[0054] As mentioned above, in order to improve the comprehensiveness of training samples, the images selected in the training of the text detection model may include initial images from different sources, with different resolutions and sizes. To facilitate the training of the text detection model, this embodiment resizes the mask image that is the same size as the initial image. The above-mentioned resize process is a scaling process that readjusts the size. After the resize process, a first target mask image and a second target mask image with the same size as the target image are obtained. The maximum value is selected pixel by pixel based on the first target mask image and the second target mask image that are the same size as the target image to obtain a target mask image that maximizes the text region, so as to facilitate the data training of the text detection model.
[0055] In one embodiment, resizing the first mask image based on the target size to obtain the first target mask image includes:
[0056] The first target mask image is obtained by performing linear interpolation calculation on the first mask image using a bilinear interpolation algorithm.
[0057] The step of resizing the second mask image based on the target size to obtain the second target mask image includes:
[0058] The second target mask image is obtained by performing linear interpolation calculation on the second mask image using a bilinear interpolation algorithm.
[0059] As mentioned above, when the size of the initial image is larger than the target size required by the text detection model, the bilinear interpolation algorithm can be used for image reduction. The image scaled by this algorithm has high quality, overcomes the problem of discontinuous gray values in nearest neighbor interpolation, and improves the smoothness of the scaled image.
[0060] In one embodiment, the step of performing linear interpolation calculation on the first mask image using a bilinear interpolation algorithm to obtain the first target mask image includes:
[0061] Perform unilinear interpolation along the X-axis of the first mask image to obtain the first interpolation point;
[0062] Based on the first interpolation point, a single linear interpolation is performed in the Y-axis direction of the first mask image to obtain a linear interpolation point, and the first target mask image is obtained based on the linear interpolation point.
[0063] As described above, firstly, four pixels of the area to be scaled are selected, forming a rectangle. Linear interpolation is performed along the X direction of this rectangle to obtain first interpolation points R1 and R2. Then, linear interpolation is performed along the Y direction of this rectangle to obtain linear interpolation point P. The above calculation steps are then performed on the remaining pixels to obtain the first target mask image. The calculation method for the second target mask image is the same as that for the first target mask image, so it will not be described in detail here.
[0064] In one embodiment, the step of selecting the maximum value of each pixel in the first mask image and the second mask image to obtain a target mask image, and inputting the target mask image into the text detection model to be trained for model training, includes:
[0065] Identify whether the number of target kernel markers in the target mask image is the same as the number of text boxes in the text box image;
[0066] If they are not the same, the text box images are subjected to a third image shrinking process, and a third kernel marker is generated for each text box to obtain a third mask image. The scaling factor of the third image shrinking process is smaller than the scaling factor of the second image shrinking process and the second image shrinking process.
[0067] The maximum value of each pixel in the first mask image, the second mask image, and the third mask image is selected to obtain a new target mask image;
[0068] The system identifies whether the number of target kernel markers in the new target mask image is the same as the number of text boxes in the text box image. If they are the same, the new target mask image is input into the text detection model to be trained for model training.
[0069] As described above, after selecting the maximum value for each pixel in the first and second mask images, the target mask image contains a target kernel mask that should simultaneously include the text regions corresponding to the first and second kernel marks. If the number of target kernel masks is less than the number of text boxes in the original image, it means that some text boxes are still eliminated due to their small size during the shrinking process. In this case, the above image shrinking process can be repeated after further reducing the second scaling factor, or a smaller third scaling factor can be set to shrink the text box image until the number of target kernel masks in the target mask image is the same as the number of text boxes in the original image, that is, no text boxes that are too small are removed due to scaling.
[0070] Reference Figure 3 This is a block diagram of a training device for a text detection model disclosed in this scheme. The device includes:
[0071] The image acquisition unit 100 is used to acquire an initial image containing the text to be detected, and generate a corresponding text box for the text to be detected to obtain a text box image;
[0072] The first shrinking unit 200 is used to perform a first image shrinking process on the text box image, and generate a first kernel marker for each text box to obtain a first mask image.
[0073] The second shrinking unit 300 is used to perform a second image shrinking process on the text box image, generate a second kernel marker for each text box, and obtain a second mask image, wherein the scaling factor of the first image shrinking process and the second image shrinking process are different.
[0074] The model training unit 400 is used to select the maximum value of each pixel in the first mask image and the second mask image to obtain a target mask image, and input the target mask image into the text detection model to be trained for model training.
[0075] In one embodiment, the first contraction unit 200 is specifically used for:
[0076] In the text box image, the pixels inside the text box are marked as 1, and the pixels outside the text box are marked as 0. The marked text box image is then shrunk according to the first scaling factor to obtain the first kernel mark.
[0077] The first mask image is obtained based on the first kernel marker of each of the text boxes.
[0078] In one embodiment, the second shrinking unit 300 is specifically used for:
[0079] In the text box image, the pixels inside the text box are marked as 1, and the pixels outside the text box are marked as 0. The marked text box image is then shrunken according to the second scaling factor to obtain the second kernel mark, wherein the second scaling factor is less than the first scaling factor.
[0080] The second mask image is obtained based on the second core marker of each of the text boxes.
[0081] In one embodiment, the model training unit 400 is specifically used for:
[0082] Obtain the target size of the training samples of the text detection model;
[0083] The first mask image is resized based on the target size to obtain the first target mask image;
[0084] The second mask image is resized based on the target size to obtain the second target mask image;
[0085] The target mask image is obtained by selecting the maximum value pixel by pixel from the first target mask image and the second mask image.
[0086] In one embodiment, the model training unit 400 is specifically used for:
[0087] The first target mask image is obtained by performing linear interpolation calculation on the first mask image using a bilinear interpolation algorithm.
[0088] The second target mask image is obtained by performing linear interpolation calculation on the second mask image using a bilinear interpolation algorithm.
[0089] In one embodiment, the model training unit 400 is specifically used for:
[0090] Perform unilinear interpolation along the X-axis of the first mask image to obtain the first interpolation point;
[0091] Based on the first interpolation point, a single linear interpolation is performed in the Y-axis direction of the first mask image to obtain a linear interpolation point, and the first target mask image is obtained based on the linear interpolation point.
[0092] In one embodiment, the model training unit 400 is specifically used for:
[0093] Identify whether the number of target kernel markers in the target mask image is the same as the number of text boxes in the text box image;
[0094] If they are not the same, the text box images are subjected to a third image shrinking process, and a third kernel marker is generated for each text box to obtain a third mask image. The scaling factor of the third image shrinking process is smaller than the scaling factor of the second image shrinking process and the second image shrinking process.
[0095] The maximum value of each pixel in the first mask image, the second mask image, and the third mask image is selected to obtain a new target mask image;
[0096] The system identifies whether the number of target kernel markers in the new target mask image is the same as the number of text boxes in the text box image. If they are the same, the new target mask image is input into the text detection model to be trained for model training.
[0097] Reference Figure 4 This application also provides a computer device whose internal structure can be as follows: Figure 4 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor is designed to provide computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores operating devices, computer programs, and the database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores training data for text detection models, etc. The network interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for training a text detection model.
[0098] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer equipment on which the present application is applied.
[0099] One embodiment of this application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a method for training a text detection model. It is understood that the computer-readable storage medium in this embodiment can be a volatile readable storage medium or a non-volatile readable storage medium.
[0100] This application discloses a training method, apparatus, device, and medium for a text detection model. It achieves preliminary text segmentation by generating text boxes from an initial image. By obtaining kernel labels for the text boxes at different scaling factors, it ensures that appropriate kernel labels can be generated for text boxes of different sizes in the image. Based on a first mask and a second mask containing kernel labels of different sizes, it selects the maximum value for each pixel, maximizing the kernel label region of the text boxes in the target mask. This avoids small-sized text boxes disappearing during scaling, improves the generalization ability of the text detection model for text of different sizes, enhances the detection capability of the text detection model, and thus improves the accuracy of text detection.
[0101] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media provided in this application and in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-speed SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0102] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0103] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A training method for a text detection model, characterized in that, include: Obtain an initial image containing the text to be detected, and generate a corresponding text box for the text to be detected to obtain a text box image; The text box images are subjected to a first image shrinkage process, and a first kernel marker is generated for each text box to obtain a first mask image; the formula for the first image shrinkage process is: in, b o For the outer border, m Here, represents the number of pixels the outer border shrinks inward, and Area represents the area. r It is a decimal between [0, 1), and Perimeter is the side length; The text box image is subjected to a second image shrinking process, and a second kernel marker is generated for each text box to obtain a second mask image. The scaling factor of the first image shrinking process and the second image shrinking process are different. The maximum value is selected for each pixel in the first mask image and the second mask image to obtain a target mask image, which is then input into the text detection model to be trained for model training. If the number of target kernel markers in the target mask image is not the same as the number of text boxes in the text box image, the text box image undergoes a third image shrinkage process to obtain a third mask image. The scaling factor of the third image shrinkage process is simultaneously less than the scaling factors of the second image shrinkage process and the third image shrinkage process. After selecting the maximum value for each pixel in the first mask image, the second mask image, and the third mask image, if the number of kernel markers in the new target mask image is still not the same, the third image shrinkage process and fusion steps are repeated until the number of kernel markers in the target mask image is the same.
2. The training method for the text detection model according to claim 1, characterized in that, The step of performing a first image shrinking process on the text box image, generating a first kernel marker for each text box, and obtaining a first mask image includes: In the text box image, the pixels inside the text box are marked as 1, and the pixels outside the text box are marked as 0. The marked text box image is then shrunk according to the first scaling factor to obtain the first kernel mark. The first mask image is obtained based on the first kernel marker of each of the text boxes.
3. The training method for the text detection model according to claim 2, characterized in that, The step of performing a second image shrinking process on the text box image, generating a second kernel marker for each text box, and obtaining a second mask image includes: In the text box image, the pixels inside the text box are marked as 1, and the pixels outside the text box are marked as 0. The marked text box image is then shrunken according to the second scaling factor to obtain the second kernel mark, wherein the second scaling factor is less than the first scaling factor. The second mask image is obtained based on the second core marker of each of the text boxes.
4. The training method for the text detection model according to claim 1, characterized in that, The step of selecting the maximum value of each pixel in the first mask image and the second mask image to obtain the target mask image includes: Obtain the target size of the training samples of the text detection model; The first mask image is resized based on the target size to obtain the first target mask image; The second mask image is resized based on the target size to obtain the second target mask image; The target mask image is obtained by selecting the maximum value pixel by pixel from the first target mask image and the second mask image.
5. The training method for the text detection model according to claim 4, characterized in that, The step of resizing the first mask image based on the target size to obtain the first target mask image includes: The first target mask image is obtained by performing linear interpolation calculation on the first mask image using a bilinear interpolation algorithm. The step of resizing the second mask image based on the target size to obtain the second target mask image includes: The second target mask image is obtained by performing linear interpolation calculation on the second mask image using a bilinear interpolation algorithm.
6. The training method for the text detection model according to claim 5, characterized in that, The step of performing linear interpolation calculation on the first mask image using a bilinear interpolation algorithm to obtain the first target mask image includes: Perform unilinear interpolation along the X-axis of the first mask image to obtain the first interpolation point; Based on the first interpolation point, a single linear interpolation is performed in the Y-axis direction of the first mask image to obtain a linear interpolation point, and the first target mask image is obtained based on the linear interpolation point.
7. The training method for the text detection model according to claim 1, characterized in that, The step of selecting the maximum value of each pixel in the first mask image and the second mask image to obtain a target mask image, and inputting the target mask image into the text detection model to be trained for model training, includes: Identify whether the number of target kernel markers in the target mask image is the same as the number of text boxes in the text box image; If they are not the same, the text box images are subjected to a third image shrinking process, and a third kernel marker is generated for each text box to obtain a third mask image; The maximum value of each pixel in the first mask image, the second mask image, and the third mask image is selected to obtain a new target mask image; The system identifies whether the number of target kernel markers in the new target mask image is the same as the number of text boxes in the text box image. If they are the same, the new target mask image is input into the text detection model to be trained for model training.
8. A training device for a text detection model, characterized in that, include: The image acquisition unit is used to acquire an initial image containing the text to be detected, and generate a corresponding text box for the text to be detected, thereby obtaining a text box image; The first shrinking unit is used to perform a first image shrinking process on the text box images, generating a first kernel marker for each text box to obtain a first mask image; the formula for the first image shrinking process is: in, b o For the outer border, m Where is the number of pixels the outer border shrinks inward, and Area is the area. r It is a decimal between [0, 1), and Perimeter is the side length; The second shrinking unit is used to perform a second image shrinking process on the text box image, generate a second kernel marker for each text box, and obtain a second mask image, wherein the scaling factor of the first image shrinking process and the second image shrinking process are different; The model training unit is used to select the maximum value of each pixel in the first mask image and the second mask image to obtain a target mask image, and input the target mask image into the text detection model to be trained for model training; wherein, if the number of target kernel markers in the target mask image is not the same as the number of text boxes in the text box image, the text box image is subjected to a third image shrinking process to obtain a third mask image, wherein the scaling factor of the third image shrinking process is simultaneously less than the scaling factor of the second image shrinking process and the second image shrinking process; after selecting the maximum value of each pixel in the first mask image, the second mask image, and the third mask image, if the number of kernel markers in the new target mask image is still not the same, the third image shrinking process and fusion steps are repeated until the number of kernel markers in the target mask image is the same.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the training method for the text detection model according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the training method for the text detection model according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method for detecting text in natural scene with robust shape
CN110008950A