Screenshot-oriented lightweight OCR (Optical Character Recognition) violation text detection method, system and equipment and storage medium
By filtering and standardizing the resolution and size of candidate text boxes, and training the model using images with interference features, the problem of poor OCR recognition reliability in screenshot scenarios is solved, achieving lightweight and fast detection of illegal text.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- RUICHI ZHIXIN (GUANGDONG HENGQIN GUANGDONG & MACAO DEEP COOP ZONE) TECHNOLOGY CO LTD
- Filing Date
- 2025-09-16
- Publication Date
- 2026-05-19
AI Technical Summary
Existing OCR technology struggles to effectively identify illegal text in mobile phone or computer screenshot scenarios, especially when UI elements, icons, background textures, and occlusions are present. The reliability of recognition is poor, and traditional methods involve high computational and storage costs, making real-time deployment difficult.
A lightweight OCR method for detecting illegal text is adopted. Candidate text boxes are selected through a text detection model, and the resolution and size are unified. Enhanced feature learning is performed using text images with interference features. The model is trained by combining occluded and variant images. Progressive distillation and cross-attention mechanisms are used to improve the model's generalization ability and robustness in screen screenshot scenarios.
It enables fast and accurate identification of illegal text in screenshots without increasing inference computation overhead, improving the model's recognition stability and generalization ability in complex scenarios.
Smart Images

