A text information processing method, device and equipment and readable storage medium
By constructing a text mask in the initial image and removing invalid text boxes, the problem of inaccurate text box information during the cropping process is solved, ensuring the effective training and detection performance of the text detection model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU SHIYUAN ELECTRONICS CO LTD
- Filing Date
- 2022-04-14
- Publication Date
- 2026-06-05
AI Technical Summary
In the data processing stage of deep learning text detection algorithms, the cropping process may result in redundant or missing text box information, leading to the introduction of training errors in the text detection model and affecting detection performance.
An initial image with the same size as the text image to be processed is generated. A text mask is constructed based on the attribute information of the labeled text boxes to determine the target text boxes. Invalid text boxes are removed and valid text boxes are retained based on the pixel information of the labeled and target text boxes.
Ensuring the accuracy and validity of text box information enabled precise training of the text detection model, thereby improving detection performance.
Smart Images

Figure CN116958975B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text data processing technology, and specifically to a method, apparatus, device, and readable storage medium for processing text information. Background Technology
[0002] In the data processing stage of deep learning text detection algorithms, text cropping is commonly used to enhance text data. However, if there is redundant text box information or valid text lacking text box information during the cropping process, it will introduce errors into the subsequent training of the text detection model, thus affecting the detection performance. Therefore, ensuring that all valid text in the cropping result retains valid text box information and that invalid text does not contain valid text box information has become an urgent technical problem to be solved. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a method, apparatus, device, and readable storage medium for processing text information, in order to solve the problem that it is difficult to guarantee the effective text information and effective text boxes in the cropping result.
[0004] According to a first aspect, embodiments of the present invention provide a method for processing text information, comprising: obtaining an initial image corresponding to a text image to be processed and labeled text boxes of the text image to be processed, wherein the initial image is a single-channel image with a pixel value of 0, and the size information of the initial image is consistent with the size information of the text image to be processed; generating a text mask corresponding to multiple labeled text boxes in the initial image based on the attribute information of the labeled text boxes, and determining multiple target text boxes corresponding to the text mask; and removing invalid text boxes corresponding to invalid text information based on the pixel information of the labeled text boxes and the target text boxes, thereby obtaining valid text information and its corresponding valid text boxes in the text image to be processed.
[0005] The text information processing method provided in this invention initializes a single-channel image with the same size as the text image to be processed and a pixel value of 0. Based on the labeled text boxes in the text image, a corresponding text mask is constructed in the initialized image to determine the target text boxes corresponding to multiple labeled text boxes. Then, based on the pixel information of the labeled text boxes and the target text boxes, the text box information to be retained or removed is determined. This method ensures the accuracy and effectiveness of the text box information, achieves effective processing of text data, and thus guarantees the accurate training of the subsequent text detection model.
[0006] In conjunction with the first aspect, in a first embodiment of the first aspect, generating a text mask corresponding to multiple labeled text boxes in the initialization image based on the attribute information of the labeled text boxes, and determining multiple target text boxes corresponding to the text mask, includes: obtaining the labeling order and text box coordinate information of the labeled text boxes; generating a text mask in the initialization image based on the labeling order and the text box coordinate information, wherein the pixel value of the text mask is the labeling order number of the labeled text boxes; and determining multiple target text boxes in the initialization image based on the text mask.
[0007] The text information processing method provided in this invention constructs a corresponding text mask in an initialized image by annotating the text boxes according to their annotation order and coordinate information. Multiple target text boxes in the initialized image can then be determined based on this text mask. This method uses the text mask generation method to assist in determining whether the cropped text image to be processed contains valid text, facilitating accurate acquisition of text box information.
[0008] In conjunction with the first aspect, in the second embodiment of the first aspect, the step of removing invalid text boxes corresponding to invalid text information based on the pixel information of the labeled text box and the target text box to obtain the valid text information and its corresponding valid text boxes in the text image to be processed includes: obtaining the first pixel count of the labeled text box and the second pixel count of the target text box; calculating the ratio between the first pixel count and the second pixel count; determining whether the ratio is less than a preset threshold; when the ratio is less than the preset threshold, determining that the text information in the labeled text box is invalid text information; removing all invalid text boxes corresponding to the invalid text information to obtain the valid text information and its corresponding valid text boxes in the text image to be processed.
[0009] The text information processing method provided in this invention calculates the ratio between the number of first pixels in the labeled text box and the number of second pixels in the target text box. When this ratio is less than a preset threshold, the text information in the labeled text box is determined to be invalid. All text boxes are traversed to remove all invalid text boxes corresponding to invalid text information, thus obtaining the valid text information and its corresponding valid text boxes in the text image to be processed. The preset threshold in this method is adjustable, which can meet different model training requirements, thereby accurately identifying valid text box information.
[0010] In conjunction with the first aspect, in the third embodiment of the first aspect, the method further includes: obtaining the boundary information of the labeled text box; determining, based on the boundary information, text boxes from the text image to be processed that do not intersect with the labeled text box; determining the text boxes that do not intersect with the labeled text box as invalid text boxes; and removing the invalid text boxes.
[0011] The text information processing method provided in this embodiment of the invention determines text boxes that do not intersect with the marked text boxes by the boundary relationship between the marked text boxes and the text image to be processed. That is, it determines invalid text boxes outside the area where the marked text boxes are located and removes the invalid text boxes, thereby ensuring that there is no redundant text box information outside the marked text boxes and further ensuring the accuracy of the text box information.
[0012] In conjunction with the first aspect, in the fourth embodiment of the first aspect, obtaining the annotation text boxes of the text image to be processed includes: cropping the text image to be processed according to preset conditions to obtain a cropped image; determining multiple text boxes with pixel values greater than 0 from the cropped image; and determining the multiple text boxes as the annotation text boxes.
[0013] The text information processing method provided in this embodiment of the invention crops the text image to be processed according to actual needs, and determines multiple labeled text boxes with pixel values greater than 0 from the cropped image. This can meet the training scenarios of different detection models and make the determination of labeled text boxes more flexible.
[0014] In conjunction with the fourth embodiment of the first aspect, in the fifth embodiment of the first aspect, the method further includes: cropping the initial image according to the cropping area corresponding to the cropped image.
[0015] The text information processing method provided in this embodiment of the invention crops the initial image according to the cropping area corresponding to the cropped image, so as to ensure that the initial image and the image to be processed are consistent, thus maximizing the accuracy of the text box information.
[0016] In conjunction with the first aspect or any one of the first to fifth embodiments of the first aspect, in a certain embodiment of the first aspect, the method further includes: determining the valid text box data containing the valid text information as valid training data.
[0017] The text information processing method provided in this embodiment of the invention determines the valid text box data containing valid text information as valid training data to train the text detection model, thereby ensuring the detection performance of the text detection model.
[0018] According to a second aspect, embodiments of the present invention provide a text information processing apparatus, comprising: an acquisition module, configured to acquire an initial image corresponding to a text image to be processed and labeled text boxes of the text image to be processed, wherein the initial image is a single-channel image with a pixel value of 0, and the size information of the initial image is consistent with the size information of the text image to be processed; a generation module, configured to generate a text mask corresponding to multiple labeled text boxes in the initial image based on the attribute information of the labeled text boxes, and determine multiple target text boxes corresponding to the text mask; and a rejection module, configured to reject invalid text information and its corresponding invalid text boxes based on the pixel information of the labeled text boxes and the target text boxes, thereby obtaining valid text information and its corresponding valid text boxes in the text image to be processed.
[0019] According to a third aspect, embodiments of the present invention provide an electronic device, including: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the text information processing method described in the first aspect or any embodiment of the first aspect.
[0020] According to a fourth aspect, embodiments of the present invention provide a computer-readable storage medium storing computer instructions for causing a computer to perform the text information processing method described in the first aspect or any embodiment of the first aspect.
[0021] It should be noted that the beneficial effects of the text information processing apparatus, electronic device, and computer-readable storage medium provided in the embodiments of the present invention can be found in the description of the corresponding content in the text information processing method, and will not be repeated here. Attached Figure Description
[0022] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0023] Figure 1 This is a flowchart of a text information processing method according to an embodiment of the present invention;
[0024] Figure 2 This is another flowchart of a text information processing method according to an embodiment of the present invention;
[0025] Figure 3This is yet another flowchart of a text information processing method according to an embodiment of the present invention;
[0026] Figure 4 This is a structural block diagram of a text information processing apparatus according to an embodiment of the present invention;
[0027] Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0029] According to an embodiment of the present invention, an embodiment of a text information processing method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0030] This embodiment provides a method for processing text information, which can be used in electronic devices such as mobile phones, tablets, computers, servers, etc. Figure 1 This is a flowchart of a text information processing method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps:
[0031] S11, obtain the initial image corresponding to the text image to be processed and the annotation text box of the text image to be processed.
[0032] The initial image is a single-channel image with a pixel value of 0, and the size information of the initial image is consistent with the size information of the text image to be processed.
[0033] The text image to be processed contains multiple text boxes and text information. These text boxes and text information are used to train the text detection model. The size information refers to the length and width of the text image to be processed, and this size information is stored in the memory of the electronic device. The electronic device can initialize a single-channel image with zero pixels of the same size as the text image to be processed, based on the length and width information of the text image to be processed. This initialized image corresponds to and is unique to the text image to be processed.
[0034] The labeled text boxes are text box data that users annotate in the text image to be processed, used for model training. Specifically, users can annotate multiple text boxes from the text image to be processed according to actual needs. Correspondingly, the electronic device can respond to the user's annotation operation and determine the labeled text boxes used for model training from the text image to be processed according to the user's annotation order.
[0035] S12, Based on the attribute information of the labeled text boxes, generate text masks corresponding to multiple labeled text boxes in the initialized image, and determine multiple target text boxes corresponding to the text masks.
[0036] The attribute information includes the labeling order of the text boxes and the coordinates of each vertex corresponding to each text box. Of course, the attribute information may also include other information, which is not specifically limited here. The target text box is the text box information corresponding to the label text boxes in the initialized image.
[0037] Specifically, the electronic device can call a preset function to generate text masks for each labeled text box in the initialization image based on the attribute information of the labeled text boxes. For example, the electronic device can use the cv2.drawContours() function to draw the text mask corresponding to each text in the labeled text box in a single-channel image (i.e., the initialization image). Then, the electronic device can determine the target text box corresponding to the labeled text box based on the text mask in the initialization image.
[0038] S13. Based on the pixel information of the labeled text box and the target text box, remove the invalid text boxes corresponding to invalid text information to obtain the valid text information and its corresponding valid text boxes in the text image to be processed.
[0039] Pixel information is used to represent the pixels present in the annotation text box and the target text box. The electronic device compares the pixel information of the annotation text box and the target text box to determine whether the text information is invalid. If the text information is invalid, the text box corresponding to the invalid text information is determined to be invalid and is removed. In this way, all the valid text information in the text image to be processed and the valid text boxes corresponding to the valid text information can be obtained.
[0040] The text information processing method provided in this embodiment initializes a single-channel image with the same size as the text image to be processed and a pixel value of 0. Based on the labeled text boxes in the text image, a corresponding text mask is constructed in the initialized image to determine the target text boxes corresponding to multiple labeled text boxes. Then, based on the pixel information of the labeled text boxes and the target text boxes, the text box information to be retained or removed is determined. This method ensures the accuracy and effectiveness of the text box information, achieves effective processing of text data, and thus guarantees the accurate training of the subsequent text detection model.
[0041] This embodiment provides a method for processing text information, which can be used in electronic devices such as mobile phones, tablets, computers, servers, etc. Figure 2 This is a flowchart of a text information processing method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0042] S21, obtain the initial image corresponding to the text image to be processed and the annotation text box of the text image to be processed. The initial image is a single-channel image with a pixel value of 0, and its size information is consistent with the size information of the text image to be processed. For detailed explanation, please refer to the relevant descriptions in the above embodiments, which will not be repeated here.
[0043] S22, Based on the attribute information of the labeled text boxes, generate text masks corresponding to multiple labeled text boxes in the initialized image, and determine multiple target text boxes corresponding to the text masks.
[0044] Specifically, step S22 above may include:
[0045] S221, obtain the annotation order and coordinate information of the annotation text boxes.
[0046] The annotation order refers to the order in which users or technicians annotate the text boxes in the image. That is, for each image, the annotation order is the order in which the text box information is annotated, and this annotation order is stored in the electronic device's memory or storage space. The text box coordinate information refers to the coordinates of the corner points of the text box. Typically, a text box is a rectangle, and the text box coordinate information is the coordinates of the four vertices of the rectangle. The electronic device can construct a coordinate system from the center point of the text image to be processed, and then determine the coordinate information corresponding to each annotated text box based on its position in the text image.
[0047] S222, Based on the annotation order and text box coordinate information, generate a text mask in the initialized image. The pixel value of the text mask is the annotation order number of the annotation text box.
[0048] The electronic device can draw a text mask for each text in the initialized image using the cv2.drawContours() function, based on the annotation information and text box coordinate information. The pixel value of the text mask is the annotation sequence number of each annotated text box in the text image to be processed.
[0049] S223, determine multiple target text boxes in the initialization image based on the text mask.
[0050] The electronic device can determine the region containing text information in the initial image based on the information generated by the text mask, and then determine multiple target text boxes corresponding to the text boxes in the initial image based on the position information of the labeled text boxes in the text image to be processed.
[0051] S23. Based on the pixel information of the labeled text box and the target text box, invalid text information and its corresponding invalid text boxes are removed to obtain the valid text information and its corresponding valid text boxes in the text image to be processed.
[0052] Specifically, step S23 above may include:
[0053] S231, obtain the number of first pixels of the annotation text box and the number of second pixels of the target text box.
[0054] Since the pixel value of the background area of the text box is 0 and the pixel value of the text area is not 0, when calculating the number of the first pixel of the annotation text box, we only need to add up all the pixel values in the area where the annotation text box is located to get the number of the first pixel M.
[0055] Similarly, the pixel value of the text mask is the annotation sequence number of the text box, that is, the pixel value of the text area is not 0. To calculate the number of second pixels, we only need to add up all the pixel values of the text mask to get the number of second pixels N corresponding to the target text box.
[0056] S232, calculate the ratio between the number of first pixels and the number of second pixels.
[0057] After obtaining the number of first pixels M and the number of second pixels N, the electronic device can calculate the ratio R between M and N, i.e., R = M / N. The validity of the current text information is determined by the ratio between the number of first pixels and the number of second pixels.
[0058] S233, determine whether the ratio is less than a preset threshold.
[0059] The preset threshold is a pre-defined minimum ratio used to determine whether text information is valid. The electronic device compares the ratio between the number of first pixels and the number of second pixels with the preset threshold to determine whether the current ratio is less than the preset threshold. If the ratio is less than the preset threshold, step S234 is executed; otherwise, the text information is considered valid, and the text box information of the valid text information is retained.
[0060] S234, the text information in the annotation text box is determined to be invalid text information.
[0061] When the ratio is less than a preset threshold, it indicates that the current text information is invalid. At this time, the electronic device can directly determine that the text information in the current annotation text box is invalid, and its corresponding text box is invalid.
[0062] S235, remove all invalid text information and their corresponding invalid text boxes to obtain the valid text information and their corresponding valid text boxes in the text image to be processed.
[0063] The electronic device iterates through each labeled text box, comparing the ratio between the number of first pixels and the number of second pixels to see if it is less than a preset threshold. When the ratio is less than the preset threshold, the invalid text information and its corresponding invalid text box are removed. This process is repeated to remove all invalid text information and its corresponding invalid text boxes, thereby obtaining the valid text information and the valid text boxes corresponding to the valid text information in the text image to be processed.
[0064] Optionally, the above method may further include:
[0065] S24, obtain the boundary information of the annotation text box.
[0066] The boundary information of the annotation text box can be determined based on the corner coordinates of the area where the annotation text box is located. The electronic device can construct a coordinate system based on the text image to be processed, and determine the corner coordinates corresponding to each annotation text box through the coordinate system. Then, the upper boundary, lower boundary, left boundary and right boundary of the area where the annotation text box is located can be determined based on the corner coordinate information.
[0067] S25, Based on boundary information, determine the text boxes in the text image to be processed that do not intersect with the labeled text boxes.
[0068] Since the text image to be processed still contains text box information that has no intersection with the labeled text box, this text box information is redundant for the labeled text box. In order to avoid this text box information affecting the accuracy of model training, it is necessary to remove this redundant text box information.
[0069] Specifically, the electronic device compares the boundary information of the labeled text box with the text box information in the text image to be processed. Based on the relationship between the right boundary of the text box in the text image to be processed and the left boundary of the labeled text box, the relationship between the left boundary of the text box in the text image to be processed and the right boundary of the labeled text box, the relationship between the top boundary of the text box in the text image to be processed and the bottom boundary of the labeled text box, and the relationship between the bottom boundary of the text box in the text image to be processed and the top boundary of the labeled text box, the electronic device identifies the text boxes in the text image to be processed that do not intersect with the labeled text boxes.
[0070] S26, Text boxes that do not intersect with the annotation text boxes are identified as invalid text boxes.
[0071] After identifying text boxes that have no intersection with the labeled text box, text box information located outside the area of the labeled text box is identified. These text boxes are considered irrelevant and can be deemed invalid by the electronic device.
[0072] S27, Remove invalid text boxes.
[0073] The electronic device removes invalid text box information to prevent it from affecting the training effect of the subsequent text detection model.
[0074] The text information processing method provided in this embodiment uses a text mask generation method to assist in determining whether the cropped text image to be processed contains valid text, facilitating accurate acquisition of text box information. The preset threshold in this method is adjustable to meet different model training needs, thereby accurately identifying valid text box information. By identifying the boundary relationship between the labeled text boxes and the text image to be processed, text boxes that do not intersect with the labeled text boxes are determined, i.e., invalid text boxes outside the area where the labeled text boxes are located are identified and removed. This ensures that there is no redundant text box information outside the labeled text boxes, further guaranteeing the accuracy of the text box information.
[0075] This embodiment provides a method for processing text information, which can be used in electronic devices such as mobile phones, tablets, computers, servers, etc. Figure 3 This is a flowchart of a text information processing method according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps:
[0076] S31, obtain the initial image corresponding to the text image to be processed and the annotation text box of the text image to be processed.
[0077] The initial image is a single-channel image with a pixel value of 0, and the size information of the initial image is consistent with the size information of the text image to be processed.
[0078] Specifically, step S31 above may include:
[0079] S311, Obtain the initialization image corresponding to the text image to be processed. For detailed explanation, please refer to the relevant descriptions in the above embodiments; they will not be repeated here.
[0080] S312, crop the text image to be processed according to preset conditions to obtain a cropped image.
[0081] The preset conditions are the clipping conditions pre-set by the user according to the current model training requirements. For example, the preset conditions can be a rectangular bounding box with a length of L and a width of H. The preset conditions are not specifically limited here, and those skilled in the art can determine them according to actual conditions.
[0082] Specifically, the electronic device can determine the area to be cropped in the text image to be processed according to preset conditions, and then crop the text image to be processed according to the determined cropping area to obtain a cropped image corresponding to the cropping area.
[0083] S313, Identify multiple text boxes from the cropped image whose pixel values are greater than 0.
[0084] The electronic device parses the cropped image to determine its pixel values. Because text boxes and text areas exist, their pixel values will not be zero. The electronic device can determine the areas with pixel values greater than zero based on the cropped image's pixel values, and then identify the various text boxes involved in the cropped image from these areas.
[0085] S314, designate multiple text boxes as annotation text boxes.
[0086] After identifying the multiple different text boxes involved in the cropped image, the electronic device can directly designate the identified text boxes as annotation text boxes.
[0087] Specifically, users can pre-set cropping conditions according to their actual needs. Correspondingly, the electronic device can respond to the user's settings and crop the required area from the text image to be processed based on the user-defined cropping conditions. Then, the electronic device can identify multiple text boxes with pixel values greater than 0 from the cropped area and classify these text boxes as labeled text boxes.
[0088] Optionally, after cropping the image to be processed, the method further includes cropping the initial image according to the cropping area corresponding to the cropped image.
[0089] The electronic device can crop the initial image according to the cropping method of the text image to be processed, and crop the initial image according to the cropping area corresponding to the cropped image, that is, crop the initial image according to the same cropping area as the cropped image.
[0090] By cropping the initial image according to the cropping area corresponding to the cropped image, the consistency between the initial image and the image to be processed is ensured, thus maximizing the accuracy of the text box information.
[0091] S32, based on the attribute information of the labeled text boxes, generate text masks corresponding to multiple labeled text boxes in the initialized image, and determine multiple target text boxes corresponding to the text masks. For detailed explanation, please refer to the relevant descriptions in the above embodiments, which will not be repeated here.
[0092] S33: Based on the pixel information of the labeled text box and the target text box, invalid text information and their corresponding invalid text boxes are removed to obtain the valid text information and their corresponding valid text boxes in the text image to be processed. For detailed explanation, please refer to the relevant descriptions in the above embodiments, which will not be repeated here.
[0093] S34, the valid text box data containing valid text information is determined as valid training data.
[0094] After obtaining valid text information and its corresponding valid text boxes, the electronic device can use the valid text box data containing the valid text information as valid training data for training the model, that is, use the valid text box data as the ground truth for model training. Accurate valid text box data enables effective training of the text detection model. By training the text detection model with valid training data, the detection accuracy of the text detection model is guaranteed to the greatest extent.
[0095] The text information processing method provided in this embodiment crops the text image to be processed according to actual needs, and determines multiple labeled text boxes with pixel values greater than 0 from the cropped image. This can meet the training scenarios of different detection models, making the determination of labeled text boxes more flexible. Valid text box data containing effective text information is determined as valid training data for training the text detection model, ensuring the detection performance of the text detection model.
[0096] This embodiment also provides a text information processing device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0097] This embodiment provides a text information processing device, such as... Figure 4 As shown, it includes:
[0098] The acquisition module 41 is used to acquire the initial image corresponding to the text image to be processed and the annotation text box of the text image to be processed. The initial image is a single-channel image with a pixel value of 0, and its size information is consistent with that of the text image to be processed. For detailed explanation, please refer to the relevant descriptions in the above method embodiments, which will not be repeated here.
[0099] The generation module 42 is used to generate text masks corresponding to multiple labeled text boxes in the initialized image based on the attribute information of the labeled text boxes, and to determine the multiple target text boxes corresponding to the text masks. For detailed explanations, please refer to the relevant descriptions in the above method embodiments, which will not be repeated here.
[0100] The removal module 43 is used to remove invalid text information and its corresponding invalid text boxes based on the pixel information of the labeled text box and the target text box, thereby obtaining the valid text information and its corresponding valid text boxes in the text image to be processed. For detailed explanations, please refer to the relevant descriptions in the above method embodiments, which will not be repeated here.
[0101] The text information processing device provided in this embodiment initializes a single-channel image with the same size as the text image to be processed and a pixel value of 0. Based on the labeled text boxes in the text image, it constructs a corresponding text mask in the initialized image to determine the target text boxes corresponding to multiple labeled text boxes. Then, based on the pixel information of the labeled text boxes and the target text boxes, it determines the text box information to be retained or removed. This device ensures the accuracy and effectiveness of the text box information, achieves effective processing of text data, and thus guarantees the accurate training of the subsequent text detection model.
[0102] In this embodiment, the text information processing device is presented in the form of a functional unit. Here, a unit refers to an ASIC circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0103] Further functional descriptions of the above modules are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0104] This invention also provides an electronic device having the above-described features. Figure 4 The text information processing device shown.
[0105] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in an optional embodiment of the present invention, such as... Figure 5As shown, the device may include: at least one processor 501, such as a CPU (Central Processing Unit), at least one communication interface 503, memory 504, and at least one communication bus 502. The communication bus 502 is used to enable communication between these components. The communication interface 503 may include a display screen or a keyboard; optionally, the communication interface 503 may also include a standard wired interface or a wireless interface. The memory 504 may be high-speed RAM (Random Access Memory) or non-volatile memory, such as at least one disk storage device. Optionally, the memory 504 may also be at least one storage device located remotely from the aforementioned processor 501. The processor 501 may be combined with... Figure 4 The described apparatus has an application program stored in memory 504, and a processor 501 calls the program code stored in memory 504 to perform any of the above method steps.
[0106] The communication bus 502 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The communication bus 502 can be divided into an address bus, a data bus, and a control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0107] The memory 504 may include volatile memory, such as random-access memory (RAM); the memory may also include non-volatile memory, such as flash memory, hard disk drive (HDD) or solid-state drive (SSD); the memory 504 may also include a combination of the above types of memory.
[0108] The processor 501 can be a central processing unit (CPU), a network processor (NP), or a combination of CPU and NP.
[0109] The processor 501 may further include a hardware chip. This hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0110] Optionally, memory 504 is also used to store program instructions. Processor 501 can call the program instructions to implement the functions described in this application. Figures 1 to 3 The text information processing method shown in the embodiment.
[0111] This invention also provides a non-transitory computer storage medium storing computer-executable instructions that can execute the text information processing method in any of the above method embodiments. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium may also include combinations of the above types of memory.
[0112] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for processing text information, characterized in that, include: Obtain the initial image corresponding to the text image to be processed and the annotation text box of the text image to be processed. The initial image is a single-channel image with a pixel value of 0, and the size information of the initial image is consistent with the size information of the text image to be processed. Based on the attribute information of the labeled text boxes, a text mask corresponding to multiple labeled text boxes is generated in the initialization image, and multiple target text boxes corresponding to the text mask are determined. Based on the pixel information of the labeled text box and the target text box, invalid text boxes corresponding to invalid text information are removed to obtain the valid text information and its corresponding valid text boxes in the text image to be processed. This includes: obtaining the number of first pixels in the labeled text box and the number of second pixels in the target text box; calculating the ratio between the number of first pixels and the number of second pixels; determining whether the ratio is less than a preset threshold; when the ratio is less than the preset threshold, determining that the text information in the labeled text box is invalid text information; and removing all invalid text boxes corresponding to the invalid text information to obtain the valid text information and its corresponding valid text boxes in the text image to be processed.
2. The method according to claim 1, characterized in that, Based on the attribute information of the labeled text boxes, a text mask corresponding to multiple labeled text boxes is generated in the initialized image, and the multiple target text boxes corresponding to the text mask are determined, including: Obtain the annotation order and coordinate information of the annotation text boxes; Based on the annotation order and the text box coordinate information, a text mask is generated in the initialization image, and the pixel value of the text mask is the annotation order number of the annotation text box; The text mask is used to determine multiple target text boxes in the initialization image.
3. The method according to claim 1, characterized in that, Also includes: Obtain the boundary information of the labeled text box; Based on the boundary information, determine the text boxes in the text image to be processed that do not intersect with the labeled text boxes; Text boxes that do not intersect with the labeled text boxes are identified as invalid text boxes; Remove the invalid text boxes.
4. The method according to claim 1, characterized in that, Obtaining the annotation text box of the text image to be processed includes: The text image to be processed is cropped according to preset conditions to obtain a cropped image; Identify multiple text boxes with pixel values greater than 0 from the cropped image; The plurality of text boxes are defined as the annotation text boxes.
5. The method according to claim 4, characterized in that, Also includes: The initial image is cropped according to the cropping area corresponding to the cropped image.
6. The method according to any one of claims 1-5, characterized in that, Also includes: Valid text box data containing the aforementioned valid text information are identified as valid training data.
7. A text information processing apparatus, characterized in that, include: The acquisition module is used to acquire the initial image corresponding to the text image to be processed and the annotation text box of the text image to be processed. The initial image is a single-channel image with a pixel value of 0, and the size information of the initial image is consistent with the size information of the text image to be processed. The generation module is used to generate a text mask corresponding to multiple labeled text boxes in the initialization image based on the attribute information of the labeled text boxes, and to determine multiple target text boxes corresponding to the text mask; The elimination module is used to eliminate invalid text information and its corresponding invalid text boxes based on the pixel information of the labeled text box and the target text box, so as to obtain the valid text information and its corresponding valid text boxes in the text image to be processed. The module includes: obtaining the first pixel count of the labeled text box and the second pixel count of the target text box; calculating the ratio between the first pixel count and the second pixel count; determining whether the ratio is less than a preset threshold; when the ratio is less than the preset threshold, determining that the text information in the labeled text box is invalid text information; and eliminating all invalid text boxes corresponding to the invalid text information to obtain the valid text information and its corresponding valid text boxes in the text image to be processed.
8. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the text information processing method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the text information processing method according to any one of claims 1-6.