An english-chinese visual character generation method based on reinforcement learning post-training
Patent Information
- Application Number
- CN202610809289.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-05
- Publication Date
- 2026-10-30
AI Technical Summary
[0018]本发明要解决的问题是:现有文生图模型的文字渲染能力提升存在生成位置受限、受基础模型能力影响等问题,特别是存在文字生成幻觉的问题
[0046]本发明提出一种文生图模型的文字生成优化方法,包括训练方式、数据处理和评测基准三个方面都进行了针对性的改进设计。第一,在训练方式上,采用强化学习的手段,来优化目前具备中英文文字生成能力的开源模型。本发明的强化学习采用多文字隔离的强化学习后训练算法,将其应用到文字渲染能力提升方面。第二,在数据处理方面,构建了一个数据收集和清洗流程pipeline,有利于进一步提升强化学习后训练的效果。第三,在评测基准方面,基于OCR模型进行设计,使其有能力检测幻觉文字,可以有效评估本发明的视觉文字生成效果。
Smart Images

Figure CN123015729A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence technology and relates to image and video generation based on flow matching and multi-modal diffusion transformer (MMDiT). It is a method for generating Chinese and English visual text based on reinforcement learning training. Background Technology
[0002] The text rendering capability of a text-based image model refers to the model's ability to accurately and clearly render specified text (such as Chinese characters, English letters, numbers, and punctuation marks) within the generated image based on prompts. Significant research has been conducted on improving text rendering capabilities, including: training external text rendering modules; training text models to enhance their character understanding; and training-free methods. These will be introduced in detail below.
[0003] 1. Training an external text rendering module. Representative methods in this category include AnyText and AnyText2 from Alibaba, and PosterMaker from the University of Science and Technology of China. In terms of network structure, these methods all externalize a ControlNet-like architecture to the backbone diffusion model. During training, the ControlNet's parameters are updated, while the parameters of the backbone model are frozen.
[0004] AnyText proposes an auxiliary latent module and a text embedding module. The auxiliary latent module overlays glyph and positional information into the latent space for the diffusion model's denoising process. The text embedding module utilizes an OCR model to embed character semantic information into the text model's embedding, guiding the language model to understand the text information. Simultaneously, AnyText designed TextControlNet to control the generation of the final image based on the information extracted from the two modules. Regarding data, AnyText constructed a large amount of glyph data, which exists in the form of masks containing character and positional information. This data is fed into ControlNet for training. During inference, the model first renders the text portion of the user-input prompt as characters, and then uses this as control information to guide the model's inference.
[0005] AnyText2 is an improvement upon AnyText. It modifies TextControlNet, removing the temporal encoding layer and image-related inputs, retaining only character-related inputs, and naming the modified model WriteNet. Essentially, it also follows the ControlNet process.
[0006] PosterMaker is primarily designed for text rendering in poster scenes. It employs TextRenderNet and SceneGenNet, which are used as guides, injecting text and scene information into the backbone model, respectively. These two network structures are essentially modifications of the ControlNet architecture. TextRenderNet allows each character to extract independent visual features through an OCR encoder, while SceneGenNet maintains consistency across other parts of the image. Furthermore, the baseline model used is the Stable Diffusion (SD) 3 model. Since SD3 lacks Chinese character support, the text generated from the guide image is in English. For Chinese characters, this method decomposes each Chinese character into individual characters, treating each character as a small image, visually guiding the model to generate Chinese characters.
[0007] 2. Training the text model to enhance its character understanding. Representative methods in this area include Glyph-ByT5 and Glyph-ByT5-v2, developed by Microsoft Research Asia and Tsinghua University. To address the low accuracy of existing text-to-image generation models in visual text rendering, the research team proposed Glyph-ByT5, a customized text encoder optimized for character awareness and glyph alignment. Regarding data, a scalable glyph-text pairing dataset (ranging from 100K to 1M) was constructed based on graphics rendering, and character or word-level glyph enhancement strategies were employed for data augmentation. Training consisted of two steps: 1) The ByT5 text model was pre-trained using Glyph-prompt and Glyph-image, leveraging CLIP's contrastive learning method. The visual backbone model used was DINOv2. The training loss employed character or word-level glyph enhancement strategies and box-level contrastive loss combined with hard negative sample contrastive loss. 2) The pre-trained Glyph-ByT5 model was aligned and trained with the backbone model SDXL. This was achieved by integrating the Glyph-ByT5 model into SDXL using a region-level multi-head cross-attention mechanism, forming the Glyph-SDXL model. During training, two methods were employed to maintain the capabilities of the original backbone model: LoRA fine-tuning and region-level multi-head cross-attention training. Experiments demonstrated that this method significantly improved the model's text rendering capabilities.
[0008] Another approach to enhancing character understanding is to employ a more refined multimodal fusion method, such as Meituan's CharGen model. While also aiming to address inaccurate character rendering, its core lies in designing a character-level multimodal encoder. This method no longer encodes the entire line of text as a single image, but instead renders each character in the text as a separate glyph. The encoder then simultaneously extracts the character's visual features (from the glyph) and textual features (from its encoding in the original text), and through a dedicated mapper module, fuses these two modal features into a unified, more informative character-level embedding vector. This character-by-character fusion of visual and textual information allows the model to gain a more detailed and accurate understanding of character structure, effectively avoiding common errors such as character overlap, missing strokes, and added strokes when generating multi-stroke Chinese characters or complex English words. To further enhance the model's ability to process long text descriptions, CharGen introduces the Long-CLIP scheme, increasing the maximum processing length of the text encoder to 248 tokens. Furthermore, to strengthen supervision of glyph details during training, CharGen proposes a novel perceptual loss function called CharGenLoss. This loss function utilizes a pre-trained ODM (OCR text destylization) model, which focuses on restoring the glyph structure of the text while ignoring stylistic features such as color and texture. This supervision allows the backbone model to focus more on generating correctly shaped characters, avoiding interference from font style diversity, thus achieving more precise constraints on stroke details.
[0009] 3. Training-Free Methods. One representative of this type of method is the TextCrafter method proposed by Nanjing University and China Mobile. TextCrafter is a training-free method that achieves accurate multi-text generation on existing DiT (Diffusion Transformer) models. It employs a progressive strategy, including three key stages: 1) Instance Fusion: The main goal of this stage is to strengthen the binding relationship between the text and its visual carrier (such as signs or posters). The method used is to use the embedding of quotation tokens and the text carrier for weighted fusion to ensure that the text appears in the correct region and does not "float" on the image surface or become misaligned. 2) Region Insulation: The main purpose is to avoid mutual interference between multiple texts, including confusion and omission. By leveraging the spatial priors of the DiT model, an initial layout is automatically generated for each text segment. Then, a mixed-integer linear programming (MILP) optimizer is used to generate non-overlapping bounding boxes to achieve text region isolation and denoising, thereby reducing multi-text conflicts. 3) Text Focus: This step primarily aims to improve the clarity of small fonts or complex text styles. By modifying the attention map weights, the attention between "text tokens" and "image tokens" is enhanced, emphasizing visual text.
[0010] Another type of training-free method optimizes the sampling process itself, exemplified by the Attention Modulated Overshooting (AMO) Sampler proposed by researchers at Google and the University of Texas at Austin. This method significantly improves the text rendering quality of pre-trained Rectified Flow (RF) models without modifying the model structure or requiring additional training, by improving the sampling algorithm. Its core is a strategy called the "Overshooting sampler," which, based on the standard Euler sampler, alternately performs two steps: first, it strategically "over-simulates" the learned ordinary differential equation (ODE), i.e., predicts a time point further back than in a normal single-step prediction; then, it compensates and corrects by reintroducing carefully calculated noise. This process is equivalent to introducing an additional Langevin dynamics term in each Euler step, which helps correct the errors accumulated in successive Euler steps, thereby improving the quality of text generation. However, high overshoot intensity can lead to over-smoothing artifacts in the image. To address this issue, researchers further proposed an attention modulation mechanism, AMO. This method adaptively controls the overreflection intensity of different image regions by utilizing the attention scores between image patches and the text content in the cue words. Specifically, it enhances the overreflection effect in text-related regions while reducing the impact on the rest of the image, thus rendering text accurately without compromising overall image quality. Experiments show that AMO improves text rendering accuracy by 32.3% and 35.9% on state-of-the-art models such as SD3 and Flux, respectively, without adding additional inference costs.
[0011] The above analysis shows that significant progress has been made in enhancing text rendering capabilities for text-to-image models in the past two years, but the following problems still exist:
[0012] 1. Methods based on external text rendering modules or glyph control branches typically require pre-rendering the target text as a glyph image, text mask, or layout control condition before inputting the text-generated image model to constrain image generation. These methods rely on preset glyphs and control areas. When text needs to naturally attach to the surface of real-world carriers such as signs, blackboards, or packaging bags, the positional, perspective, and geometric deformation relationships between the text and the carrier are difficult to accurately determine before generation. Therefore, problems easily arise where the text's position, size, or orientation does not match the carrier.
[0013] 2. Methods based on text encoders or character understanding enhancement typically improve the model's ability to understand text content and glyph structure by training character-level encoders, glyph-aware text models, or related alignment modules. These methods usually require constructing training data containing accurate text annotations, glyph images, or region alignment information, resulting in high data construction costs. Furthermore, in scenarios where multiple text instances are generated simultaneously, interference may still occur between different text targets, making it difficult to simultaneously achieve both local text accuracy and overall image consistency.
[0014] 3. Training-free methods typically do not update the parameters of the base text-to-image model. Instead, they improve text generation quality during the inference phase through methods such as region constraints, attention modulation, or sampling strategy adjustments. While these methods are flexible and low-cost, their performance ceiling is still limited by the capabilities of the base model. When the base model is insufficient in multi-text generation, rendering of complex Chinese characters, or suppression of illusory text, simply relying on inference-stage constraints is insufficient to fundamentally improve text generation capabilities. Furthermore, some inference-stage adjustment methods may introduce new image quality issues such as over-smoothing, increased artifacts, or loss of detail.
[0015] Therefore, existing methods still struggle to simultaneously meet the requirements of accurate multi-text generation in complex scenarios, natural binding of text and visual carriers, non-interference between different texts, reduction of the illusion of unspecified or garbled text, and maintenance of overall image quality.
[0016] Furthermore, since mid-2025, with the release of models such as Seedream 4.0 and qwen-image, the aforementioned text enhancement methods are no longer applicable, as these newer models possess strong text rendering capabilities. These models, trained on large amounts of text data, outperform the enhancement schemes mentioned earlier. However, these powerful models still suffer from the problem of generating illusions, which refers to generating text not specified by the user or garbled characters, such as… Figure 1 As shown, Figure 1 The first line generated text that was not specified by the user, and the second line generated text contained garbled characters.
[0017] Because humans are far more sensitive to text than to other details in an image, text illusions greatly affect the accurate representation of the overall content of an image. Summary of the Invention
[0018] The problem this invention aims to solve is that existing text-to-image models suffer from limitations in text rendering capabilities, such as restricted generation positions and limitations imposed by the capabilities of the underlying model, and in particular, the problem of text generation illusion.
[0019] The technical solution of this invention is: a method for generating Chinese and English visual text based on reinforcement learning post-training, wherein a multi-text isolation reward function is constructed for a text-to-image model capable of generating images from Chinese and English text. The text rendering capability of the text-to-image model is optimized by using reinforcement learning for post-training. Specifically:
[0020] First, extract from multi-text prompt words The target text string entities constitute the baseline set. The image is generated by the Wensheng image model and then subjected to OCR recognition to obtain a global recognition sequence. For each target string A sliding window mechanism is used to calculate its correlation with the global recognition sequence. Independent similarity scores between The independent similarity score is defined as the target string with sequence All substrings of equal length The maximum Lewinstein similarity between them;
[0021] Computational basic aggregate reward :
[0022]
[0023] This is a balancing factor used to control the sensitivity to the worst-performing instance, which refers to the benchmark set. Independent similarity scores calculated for each target string The lowest level of entity;
[0024] Calculate the noise penalty factor based on the proportion of text length in the generated image. :
[0025]
[0026] This is a tolerance threshold for the length ratio, used to tolerate redundancy in identification. The total length of the recognized text in the generated image. The total length of the target text in the prompt words;
[0027] Obtain the multi-text insulation reward function: .
[0028] Furthermore, regarding and Standardization is performed to eliminate format noise from interfering with reward calculations.
[0029] Furthermore, independent similarity scores The range is The calculation is as follows:
[0030]
[0031] in, This indicates the distance edited by Levinstein.
[0032] Furthermore, a two-stage post-training strategy is employed to train the text-to-image model, including:
[0033] Aesthetic maintenance phase: The text-to-image model is pre-trained using an aesthetic reward model;
[0034] Text reinforcement stage: Based on multi-text insulation reward function The accuracy of multi-text generation in text-generated graphs is optimized by using a multi-text insulation reward function to guide text to achieve spatial decoupling at the feature level.
[0035] Furthermore, during reinforcement learning training, training data is constructed in the following way:
[0036] 1) Configure different text and image scenarios, including general realistic environments, posters, and PPTs, with general realistic environments accounting for 50% to ensure the generalization of real-world scenarios while avoiding homogeneous output;
[0037] 2) Configure the total length of the target text in the prompt words: 10~20 characters;
[0038] 3) Configure the text types to be included in the text-to-image prompts, including their position, color, size, font, and complex fonts in different images;
[0039] 4) Each prompt word contains 1-3 instances of the target text to be generated;
[0040] Based on the above configuration, training samples are generated for reinforcement learning training. Each training sample includes a text generation prompt word and a text instance attribute annotation set. The text instance attribute annotation set is used to record the structured attribute information of each target text instance in the prompt word, including text content, text position, text color, font type, and font size.
[0041] Furthermore, the text-generated image model is used for hallucination text evaluation. Based on an OCR model, firstly, a text detection model is used to detect text regions in the generated image to obtain candidate text regions. Then, a text recognition model is used to recognize the text in the candidate text regions, obtaining the candidate text region text and its recognition confidence. The local text similarity or text coverage recall between the candidate text region text and the target text is calculated. If the recognition confidence of the candidate text region is greater than or equal to 0.6, and its local text similarity or text coverage recall with the target text is greater than or equal to 0.90, then the candidate text region is classified as a correct text block. If the local text similarity or text coverage recall between the candidate text region and the target text is greater than or equal to 0.60 but less than 0.90, then the candidate text region is classified as an incorrectly generated text block and is not included in the hallucination block count. Candidate text regions in other cases are classified as hallucination blocks. A hallucination count index is calculated to assess the severity of the hallucination. and the area index of illusion :
[0042]
[0043]
[0044] in: The number of illusion blocks identified. Let be the confidence score for identifying the j-th illusion block. The independent similarity score between the text and the globally recognized sequence of the image in the illusion block. The area of the detection frame for the illusion block. The area represents the total area of the image. Both the hallucination count index and the hallucination area index are positively correlated with the severity of the hallucination text in the generated image. The larger the hallucination count index, the more hallucination text blocks are identified in the generated image. The larger the hallucination area index, the larger the proportion of space occupied by the hallucination text blocks in the entire image.
[0045] The above metrics are calculated on images generated by different candidate text-based image models to compare the text illusion suppression effects. If other generation quality requirements are met, the model with lower illusion count and illusion area metrics is selected as the better text-based image model.
[0046] This invention proposes an optimized text generation method for a text-to-image model, with targeted improvements in three aspects: training method, data processing, and evaluation benchmark. First, in terms of training method, reinforcement learning is employed to optimize existing open-source models capable of generating both Chinese and English text. The reinforcement learning algorithm used in this invention employs multi-text isolation post-training and is applied to improve text rendering capabilities. Second, in terms of data processing, a data collection and cleaning pipeline is constructed, which further enhances the effectiveness of post-training reinforcement learning. Third, in terms of evaluation benchmark, an OCR model is designed to detect illusory text, effectively evaluating the visual text generation effect of this invention.
[0047] Compared to methods like AnyText, AnyText2, GlyphControl, and PosterMaker, which rely on external text rendering modules or glyph control branches, this invention does not require pre-constructing character masks, glyph images, or fixing text layout conditions before image generation. Instead, it enhances the text generation capability of the basic text-to-image model through reinforcement learning after training, while retaining its original generation capabilities. Therefore, this invention avoids the overly restrictive limitations imposed by preset character masks on text position, shape, and orientation, making the generated text more likely to exhibit natural positional relationships and geometric changes with real-world carriers such as signs, blackboards, and packaging bags.
[0048] Compared to solutions such as Glyph-ByT5, Glyph-ByT5-v2, TextDiffuser, and Diff-Text, which mainly improve text accuracy by enhancing text encoding, introducing layout masks, or restricting attention maps, the focus of this invention is not to add an extra text control module to models that originally lack text generation capabilities. Instead, it addresses the problem that models like Qwen-Image, which already have strong Chinese and English text generation capabilities, may still produce unspecified text, duplicate text, or garbled text in complex multi-text scenarios. It constructs a multi-text isolation reward function based on OCR feedback and directly optimizes the model's text illusion problem through reinforcement learning training.
[0049] Compared to methods like AMO Sampler that improve text generation by adjusting sampling strategies during the inference phase, this invention does not merely impose temporary constraints on a single inference process. Instead, it models rewards for each target text as an independent text instance: on one hand, it improves the completeness of each target text generation by constraining independent similarity and worst-case text instances, avoiding missing characters or text; on the other hand, it suppresses over-generation phenomena such as unspecified text, duplicate text, and garbled text by penalizing text length ratio recognition. Therefore, this invention can simultaneously constrain "the text that should be generated must be accurately generated" and "the text that should not be generated should not appear" at the training objective level, thus more directly reducing text illusions in the generation of complex Chinese and English visual text. Attached Figure Description
[0050] Figure 1 This is an example of how text-to-image generation can create an illusion.
[0051] Figure 2 This is a schematic diagram of the post-training process of reinforcement learning based on the multi-text insulation reward function of the present invention.
[0052] Figure 3 This is a flowchart illustrating the evaluation method of the present invention. Detailed Implementation
[0053] The implementation of this invention will be described in detail below.
[0054] This invention constructs a multi-text insulation reward function. This study employs reinforcement learning post-training to optimize the text rendering capabilities of the text-generated image model. The aim is to enhance the fidelity of individual text instances during image generation and eliminate mutual interference between texts. This includes the following: Figure 2 As shown.
[0055] 1. Target Extraction and Data Preprocessing
[0056] First, extract from multi-text prompt words The target text string entities constitute the baseline set. During training, OCR recognition is performed on the images generated by the model to obtain a global recognition sequence. .right and All processes are standardized, such as converting to lowercase and removing special characters, to eliminate the interference of format noise on reward calculation.
[0057] 2. Independent fuzzy matching calculation
[0058] For each target string That is, the target text string entity, which is calculated using a sliding window mechanism to compare it with the global recognition sequence. Independent similarity scores between The score is defined as the target string. with sequence All substrings of equal length Maximum Levenshtein Similarity between them:
[0059]
[0060] in, This indicates the Levenstein edit distance. In this way, the system can precisely monitor the "insulation" quality of each text instance, ensuring that generation errors in different text regions do not penalize each other.
[0061] 3. Insulation Sensing Aggregation Reward
[0062] To prevent model collapse during training, i.e., generating only a portion of the text while ignoring the rest, this invention defines a basic aggregation reward. This is used to balance average generation performance with individual integrity.
[0063]
[0064] In this formula, This is a balancing factor used to control sensitivity to the "worst performing instance," with an empirical value set to 0.3. The worst performing instance refers to the benchmark set. Independent similarity scores calculated for each target string The minimum target text string entity. This is achieved by introducing [something] into the basic aggregate reward. This invention can explicitly penalize the omission or corruption of any single text target, forcing the model to "insulate" all request instances in the feature space.
[0065] 4. Anti-interference penalty mechanism
[0066] To address the "text explosion" phenomenon that may occur in reinforcement learning, where the model generates excessive redundant text to artificially inflate recall, this invention introduces a noise penalty factor based on length ratio. .
[0067] First, define the tolerance threshold for the length ratio. If the total length of the text recognized in the generated image is... Total length of target text in prompt words If the ratio exceeds this threshold, the reward will be reduced:
[0068]
[0069] In this embodiment, the following settings are provided: To tolerate reasonable redundancy in identification, while severely cracking down on garbled text and excessive generation.
[0070] The final training reward function is expressed as follows: .
[0071] This invention proposes an attention decoupling mechanism under dual constraints, and constructs a multi-text isolation reward function. Functionally, a two-way constraint mechanism for the generation length was established:
[0072] Lower bound constraint: "Insulation-aware aggregation" prompts the model to generate enough tokens to cover all targets and prevent omissions.
[0073] Upper bound constraint: Suppresses excessive model generation through "anti-interference penalty" to prevent hallucinations.
[0074] During reinforcement learning training, under this "push-pull" dynamic mechanism, the correct spatial layout is indirectly approximated. The cross-attention map of the text-generated graph model achieves spatial decoupling and region isolation at the feature level, significantly eliminating the overlap of activation regions between different text targets.
[0075] Furthermore, this invention employs the concept of Curriculum Strategy to perform a two-stage post-training of the text-based graph model:
[0076] Aesthetic maintenance phase: The model is pre-trained using aesthetic reward models such as PickScore, CLIPScore, and HPSv2.1 to ensure the artistry of the images.
[0077] Text enhancement stage: The OCR insulation reward function $R_{ocr}$ described in this invention is introduced to specifically optimize the accuracy and spatial arrangement of multi-text generation.
[0078] The multi-text insulation reward function designed in this invention It possesses extremely high versatility, seamlessly adapting to and integrating into various mainstream and advanced reinforcement learning frameworks, including but not limited to: DiffusionNFT, Flow-GRPO, DANCE-GRPO, etc. By... As a general objective function input, the method of this invention can guide the model to achieve attention decoupling in the feature space through different reinforcement learning (RL) algorithms, and ultimately generate clear, isolated and non-redundant multi-text images while maintaining high aesthetic image quality.
[0079] Further, for post-reinforcement learning training, the present invention also proposes a construction scheme for training data, which includes the following configurations.
[0080] 1) Configure image scenarios: general realistic, poster, and PPT scenarios, with a total volume of 100,000. The general realistic accounts for 50%, the poster accounts for 30%, and the PPT accounts for 20%, so as to avoid homogeneous output while ensuring the generalization of real scenarios. The general realistic scenarios include: real text-containing scenarios such as subway stations, railway stations, shopping malls, and traffic; the poster scenarios include: festival posters, solar term posters, recruitment posters, press conference posters, promotional posters (containing technological and sci-fi elements), and marketing posters; the PPT scenarios include summary reports, teaching and training, product demonstrations, promotion planning, etc.
[0081] 2) Configure the length of the target text in the text-to-image prompt: 10-20 characters;
[0082] 3) Configure the text requirements for the text-to-image prompt: the following aspects of content need to be covered:
[0083] Position: left side, right side, corner, lower left corner, center of the frame, lower edge of the frame, upper part, on the bookmark, on the lantern, etc.;
[0084] Color: yellow, matte color, green gradient, etc.;
[0085] Font size: for example, large, small, medium;
[0086] Font type: e.g., handwritten, Microsoft YaHei, thin font, official script, etc.; must be simplified Chinese characters.
[0087] Complex font type: a small number of complex characters may be included, such as complex rare Chinese characters, etc.
[0088] 4) Configure that the prompt contains 1-3 target texts required to be generated, and the probability of the constructed samples is: 1 occurrence: 2 occurrences: 3 occurrences = 5:3:2.
[0089] Based on the above training data, a configuration is constructed to generate training samples for reinforcement learning post-training. Each training sample includes a text generation prompt and a set of text instance attribute annotations. The text generation prompt is used as input to the text-generated graph model, and the target text to be generated is marked with double quotes within the prompt. The text instance attribute annotation set records the structured attribute information of each target text instance in the prompt, including text content, text position, text color, font type, and font size. An example of a prompt is: "A realistic image of a hospital entrance scene, with the hospital building entrance in the center, a large red sign hanging above, clearly marked 'XXX City Hospital' in white regular script, with slight shading at the edges to enhance the sense of depth." Here, "XXX City Hospital" is the target text, which is the text to be displayed in the image generated by the text-generated graph model. This sample contains one instance of the target text in the prompt.
[0090] In general, the images in the training data are divided into three categories: general realistic images, posters, and PPTs. To further improve the diversity and differentiation of the generated prompts and avoid homogeneous output, it is necessary to prioritize building a structured knowledge base for the text-to-image model for these three types of image scenes, such as a general scene library, a poster theme library, and a PPT scene library, to provide a reference for subsequent random sampling and differentiated generation.
[0091] As an example, common realistic text and image scenarios include:
[0092] Public transportation and travel scenarios, such as: subway station route maps, subway station exit signs, electronic screens in train station waiting halls, train timetables in train stations, lost and found offices in train stations, airport check-in counters, airport baggage claim areas, airport emergency evacuation maps, long-distance bus station schedules, etc.
[0093] Road and traffic facility scenarios, such as: highway exit warning signs, highway service area signs, road sign directional signs, parking lot entrance fee instructions, ride-hailing waiting area rules, charging pile operation guides, tunnel speed limit reminders, speed camera signs, road construction fence notices, and dangerous goods transportation route signs, etc.
[0094] Commercial and shopping scenarios, such as: shopping mall maps, shopping mall floor indexes, shopping mall brand store signs, supermarket product price tags, countdown timers for limited-time sales, QR code scanning instructions for unmanned stores, instructions for using fitting rooms, shopping mall WiFi connection guides, location signs for mother and baby rooms, holiday-themed decorative text, shopping mall safety exit maps, and signs for accessible pathways, etc.
[0095] As an embodiment, poster scenarios include multiple types, such as Spring Festival posters, Father's Day posters, Mother's Day posters, Teacher's Day posters, 24 solar terms overview posters, short video operation recruitment posters, cross-border e-commerce operation recruitment posters, new product launch posters, movie premiere conference posters, corporate strategy conference posters, future city sci-fi posters, and various other types of posters.
[0096] As an embodiment, PPT scenarios include various types of PPTs, such as quarterly summaries, annual reports, product releases, market analysis, training courseware, event planning, organizational structures, test reports, function demonstrations, academic reports, international cooperation, engineering progress, hotel introductions, automobile launches, game design, film and television planning, user evaluation, and so on.
[0097] In addition, for prompt generation of text images containing rare characters, it is necessary to first build a rare character knowledge base, and fine-tune the prompt on the previous basis. Common rare characters include such as "tao", "tie", "huo", "cuan", "yu", "da", "bing", etc.
[0098] Further, the present invention can be applied to a variety of text-to-image models. In this regard, the present invention also proposes a hallucinated text evaluation method, which realizes automatic detection and quantitative evaluation of hallucinated text in generated images. Different from the method that only evaluates the text generation quality from the entire image level, the evaluation method proposed by the present invention adopts a two-stage process, as Figure 3 shown. An OCR model generally includes two models: a text detection model and a text recognition model. As an embodiment, the text detection model first detects the text regions in the generated image, and screens out candidate text regions with a text region detection threshold of 0.2 and a detection box confidence threshold of 0.6; then the text recognition model is used to recognize the text in the candidate text regions, to obtain the text of the candidate text regions and its recognition confidence; the text of the candidate text regions and the target text are respectively normalized, and the local text similarity or text coverage recall between the text of the candidate text regions and the target text is calculated; if the recognition confidence of a candidate text region is greater than or equal to 0.6, and the local text similarity or text coverage recall between it and the target text is greater than or equal to 0.90, the candidate text region is classified as a correct text block; if the local text similarity or text coverage recall between the candidate text region and the target text is greater than or equal to 0.60 but less than 0.90, the candidate text region is classified as an incorrectly generated text block and is not counted as a hallucination block; in other cases, that is, candidate text regions that do not form an effective match with the target text are classified as hallucination blocks, thereby realizing region-level fine-grained evaluation of the degree of text hallucination in the generated image.
[0099] This invention designs two metrics to evaluate the overall degree of image hallucination: the hallucination count metric HS_Count and the hallucination area metric HS_Area. HS_Count is calculated based on the confidence and similarity of the identified hallucinations; the higher the confidence and similarity, the higher the metric. HS_Area is determined using the area of the detection box that detected the hallucination; the larger the area, the higher the metric. Therefore, these two metrics measure the degree to which a single image is disrupted by text hallucinations from two aspects. The specific calculation methods are as follows:
[0100]
[0101]
[0102] in: The number of illusion blocks identified. Let be the confidence score for identifying the j-th illusion block. The independent similarity score between the text and the globally recognized sequence of the image in the illusion block. The area of the detection frame for the illusion block. The area represents the total area of the image. Both the hallucination count index and the hallucination area index are positively correlated with the severity of the hallucination text in the generated image. The larger the hallucination count index, the more hallucination text blocks are identified in the generated image. The larger the hallucination area index, the larger the proportion of space occupied by the hallucination text blocks in the entire image.
[0103] The method of this invention trains multiple text-based image models and then calculates metrics to evaluate illusory text. Both the illusion count metric and the illusion area metric are used to quantify the degree of text illusion in the generated image, with higher values indicating a higher degree of illusion. By calculating these metrics on images generated by different candidate text-based image models, their text illusion suppression effects can be compared. When other generation quality requirements are met, the model with lower illusion count and illusion area metrics is selected as the superior text-based image model.
Claims
1. A method for generating Chinese and English visual text based on reinforcement learning post-training, characterized by: For text-generated image models capable of generating images from Chinese and English text, a multi-text isolation reward function is constructed. The text rendering capability of the text-to-image model is optimized by using reinforcement learning post-training, specifically as follows: First, extract from multi-text prompt words The target text string entities constitute the baseline set. The image is generated by the Wensheng image model and then subjected to OCR recognition to obtain a global recognition sequence. For each target string A sliding window mechanism is used to calculate its correlation with the global recognition sequence. Independent similarity scores between The independent similarity score is defined as the target string with sequence All substrings of equal length The maximum Levinstein similarity between them; Computational basic aggregate reward : This is a balancing factor used to control the sensitivity to the worst-performing instance, which refers to the benchmark set. Independent similarity scores calculated for each target string The lowest level of entity; Calculate the noise penalty factor based on the proportion of text length in the generated image. : This is a tolerance threshold for the length ratio, used to tolerate redundancy in identification. The total length of the recognized text in the generated image. The total length of the target text in the prompt words; Obtain the multi-text insulation reward function: .
2. The method for generating Chinese and English visual text based on reinforcement learning post-training as described in claim 1, characterized in that: right and Standardization is performed to eliminate format noise from interfering with reward calculations.
3. The method for generating Chinese and English visual text based on reinforcement learning post-training as described in claim 1, characterized in that: Independent similarity score The range is The calculation is as follows: in, This indicates the distance edited by Levinstein.
4. The method for generating Chinese and English visual text based on reinforcement learning post-training as described in claim 1, characterized in that: Balance coefficient Set to 0.3, the tolerance threshold for length ratio. Set it to 1.
1.
5. The method for generating Chinese and English visual text based on reinforcement learning post-training as described in claim 1, characterized in that: A two-stage post-training strategy was adopted to train the text-to-image model, including: Aesthetic maintenance phase: The text-to-image model is pre-trained using an aesthetic reward model; Text reinforcement stage: Based on multi-text insulation reward function The accuracy of multi-text generation in text-generated graphs is optimized by using a multi-text insulation reward function to guide text to achieve spatial decoupling at the feature level.
6. The method for generating Chinese and English visual text based on reinforcement learning post-training as described in claim 1, characterized in that: The reinforcement learning frameworks used for post-training reinforcement learning include DiffusionNFT, Flow-GRPO, and DANCE-GRPO. As the objective function, reinforcement learning guides the text-generated image model to achieve attention decoupling in the feature space, generating clear, isolated, and non-redundant multi-text images.
7. The method for generating Chinese and English visual text based on reinforcement learning post-training as described in claim 1, characterized in that: When training after reinforcement learning, the training data is constructed in the following way: 1) Configure different text and image scenarios, including general realistic environments, posters, and PPTs, with general realistic environments accounting for 50% to ensure the generalization of real-world scenarios while avoiding homogeneous output; 2) Configure the total length of the target text in the prompt words: 10~20 characters; 3) Configure the text types to be included in the text-to-image prompts, including their position, color, size, font, and complex fonts in different images; 4) Each prompt word contains 1-3 instances of the target text to be generated; Based on the above configuration, training samples are generated for reinforcement learning training. Each training sample includes a text generation prompt word and a text instance attribute annotation set. The text instance attribute annotation set is used to record the structured attribute information of each target text instance in the prompt word, including text content, text position, text color, font type, and font size.
8. The method for generating Chinese and English visual text based on reinforcement learning post-training as described in claim 1, characterized in that: A method for evaluating hallucinatory text in a text-generated image model is based on an OCR model. First, a text detection model is used to detect text regions in the generated image, obtaining candidate text regions. Then, a text recognition model is used to identify the text within these candidate regions, obtaining the candidate text and its recognition confidence. Local text similarity or text coverage recall between the candidate text and the target text is calculated. If the recognition confidence of a candidate text region is greater than or equal to 0.6, and its local text similarity or text coverage recall with the target text is greater than or equal to 0.90, then the candidate text region is classified as a correctly generated text block. If the local text similarity or text coverage recall between the candidate text region and the target text is greater than or equal to 0.60 but less than 0.90, then the candidate text region is classified as an incorrectly generated text block and is not included in the hallucinatory block count. All other candidate text regions are classified as hallucinatory blocks. A hallucination count index is calculated to assess the severity of the hallucination. and the area index of illusion : in: The number of illusion blocks identified. Let be the confidence score for identifying the j-th illusion block. The independent similarity score between the text and the globally recognized sequence of the image in the illusion block. The area of the detection frame for the illusion block. The area represents the total area of the image. Both the hallucination count index and the hallucination area index are positively correlated with the severity of the hallucination text in the generated image. The larger the hallucination count index, the more hallucination text blocks are identified in the generated image. The larger the hallucination area index, the larger the proportion of space occupied by the hallucination text blocks in the entire image. The above metrics are calculated on images generated by different candidate text-based image models to compare the text illusion suppression effects. If other generation quality requirements are met, the model with lower illusion count and illusion area metrics is selected as the better text-based image model.
9. The method for generating Chinese and English visual text based on reinforcement learning post-training as described in claim 8, characterized in that: The text detection model filters candidate text regions from the generated image using a text region detection threshold of 0.2 and a detection box confidence threshold of 0.
6. Before calculating the local text similarity or text coverage recall between the candidate text regions and the target text, the candidate text regions and the target text are normalized respectively.