Figure CN122067237A_ABST
Abstract
Description
[0001] Technology Neighborhood
[0002] This invention relates to the field of artificial intelligence technology, and in particular to a lightweight OCR method, system, device, and storage medium for detecting illegal text in screenshots. Background Technology
[0003] Illegal text detection typically relies on Optical Character Recognition (OCR) technology. It involves three stages: text detection, text recognition, and violation determination, to extract the text from an image and then compare it against a violation dictionary or classification model. However, real-world application scenarios are complex and diverse. Screenshots from mobile phones or computers often contain numerous UI elements, icons, background textures, and pop-up window obstructions. These interfering factors can lead to false positives and false negatives in the text recognition stage. Especially when illegal words are deliberately censored, symbols are inserted, or fonts are abnormal, traditional OCR models often struggle to correctly recognize them, thus affecting the reliability of illegal text detection.
[0004] Text recognition improvement methods for mobile / computer screenshot scenarios can be divided into two categories. One category focuses on data, such as using large-scale labeled data and expanding synthetic datasets to cover diverse scenarios. However, labeling requires significant manpower and resources, and there are often significant domain differences between synthetic data and real screenshots. Directly using synthetic data may lead to a significant drop in accuracy when the model is transferred to real-world scenarios. Furthermore, labels in open-source data often contain a lot of noise, which can easily cause the model to be misled by incorrect samples during training. The other category uses complex model structures to improve fault tolerance, such as deepening the visual encoder and stacking larger attention layers. However, this approach not only incurs high computational and storage costs, making real-time deployment on terminal devices difficult, but also struggles to guarantee recognition stability under conditions of severe background noise and occlusion. Summary of the Invention
[0005] The purpose of this invention is to address the technical problems existing in the background art by proposing a lightweight OCR method, system, device, and storage medium for detecting illegal text in screen screenshots.
[0006] To achieve the above-mentioned technical objectives, the technical solution adopted by the present invention is as follows:
[0007] A first implementation of the first aspect of the present invention provides a lightweight OCR method for detecting illegal text in screenshots, comprising:
[0008] S101. Detect the obtained original screenshot and separate candidate text regions from it. Use a pre-set text detection model to detect the candidate text regions and output multiple detection results. The detection results include bounding box coordinates and confidence scores.
[0009] S102. Based on each confidence level, select multiple candidate text boxes from multiple detection results, and unify the resolution and size of each candidate text box;
[0010] S103. Use a pre-set text recognition model to recognize the unified candidate text boxes and obtain text information. The text recognition model uses text images with interference features as training samples in advance to learn enhanced features.
[0011] S104. Identify the illegal content in the text information and output an illegal alarm. If there is no illegal content in the text information, return to step S101.
[0012] Optionally, in a second implementation of the first aspect of the present invention, unifying the resolution and size of each candidate text box includes:
[0013] Scale all candidate text boxes to a uniform height and width;
[0014] Perform geometric correction on irregular candidate text boxes to standardize resolution;
[0015] A proportional scaling and padding strategy is adopted, which aligns each candidate text box with the top left corner and then pads the empty parts with zeros.
[0016] Optionally, in a third implementation of the first aspect of the present invention, the method for obtaining the text image with interference features includes:
[0017] Based on the text image to be trained, an occlusion mask is added to obtain the occluded image;
[0018] Based on the text content in the text image to be trained, generate multiple different appearance variants to obtain variant images.
[0019] Optionally, in a fourth implementation of the first aspect of the present invention, the text recognition model uses text images with interference features as training samples beforehand to perform enhanced feature learning, including:
[0020] Using the occluded image and variant images as input to the text recognition model, we obtain occlusion features F1 and semantic features F2;
[0021] Calculate the alignment loss Lali between the occlusion feature F1 and the semantic feature F2;
[0022] Insert a mask marker into the occlusion feature F1 and extract the mask feature F1';
[0023] Then, through a pre-set cross-attention mechanism to interact with the features, the semantic feature F2 and the mask feature F1' are calculated, and the reconstruction loss Lcon is output.
[0024] The total loss Ltotal is calculated by combining the original loss Lori, alignment loss Lali, reconstruction loss Lcon, and preset learnable parameters. The original loss Lori is obtained by loss calculation from a noise-free text image.
[0025] Optionally, in the fifth implementation of the first aspect of the present invention, the formula for calculating the total loss Ltotal is:
[0026] L total =L ori +αL ali +βL con ;
[0027] Here, α and β are learnable parameters.
[0028] Optionally, in a sixth implementation of the first aspect of the present invention, step S104 further includes:
[0029] We construct labeled real screenshot data and synthetic image data, where the labeled real screenshot data and synthetic image data both include noise-free text images, occluded images and variant images;
[0030] The total loss of labeled real screenshot data and synthetic image data is calculated separately.
[0031] Optionally, in the seventh implementation of the first aspect of the present invention, step S104 further includes:
[0032] The teacher model is trained using labeled real screenshot data and synthetic image data to generate soft-labeled real screenshot data.
[0033] Based on a pre-built progressive training model, real screenshot data and synthetic image data with soft labels are progressively introduced into the distillation process layer by layer from real screenshot samples.
[0034] The similarity between real samples and synthetic domains is stratified by using the domain difference estimation method. Starting from the samples that are closest to the synthetic data, the similarity is gradually expanded to more difficult real samples. Each layer of samples is generated with soft labels by the teacher model and filtered with confidence scores before being input into the pre-set student model for distillation optimization.
[0035] A first implementation of the second aspect of the present invention provides a lightweight OCR illegal text detection system for screen screenshots, comprising:
[0036] The text detection module is used to detect the acquired original screenshot and separate candidate text regions from it. It uses a pre-built text detection model to detect candidate text regions and outputs multiple detection results, including bounding box coordinates and confidence scores.
[0037] The text image preprocessing module is used to filter out multiple candidate text boxes from multiple detection results based on various confidence levels, and to unify the resolution and size of each candidate text box;
[0038] The text recognition module is used to recognize the unified candidate text boxes using a pre-built text recognition model to obtain text information. The text recognition model uses text images with interference features as training samples in advance to learn enhanced features.
[0039] The violation determination module is used to identify violations in text information and output violation alarms. If there are no violations in the text information, the system returns to the text detection module.
[0040] A first implementation of the third aspect of the present invention provides a lightweight OCR illegal text detection device for screen screenshots, the lightweight OCR illegal text detection device for screen screenshots includes: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected by a line;
[0041] The at least one processor invokes the instructions in the memory to cause the lightweight OCR illegal text detection device for screenshots to perform the lightweight OCR illegal text detection method for screenshots as described in any one of the first aspects of the present invention.
[0042] A first implementation of the fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a lightweight OCR method for detecting illegal text in screen captures as described in any one of the first aspects of the present invention.
[0043] Compared with existing technologies, this invention has the following beneficial technical effects: Candidate text regions are separated from the original screenshot, and multiple detection results are detected using a text detection model. These detection results include bounding box coordinates and confidence scores. Based on each confidence score, multiple candidate text boxes are selected from the multiple detection results, and the resolution and size of each candidate text box are standardized. A pre-set text recognition model is used to recognize the standardized candidate text boxes to obtain text information. The text recognition model uses text images with interference features as training samples to enhance feature learning, identify illegal content in the text information, and output violation alarms. This enables rapid and accurate identification of illegal text in screenshots. Furthermore, by pre-training the text recognition model with loss functions using text images with interference features, the model's generalization ability and robustness in screenshot scenarios are improved without increasing inference computation overhead. Attached Figure Description
[0044] Figure 1 This is a schematic diagram of the first embodiment of the lightweight OCR illegal text detection method for screen screenshots in this invention.
[0045] Figure 2 This is a schematic diagram of an embodiment of a lightweight OCR illegal text detection system for screen screenshots in this invention.
[0046] Figure 3 This is a schematic diagram of an embodiment of a lightweight OCR illegal text detection device for screen screenshots in this invention.
[0047] Figure 4 This is a flowchart of the loss calculation process and model training process in step 104 of this embodiment of the invention;
[0048] Figure 5 This is a flowchart illustrating the processing flow, text detection model, text recognition model training flow, and model update flow of an embodiment of the present invention. Detailed Implementation
[0049] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.
[0050] For ease of understanding, the specific process of the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 1 , Figure 4 as well as Figure 5 The lightweight OCR method for detecting illegal text in screenshots, as described in this embodiment of the invention, includes:
[0051] S101. Detect the obtained original screenshot and separate the candidate text regions from it. Use a pre-set text detection model to detect the candidate text regions and output multiple detection results. The detection results include bounding box coordinates and confidence scores.
[0052] In this implementation, the original screenshot is an image captured from a software interface, webpage, or document page. It contains various contents, such as interface elements, icons, background patterns, and multiple lines of text. In order to filter out the regions that may contain text, it is necessary to divide the original screenshot into regions beforehand. Then, a pre-prepared and trained text detection model is applied to the previously separated candidate text regions. The model further judges the specific situation of the text in these regions, locates the regions that may contain text, and gives the detection results in the form of bounding box coordinates and confidence scores.
[0053] After the model performs the detection, multiple corresponding results are obtained. The bounding box coordinates are used to accurately locate the specific position of the text in the screenshot, just like defining a range for the text box; while the confidence score reflects the model's grasp of the accuracy of the detected text region. The higher the value, the more reliable the model considers the detection result. The lightweight MobileNetV3 is selected as the backbone network in the text detection model.
[0054] S102. Based on each confidence level, select multiple candidate text boxes from multiple detection results, and unify the resolution and size of each candidate text box;
[0055] In this embodiment, after detecting candidate text regions using the text detection model, multiple detection results with bounding box coordinates and confidence scores are obtained. The confidence score reflects the model's grasp of the accuracy of its judgment regarding the corresponding text region. Filtering multiple candidate text boxes based on each confidence score is a process of selection based on this reliability metric. Typically, an appropriate confidence threshold is set; only text boxes corresponding to detection results with confidence scores reaching or exceeding this threshold are selected as candidate text boxes. The purpose of this is to exclude text regions that the model deems inaccurate or unreliable, ensuring that the text boxes processed subsequently are highly likely to accurately contain the text content.
[0056] After selecting multiple candidate text boxes, they often differ in these aspects because they may originate from different original screenshots, or the original screenshots themselves may have variations in resolution and size. Therefore, standardizing the resolution and size of all candidate text boxes is crucial. Specialized image processing techniques and algorithms can be used to adjust their resolution to a uniform standard, such as setting a specific pixel value, and also standardize their dimensions, such as setting fixed width and height values. This facilitates subsequent unified recognition, analysis, and layout of the text within these text boxes, making the entire processing workflow more standardized and orderly, avoiding the inconvenience and errors caused by differences in resolution and size, and improving the accuracy and efficiency of text processing.
[0057] Furthermore, unifying the resolution and size of all candidate text boxes includes:
[0058] Scale all candidate text boxes to a uniform height and width;
[0059] Perform geometric correction on irregular candidate text boxes to standardize resolution;
[0060] A proportional scaling and padding strategy is adopted, which aligns each candidate text box with the top left corner and then pads the empty parts with zeros.
[0061] In this embodiment, the input image size of the text detection model is set in two ways according to the overall text orientation of the screenshot: 640×960 for landscape mode and 960×640 for portrait mode. After detecting a text line, candidate text boxes are filtered with a confidence level of 0.6. The text line image is extracted according to the text box coordinates, and then corrected for perspective, scaled proportionally, and filled to 32×480 as the input of the text recognition model. The overall confidence threshold of the text recognition model is set to 0.6 to filter UI icons that frequently appear in the screenshot scene.
[0062] S103. Use a pre-set text recognition model to recognize the unified candidate text boxes and obtain text information. The text recognition model uses text images with interference features as training samples in advance to learn enhanced features.
[0063] In this embodiment, since most text recognition models include a visual feature extractor that outputs a two-dimensional feature map, a sequence modeler that maps features to a time series, and a decoding classification layer that generates character probability sequences and decodes them into characters, the text recognition model here adds two training-period auxiliary branches: a mask reconstruction module and a language guidance module.
[0064] Furthermore, methods for acquiring text images with interfering features include:
[0065] Based on the text image to be trained, an occlusion mask is added to obtain the occluded image;
[0066] Based on the text content in the text image to be trained, generate multiple different appearance variants to obtain variant images.
[0067] In this embodiment, the mask reconstruction module and the language guidance module correspond to the two steps mentioned above, respectively, to generate the occluded image and the variant image. The different appearance variants refer to different UI designs, appearance styles, background noise, etc. of the image.
[0068] See attached Figure 4 The text recognition model uses text images with interfering features as training samples beforehand to perform enhanced feature learning, including:
[0069] Using the occluded image and variant images as input to the text recognition model, we obtain occlusion features F1 and semantic features F2;
[0070] Calculate the alignment loss Lali between the occlusion feature F1 and the semantic feature F2;
[0071] Insert a mask marker into the occlusion feature F1 and extract the mask feature F1';
[0072] Then, through a pre-set cross-attention mechanism to interact with the features, the semantic feature F2 and the mask feature F1' are calculated, and the reconstruction loss Lcon is output.
[0073] The total loss Ltotal is calculated by combining the original loss Lori, alignment loss Lali, reconstruction loss Lcon, and preset learnable parameters. The original loss Lori is obtained by loss calculation from a noise-free text image.
[0074] The formula for calculating the total loss Ltotal is as follows:
[0075] L total =L ori +αL ali +βL con ;
[0076] Here, α and β are learnable parameters.
[0077] Furthermore, step S103 also includes:
[0078] We construct labeled real screenshot data and synthetic image data, where the labeled real screenshot data and synthetic image data both include noise-free text images, occluded images and variant images;
[0079] The total loss of labeled real screenshot data and synthetic image data is calculated separately.
[0080] Furthermore, step S103 also includes:
[0081] The teacher model is trained using labeled real screenshot data and synthetic image data to generate soft-labeled real screenshot data.
[0082] Based on a pre-built progressive training model, real screenshot data and synthetic image data with soft labels are progressively introduced into the distillation process layer by layer from real screenshot samples.
[0083] The similarity between real samples and synthetic domains is stratified by using the domain difference estimation method. Starting from the samples that are closest to the synthetic data, the similarity is gradually expanded to more difficult real samples. Each layer of samples is generated with soft labels by the teacher model and filtered with confidence scores before being input into the pre-set student model for distillation optimization.
[0084] In this embodiment, the teacher model is used to generate soft labels for the data in each layer of samples. As the training progresses, the system dynamically adjusts the proportion and difficulty of introducing unlabeled samples and reverts to the previous stage when the quality of the pseudo-labels is insufficient. This continuously narrows the gap between the real domain and the synthetic domain while ensuring training stability. The student model optimizes the learning process by combining cross-entropy and temperature-controlled KL divergence, which reduces noise label interference and obtains more stable feature representations. In particular, it not only effectively alleviates the label noise problem but also avoids using a time-consuming encoding and decoding structure as the backbone network of the final model.
[0085] S104. Identify the illegal content in the text information and output an illegal alarm. If there is no illegal content in the text information, return to step S101.
[0086] In this embodiment, multi-label determination at the character / word / phrase level is performed based on the recognition output and final features, and then the recognized character sequence is sent to the violation detection module. This module, based on the recognition results, compares the results with a preset violation word list and discrimination rules, and combines the contextual information of the character sequence to perform violation determination character-by-character, word-by-word, or phrase-by-phrase. For detected violations, the system outputs the location of the violation fragment, the corresponding confidence value, and provides related supplementary evidence information for subsequent automatic interception or manual review. By adding a mask reconstruction and language guidance dual-aid module during the training phase, and integrating distillation and progressive training strategies, the model's generalization ability and robustness in screenshot scenarios are improved without increasing inference computational overhead. The ViT-S encoding / decoding model is selected as the teacher model for text recognition, and the lightweight MobileNetV3 is selected as the student model. The training image data composition of the text recognition model is: 10% labeled image data, 30% unlabeled data, 60% synthetic data, and other scene data.
[0087] The lightweight OCR method for detecting illegal text in screenshots according to embodiments of the present invention has been described above. The lightweight OCR system for detecting illegal text in screenshots according to embodiments of the present invention is described below. Please refer to [link / reference]. Figure 2 The lightweight OCR illegal text detection system for screen screenshots includes:
[0088] The text detection module 201 is used to detect the acquired original screenshot and separate candidate text regions from it. It uses a preset text detection model to detect the candidate text regions and outputs multiple detection results, including bounding box coordinates and confidence scores.
[0089] The text image preprocessing module 202 is used to filter out multiple candidate text boxes from multiple detection results based on each confidence level, and to unify the resolution and size of each candidate text box;
[0090] The text recognition module 203 is used to recognize the unified candidate text boxes using a pre-set text recognition model to obtain text information. The text recognition model uses text images with interference features as training samples in advance to learn enhanced features.
[0091] The violation determination module 204 is used to identify violations in the text information and output a violation alarm. If there are no violations in the text information, it returns to the text detection module.
[0092] The standardization of resolution and size for all candidate text boxes includes:
[0093] Scale all candidate text boxes to a uniform height and width;
[0094] Perform geometric correction on irregular candidate text boxes to standardize resolution;
[0095] A proportional scaling and padding strategy is adopted, which aligns each candidate text box with the top left corner and then pads the empty parts with zeros.
[0096] The methods for obtaining text images with interference features include:
[0097] Based on the text image to be trained, an occlusion mask is added to obtain the occluded image;
[0098] Based on the text content in the text image to be trained, generate multiple different appearance variants to obtain variant images.
[0099] The text recognition model uses text images with interfering features as training samples beforehand to learn enhanced features, including:
[0100] Using the occluded image and variant images as input to the text recognition model, we obtain occlusion features F1 and semantic features F2;
[0101] Calculate the alignment loss Lali between the occlusion feature F1 and the semantic feature F2;
[0102] Insert a mask marker into the occlusion feature F1 and extract the mask feature F1';
[0103] Then, through a pre-set cross-attention mechanism to interact with the features, the semantic feature F2 and the mask feature F1' are calculated, and the reconstruction loss Lcon is output.
[0104] The total loss Ltotal is calculated by combining the original loss Lori, alignment loss Lali, reconstruction loss Lcon, and preset learnable parameters. The original loss Lori is obtained by loss calculation from a noise-free text image.
[0105] The formula for calculating the total loss Ltotal is as follows:
[0106] L total =L ori +αL ali +βL con ;
[0107] Here, α and β are learnable parameters.
[0108] Specifically, the text recognition module 203 can also perform the following:
[0109] We construct labeled real screenshot data and synthetic image data, where the labeled real screenshot data and synthetic image data both include noise-free text images, occluded images and variant images;
[0110] The total loss of labeled real screenshot data and synthetic image data is calculated separately.
[0111] Specifically, the text recognition module 203 can also perform the following:
[0112] The teacher model is trained using labeled real screenshot data and synthetic image data to generate soft-labeled real screenshot data.
[0113] Based on a pre-built progressive training model, real screenshot data and synthetic image data with soft labels are progressively introduced into the distillation process layer by layer from real screenshot samples.
[0114] The similarity between real samples and synthetic domains is stratified by using the domain difference estimation method. Starting from the samples that are closest to the synthetic data, the data is gradually expanded to more difficult real samples. Each layer of samples consists of real screenshot data with soft labels generated by the teacher model. After being filtered by confidence, the data is input into the pre-set student model for distillation optimization.
[0115] The above is attached Figure 2 The present invention provides a detailed description of the lightweight OCR illegal text detection method for screen screenshots from the perspective of unitized functional entities. The following describes the lightweight OCR illegal text detection device for screen screenshots from the perspective of hardware processing.
[0116] Figure 3This is a schematic diagram of the structure of a lightweight OCR illegal text detection device 300 for screenshots provided in an embodiment of the present invention. This lightweight OCR illegal text detection device 300 for screenshots can vary considerably due to different configurations or performance. It may include one or more central processing units (CPUs) 310 (e.g., one or more processors) and a memory 320, and one or more storage media 330 (e.g., one or more mass storage devices) for storing application programs 333 or data 332. The memory 320 and storage media 330 can be temporary or persistent storage. The program stored in the storage media 330 may include one or more units (not shown in the diagram), each unit may include a series of instruction operations on the lightweight OCR illegal text detection device 300 for screenshots. Furthermore, the processor 310 may be configured to communicate with the storage media 330 and execute the series of instruction operations in the storage media 330 on the lightweight OCR illegal text detection device 300 for screenshots.
[0117] The lightweight OCR non-violation text detection device 300 based on screenshots may also include one or more power supplies 340, one or more wired or wireless network interfaces 350, one or more input / output interfaces 360, and / or one or more operating systems 331, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will understand that... Figure 3 The lightweight OCR illegal text detection device structure shown for screen capture does not constitute a limitation on communication protocol devices based on LAN screen projection, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0118] The present invention also provides a computer-readable storage medium, which can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when the instructions are executed on a computer, cause the computer to perform the steps of the lightweight OCR illegal text detection method for screen screenshots.
[0119] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0120] The above describes a lightweight OCR method or multiple implementations for detecting illegal text in screenshots, but it is not intended to limit the specific implementation of this invention to these descriptions. Any methods or structures that are similar to or identical to those of this invention, or any technical deductions or substitutions made based on the concept of this invention, should be considered within the scope of protection of this invention.
Claims
1. A lightweight OCR method for detecting illegal text in screenshots, characterized in that, include: S101. Detect the obtained original screenshot and separate the candidate text regions from it. Use a preset text detection model to detect the candidate text regions and output multiple detection results, wherein the detection results include bounding box coordinates and confidence scores. S102. Based on the confidence levels, select multiple candidate text boxes from the multiple detection results, and unify the resolution and size of each candidate text box; S103. The candidate text boxes that have been unified are identified using a pre-set text recognition model to obtain text information. The text recognition model uses text images with interference features as training samples in advance to perform enhanced feature learning. S104. Identify the illegal content in the text information and output an illegal alarm. If there is no illegal content in the text information, return to step S101.
2. The lightweight OCR method for detecting illegal text in screen screenshots according to claim 1, characterized in that, The standardization of the resolution and size of each candidate text box includes: Scale the size of each candidate text box to a uniform height and width; Geometric correction is performed on the irregular candidate text boxes to standardize the resolution; A proportional scaling and padding strategy is adopted, after aligning each candidate text box with the upper left corner, the empty parts are padded with zeros.
3. A lightweight OCR method for detecting illegal text in screenshots according to claim 2, characterized in that, The methods for obtaining the text image with interference features include: Based on the text image to be trained, an occlusion mask is added to obtain the occluded image; Based on the text content in the text image to be trained, generate multiple different appearance variants to obtain variant images.
4. A lightweight OCR method for detecting illegal text in screenshots according to claim 3, characterized in that, The text recognition model uses text images with interfering features as training samples beforehand to perform enhanced feature learning, including: Using the occluded image and the variant image as input to the text recognition model, occlusion feature F1 and semantic feature F2 are obtained; Calculate the alignment loss L between the occlusion feature F1 and the semantic feature F2. ali ; Insert a mask marker into the occlusion feature F1 and extract the mask feature F1'; Then, by interacting with the features through a pre-set cross-attention mechanism, the semantic feature F2 and the mask feature F1' are calculated, and the reconstruction loss L is output. con ; And combined with the original loss L ori The alignment loss L ali The reconstruction loss L con And with pre-defined learnable parameters, the total loss L is calculated. total Wherein, the original loss L ori The text image is obtained by loss calculation for noise-free text.
5. A lightweight OCR method for detecting illegal text in screenshots according to claim 4, characterized in that, The calculation of total loss L total The formula is: L total =L ori +αL ali +βL con ; Wherein, α and β are learnable parameters.
6. A lightweight OCR method for detecting illegal text in screenshots according to claim 5, characterized in that, Step S103 further includes: Construct labeled real screenshot data and synthetic image data, wherein the labeled real screenshot data and the synthetic image data both include the noise-free text image, the occluded image, and the variant image; The total loss of the labeled real screenshot data and the synthetic image data is calculated respectively.
7. A lightweight OCR method for detecting illegal text in screenshots according to claim 6, characterized in that, Step S103 further includes: The labeled real screenshot data and the synthetic image data are used to train a teacher model to generate soft-labeled real screenshot data. Based on a pre-set progressive training model, the real screenshot data of the soft label and the synthetic image data are progressively introduced into the distillation process layer by layer from the real screenshot samples. The similarity between real samples and synthetic domains is stratified by the domain difference estimation method. Starting from the samples that are closest to the synthetic data, the similarity is gradually expanded to more difficult real samples. Each layer of samples is generated with soft labels by the teacher model and filtered with confidence scores before being input into the pre-set student model for distillation optimization.
8. A lightweight OCR system for detecting inappropriate text in screenshots, characterized in that, include: The text detection module is used to detect the acquired original screenshot and separate candidate text regions from it. The candidate text regions are detected using a preset text detection model, and multiple detection results are output. The detection results include bounding box coordinates and confidence scores. The text image preprocessing module is used to filter out multiple candidate text boxes from multiple detection results based on the confidence levels, and to unify the resolution and size of each candidate text box; The text recognition module is used to recognize the unified candidate text boxes using a pre-set text recognition model to obtain text information. The text recognition model uses text images with interference features as training samples in advance to learn enhanced features. The violation determination module is used to identify the violation content in the text information and output a violation alarm. If there is no violation content in the text information, the system returns to the text detection module.
9. A lightweight OCR device for detecting illegal text in screenshots, characterized in that, The lightweight OCR illegal text detection device for screenshots includes: a memory and at least one processor, wherein the memory stores instructions, and the memory and the at least one processor are interconnected via a circuit. The at least one processor invokes the instructions in the memory to cause the lightweight OCR illegal text detection device for screenshots to perform the lightweight OCR illegal text detection method for screenshots as described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the lightweight OCR illegal text detection method for screenshots as described in any one of claims 1-7.