Security image generation method and device, electronic equipment and storage medium

By leveraging the feedback mechanism of large language models and detection models, text encoding is optimized to generate images that comply with security rules, thus solving the problem of AI generating unsafe images and improving both generation efficiency and security.

CN118967879APending Publication Date: 2024-11-15DUXIAOMAN TECH (BEIJING) CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410983658.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-22
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

Existing technologies for AI-generated images are prone to generating unsafe and non-compliant content, resulting in low generation efficiency.

Method used

By using a feedback mechanism between a pre-set large language model and a detection model, the target text encoding is updated based on anomaly information until an image that conforms to security rules is generated. The text features are optimized using a cross-attention mechanism and a negative gradient adjustment method to ensure that the generated image strikes a balance between semantic integrity and security.

Benefits of technology

It improves the efficiency of secure image generation, ensuring that the generated images meet security requirements while maintaining semantic integrity, and avoids security risks caused by random generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118967879A_ABST
    Figure CN118967879A_ABST
Patent Text Reader

Abstract

The invention provides a secure image generation method and device, electronic equipment and a storage medium, and the method comprises the steps: coding a target description text through a large language model to obtain a target text code, and generating a candidate image based on the target text code through a text graph model, and the detection model detects the security of the candidate image according to a preset security rule, if any feature which does not conform to the security rule exists, the big language model is notified to carry out fine adjustment and optimization of description through a feedback mechanism, and then coding generation is carried out again until the generated image conforms to the security standard. Under the condition that the candidate image does not conform to the security rule, the target text code is updated by using the abnormal information fed back by the detection model, so that the updated target text code is similar to the original target text code semantically, the picture content is ensured to meet the security requirement on the premise of ensuring the semantic integrity, and the user experience is improved. And the image is generated based on the target description text semantics all the time, so that the generation efficiency of the security image is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of large model technology, and in particular to a safety image generation method, device, electronic device and storage medium. Background Art

[0002] With the rapid development of AI technology, it has become possible to use AI to generate images or videos based on text, but in this process, the generated images may be unsafe and uncompliant. Specifically, AI may generate images containing unsafe content such as inappropriate advertisements and sensitive information.

[0003] In order to prevent AI from generating such unsafe images, related technologies usually choose to add an audit model before outputting the AI-generated image to perform a security audit on the image. For images that fail the security audit, the user can choose to regenerate the image or refuse to generate the image, resulting in low efficiency in AI image generation. Summary of the invention

[0004] In view of this, embodiments of the present invention provide a security image generation method, device, electronic device and storage medium to improve the efficiency of security image generation.

[0005] According to one aspect of the present invention, a method for generating a security image is provided, the method comprising:

[0006] Get the target description text;

[0007] Outputting a target text encoding for the target description text using a preset large language model;

[0008] Generate candidate images based on the target text encoding using a preset text-image model;

[0009] Determining whether the candidate image is safe based on preset safety rules using a preset detection model;

[0010] In the case where the candidate image is unsafe, the abnormal information is fed back to the preset large language model, so that the preset large language model outputs a new target text encoding based on the abnormal information and the semantics of the target description text; and the step of generating the candidate image based on the target text encoding by using the preset text-image model is returned until the candidate image is safe;

[0011] The safe candidate image is output as a target image.

[0012] In a possible embodiment, the abnormal information includes: description information of the violation points in the candidate image;

[0013] The preset large language model outputs a new target text encoding through the following steps:

[0014] Based on the violation point description information, modify the text related to the violation point description information in the target description text to obtain an updated description text;

[0015] A target loss is obtained based on a semantic loss and an avoidance loss, wherein the semantic loss is a semantic loss between the updated description text and the target description text, the avoidance loss is an avoidance loss between the updated description text and the violation point description information, and the target loss is positively correlated with the semantic loss and negatively correlated with the avoidance loss;

[0016] Adjusting the updated description text based on the target loss until the target loss converges;

[0017] A new target text encoding is output based on the updated description text when the target loss converges.

[0018] In a possible embodiment, the semantic loss is the semantic similarity between the updated description text and the target description text, the avoidance loss is the semantic similarity between the updated description text and the violation point description information, and the target loss is obtained by the following formula:

[0019] L=αL1-βL2

[0020] Among them, L is the target loss, L1 is the semantic loss, L2 is the avoidance loss, α is the first preset weight, and β is the second preset weight.

[0021] In a possible embodiment, the abnormal information includes: candidate image features and description information of illegal points in the candidate image;

[0022] The step of outputting a target text encoding for the target description text using a preset large language model includes:

[0023] Extracting text features of the target description text using the preset large language model;

[0024] Outputting the target text encoding based on the text features;

[0025] The preset large language model outputs a new target text encoding through the following steps:

[0026] Using a cross attention mechanism, determining each feature point in the candidate image features that is associated with the violation point description information as a violation description feature;

[0027] Using the violation description feature to adjust the text feature using a negative gradient adjustment method to obtain an updated text feature;

[0028] Based on the updated text features, a new target text encoding is obtained.

[0029] In a possible embodiment, the preset security rules include text rules and image rules, the text rules include violation point description information, and the image rules include images with violation points marked.

[0030] According to another aspect of the present invention, there is provided a security image generating device, the device comprising:

[0031] An acquisition module is used to obtain the target description text;

[0032] An encoding module, used for outputting a target text encoding for the target description text using a preset large language model;

[0033] A generation module, used for generating candidate images based on the target text encoding by using a preset text-image model;

[0034] A judgment module, used to determine whether the candidate image is safe based on preset safety rules using a preset detection model;

[0035] A feedback module is used to feed back abnormal information to the preset large language model when the candidate image is unsafe, so that the preset large language model outputs a new target text encoding based on the abnormal information and the semantics of the target description text; and return to the step of generating a candidate image based on the target text encoding by using the preset text-image model until the candidate image is safe;

[0036] The output module is used to output the safe candidate image as a target image.

[0037] In a possible embodiment, the abnormal information includes: description information of the violation points in the candidate image;

[0038] The preset large language model outputs a new target text encoding through the following steps:

[0039] Based on the violation point description information, modify the text related to the violation point description information in the target description text to obtain an updated description text;

[0040] A target loss is obtained based on a semantic loss and an avoidance loss, wherein the semantic loss is a semantic loss between the updated description text and the target description text, the avoidance loss is an avoidance loss between the updated description text and the violation point description information, and the target loss is positively correlated with the semantic loss and negatively correlated with the avoidance loss;

[0041] Adjusting the updated description text based on the target loss until the target loss converges;

[0042] A new target text encoding is output based on the updated description text when the target loss converges.

[0043] In a possible embodiment, the abnormal information includes: candidate image features and description information of illegal points in the candidate image;

[0044] The step of outputting a target text encoding for the target description text using a preset large language model includes:

[0045] Extracting text features of the target description text using the preset large language model;

[0046] Outputting the target text encoding based on the text features;

[0047] The preset large language model outputs a new target text encoding through the following steps:

[0048] Using a cross attention mechanism, determining each feature point in the candidate image features that is associated with the violation point description information as a violation description feature;

[0049] Using the violation description feature to adjust the text feature using a negative gradient adjustment method to obtain an updated text feature;

[0050] Based on the updated text features, a new target text encoding is obtained.

[0051] According to another aspect of the present invention, there is provided an electronic device, comprising:

[0052] Processor; and

[0053] Memory for storing programs,

[0054] The program includes instructions, which, when executed by the processor, cause the processor to execute any of the above-mentioned security image generation methods.

[0055] According to another aspect of the present invention, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute any of the above-mentioned security image generation methods.

[0056] One or more technical solutions provided in the embodiments of the present invention obtain the target description text, encode the target description text through the large language model to obtain the target text code, generate the candidate image based on the target text code through the text-generated graph model, and then the detection model analyzes and judges the security of the generated candidate image according to the preset security rules. If there are any features that do not meet the security rules, the large language model will be notified through the feedback mechanism to fine-tune and optimize the description, and then the code generation will be performed again until the generated image meets the security standards.

[0057] By applying the embodiments of the present invention, when a candidate image does not meet security rules, the target text encoding is updated using the abnormal information fed back by the detection model, so that the updated target text encoding is semantically similar to the original target text encoding, thereby ensuring that the generated image content meets security requirements while ensuring semantic integrity. Moreover, since a new description text is generated based on the semantics of the original target description text, the image is always generated based on the semantics of the target description text rather than randomly generated, thereby improving the generation efficiency of safe images. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Further details, features and advantages of the invention are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:

[0059] Figure 1 A schematic diagram of a process for generating a security image in the related art;

[0060] Figure 2 A schematic diagram of a process for generating a security image using a security model in a related technology;

[0061] Figure 3 A schematic diagram of a flow chart of a method for generating a security image provided by an embodiment of the present invention;

[0062] Figure 4 A schematic diagram of another flow chart of a method for generating a security image provided by an embodiment of the present invention;

[0063] Figure 5 A schematic diagram of the structure of a security image generating device provided by an embodiment of the present invention;

[0064] Figure 6 A block diagram of an exemplary electronic device that can be used to implement an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0065] Embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are only for exemplary purposes and are not intended to limit the scope of protection of the present invention.

[0066] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0067] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the following description. It should be noted that the concepts of "first", "second", etc. mentioned in the present invention are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0068] It should be noted that the modifications of "one" and "plurality" mentioned in the present invention are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0069] The names of the messages or information exchanged between multiple devices in the embodiments of the present invention are only used for illustrative purposes, and are not used to limit the scope of these messages or information.

[0070] In order to meet the security compliance requirements in related fields, related technologies usually add a set of security audit models after content generation. The generated content can be safely output after being audited by the security audit model, such as Figure 1As shown in the figure, CLIP is a neural network released by OpenAI that connects text and images. Through contrastive learning, it learns to match images and text descriptions, hoping to unify image features and text features. In the field of text graphs, it is usually used as a text encoder. T5 is also a large language model, and is usually used as a text encoder in the field of text graphs. Specifically, the user description is input into the text encoder, and the output of the text encoder is input into the text graph model. After obtaining the output content, the aggregated audit model is used to achieve safe content output. When encountering illegal content during use, it is usually chosen to randomly generate again until a compliant image is generated, or the generation fails directly, which is inefficient and has a poor experience.

[0071] In the field of text graphs, a one-step secure generation method has also emerged, such as Figure 2 As shown in FIG. 1 , Safe Latent Diffusion is used to collect non-compliant images in advance as learning materials for the text graph model, and the generated images are guided by gradients during generation to keep them away from such non-compliant images.

[0072] However, the image generation process using the Diffusion model not only depends on the input text, but also on the random noise of the input. In addition, the image generation module may add some content related to the common elements in the training data to the generated image. This may lead to uncertainty in the generated results and may cause unsafe factors.

[0073] Based on this, in order to generate a security image and improve the efficiency of generating the security image, the embodiments of the present invention provide a security image generation method, device, electronic device and storage medium. The security image generation method provided by the embodiments of the present invention can be applied to any electronic device with an image generation function, such as a server, a computer or a mobile terminal, etc. The following describes the solution of the present invention with reference to the accompanying drawings:

[0074] Figure 3 A schematic flow chart of a method for generating a security image provided by an embodiment of the present invention may include the following steps:

[0075] S301, obtaining target description text;

[0076] S302, outputting a target text encoding for the target description text using a preset large language model;

[0077] S303, using a preset text-image model to generate candidate images based on the target text encoding;

[0078] S304, using a preset detection model to determine whether the candidate image is safe based on preset safety rules, if not safe, executing S305, if safe, executing S306;

[0079] S305: If the candidate image is unsafe, the abnormal information is fed back to the preset large language model, so that the preset large language model outputs a new target text encoding based on the abnormal information and the semantics of the target description text; and the step of generating a candidate image based on the target text encoding by using the preset text-image model is returned until the candidate image is safe.

[0080] S306: Output the safe candidate image as a target image.

[0081] In the embodiment of the present invention, after obtaining the target description text, the target description text is encoded by the large language model to obtain the target text encoding, and the candidate image is generated based on the target text encoding by the text-generated graph model. Subsequently, the detection model analyzes and judges the security of the generated candidate image according to the preset security rules. If there are any features that do not meet the security rules, the large language model will be notified through the feedback mechanism to fine-tune and optimize the description, and then the encoding will be generated again until the generated image meets the security standards.

[0082] By applying the embodiments of the present invention, when a candidate image does not meet security rules, the target text encoding is updated using the abnormal information fed back by the detection model, so that the updated target text encoding is semantically similar to the original target text encoding, thereby ensuring that the generated image content meets security requirements while ensuring semantic integrity. Moreover, since a new description text is generated based on the semantics of the original target description text, the image is always generated based on the semantics of the target description text rather than randomly generated, thereby improving the generation efficiency of safe images.

[0083] The above steps S301-S306 are exemplarily described below:

[0084] The target description text can be input from outside, and can be a complete sentence or multiple short sentences, which is not specifically limited in the present invention. The target description text includes the content that needs to be included in the target image to be obtained, such as scene information, character information, and quantity information, etc. For example, the target description text can be "a person on the beach".

[0085] The target description text can be input into a large language model, which can be the CLIP model, T5 model, etc. The specific type of the large language model can be flexibly selected according to actual business needs. The large language model can encode the target description text to obtain the target text encoding.

[0086] In a possible embodiment, the large language model may encode the target description text according to a preset correspondence between text and encoding. In another possible embodiment, the large language model may encode the target description text according to the following steps:

[0087] Extracting text features of the target description text using the preset large language model;

[0088] Outputting the target text encoding based on the text features;

[0089] The above-mentioned target text encoding can be input into the Wenshengtu large model, which can be any large model with the function of generating images based on text, such as a Stable Diffusion model. After obtaining the candidate image output by the Wenshengtu large model, the candidate image can be input into the detection model. The detection model can be any model with image recognition function. In a possible embodiment, the detection model can be a multimodal large model, which refers to a model that can process multiple input data, such as the multimodal large model can process input in text, image and video formats.

[0090] In the embodiment of the present invention, the above-mentioned multimodal large model and the text-graph large model receive text encoding input by the same large language model, that is, it can be understood that the above-mentioned multimodal large model is composed of a large language model, an image processing model and a fusion model, and the text-graph model is composed of the same large language model and text-graph modules.

[0091] The multimodal large model can perform security compliance detection on the candidate images based on preset security rules. The preset security rules can be set according to the industry security standards of the corresponding business field, and can include multiple violation types. As a possible implementation method, the preset security rules can include text rules and image rules, wherein the text rules include violation point description information, and the image rules include images with marked violation points. The above-mentioned violation points refer to image points that do not comply with security rules, and the above-mentioned violation point description information can be information such as the appearance and type of the violation points.

[0092] The multimodal large model can detect candidate images based on the above-mentioned preset security rules and output a safety result. If the candidate image is safe, the candidate image can be output as the target image; if the candidate image is an unsafe image, abnormal information can be returned to the large language model, and the abnormal information may include image features of the candidate image and description information of the violation points of the candidate image, etc.

[0093] As a possible embodiment, the multimodal large model can extract candidate image features and match the candidate image features with the text rules and image rules in the above-mentioned preset security rules. If the match is successful, the candidate image is not compliant. If the match fails, it means that the candidate image is compliant.

[0094] In a possible embodiment, the multimodal large model can be pre-trained using the preset security rules, so that the multimodal large model can directly determine whether the candidate image is compliant, and if the candidate image is not compliant, mark the violation points in the candidate image and output the violation point description information. The multimodal large model can be pre-trained by any image recognition model training method, and the present invention does not specifically limit this.

[0095] The large language model can re-output the target text encoding based on the above-mentioned abnormal information. Specifically, the target text encoding can be re-output based on the semantic information of the target description text. As a possible implementation method, the above-mentioned target description text can be updated to re-output the target text encoding. Specifically, the target text encoding can be re-output through the following steps:

[0096] S31. Based on the violation point description information, modify the text related to the violation point description information in the target description text to obtain an updated description text.

[0097] In this step, the words and characters in the target description text that match the violation point description information can be replaced with synonyms or deleted. Specifically, the target description text can be segmented, and the similarity between each segmentation result and the violation point description information can be calculated, and the segmentation result with the highest similarity can be modified to obtain an updated description text.

[0098] S32, obtaining a target loss based on a semantic loss and an avoidance loss, wherein the semantic loss is a semantic loss between the updated description text and the target description text, the avoidance loss is an avoidance loss between the updated description text and the violation point description information, and the target loss is positively correlated with the semantic loss and negatively correlated with the avoidance loss;

[0099] S33. Adjust the updated description text based on the target loss until the target loss converges.

[0100] As a possible implementation, the semantic loss is the semantic similarity between the updated description text and the target description text. Exemplarily, the semantic loss may be cosine(CLIP(D 原 ), CLIP(D 微调 )), where D 原 Refers to the original target description text, D微调 Refers to the updated description text. CLIP(D 原 ), CLIP(D 微调 ) are the text features output by the CLIP large model for the original target description text and the updated description text respectively.

[0101] The avoidance loss is the semantic similarity between the updated description text and the violation point description information. For example, the avoidance loss can be cosine(CLIP(D 微调 ), CLIP(D 违规点 )), where D 微调 Refers to the updated description text, D 违规点 Refers to the violation description information above.

[0102] The target loss is obtained by the following formula:

[0103] L=αL1-βL2

[0104] Among them, L is the target loss, L1 is the semantic loss, L2 is the avoidance loss, α is the first preset weight, β is the second preset weight, and the above-mentioned first preset weight and second preset weight can be set according to actual needs and can be any value greater than zero.

[0105] The above target loss convergence means that the value of the target loss is less than the preset loss value, or the difference between the target loss values ​​obtained from two trainings is less than the preset difference.

[0106] S34. Output a new target text encoding based on the updated description text when the target loss converges.

[0107] When the target loss converges, the corresponding updated description text can be used as the new target description text and input into the large language model, which can re-output the target text encoding based on the new target description text. The text-based graph model can regenerate the candidate image based on the new target text encoding and conduct a security audit.

[0108] In a possible embodiment, since the large language model extracts text features from the target description text and then generates the target text encoding based on the text features, the text features can be modified based on the above-mentioned abnormal information to achieve the purpose of generating a new target text encoding. Specifically, the new target text encoding can be obtained by the following steps:

[0109] S41, using a cross attention mechanism, determining each feature point associated with the violation point description information in the candidate image features as a violation description feature;

[0110] S42, using the violation description feature to adjust the text feature using a negative gradient adjustment method to obtain an updated text feature;

[0111] S43. Based on the updated text features, a new target text encoding is obtained.

[0112] The cross-attention mechanism usually has three inputs: query, key, and value, where key and value are one-to-one corresponding. For a specific query, the similarity is calculated with all keys, and the corresponding weight of the value is taken as the softmax, and the weighted average of the value is taken as an expression strongly related to the query. In an embodiment of the present invention, the violation point description information can be used as the query, the candidate image features can be used as the keys, and the value is the similarity between the candidate image features and the query. The features of the violation point description information can be obtained by averaging or weighted averaging the values, which are referred to as violation description features in this article.

[0113] Then, the negative gradient adjustment method can be used to update the text features of the target description text using the violation description features. Specifically, the text features of the target description text can be updated using the following formula:

[0114] F 新描述 =F 原描述 -η·▽F 违规

[0115] Among them, F 新描述 refers to the updated text features, F 原描述 refers to the text features of the original target description text, η is the learning rate, which can be set according to actual needs, and F 违规 Refers to the violation description characteristics, ▽F 违规 Indicates the gradient direction that generates the illegal image.

[0116] In a possible embodiment, the iteration rounds can be preset, and after adjusting the preset iteration rounds according to the above negative gradient adjustment method, a new target text code can be output based on the updated text features. It is also possible to calculate the semantic similarity between the updated text features and the original text features after each update, and if the semantic similarity is within a preset range, a new target text code can be output based on the updated text features. The text-generated graph model can then regenerate candidate images based on the new target text code and perform a security audit.

[0117] As a possible implementation, the above process of obtaining the violation description feature using the cross-attention mechanism and performing negative gradient adjustment on the original text feature based on the violation description feature can be performed through a preset loop feedback mechanism, which may include a cross-attention mechanism and a negative gradient adjustment mechanism. That is, if the candidate image is unsafe, the multimodal large model can output the above candidate image features and violation description information as inputs to the loop feedback mechanism, and the cross-attention mechanism in the loop feedback mechanism can output the violation description feature based on the candidate image features and the violation description information, and update the text features of the target description text based on the violation description feature through the negative gradient adjustment mechanism, and input it into the large language model.

[0118] like Figure 4 As shown, Figure 4 A flow chart of a security image generation method provided in an embodiment of the present invention. Specifically, a user inputs a target description text into a large language model, and the large language model outputs a target text encoding for the target description text. The target text encoding is input into a multimodal large model and a text image large model.

[0119] The text-based image model generates an image (image on the left) based on the target text encoding and inputs it into the multimodal large model. The multimodal large model determines whether the image is compliant based on pre-defined rules. If the image does not comply with the rules, it will feedback abnormal information to the large language model. The abnormal information includes the description of the violation points output by the multimodal large model for the image and the features extracted from the image.

[0120] The large language model modifies the target description text or extracts features from the target description text based on the feature and the violation description information, thereby outputting a new target text encoding. The text-generated graph model regenerates the image (the image on the right) based on the new target text encoding, and inputs the image into the multimodal large model. Once the image passes the security review, it can be output to the user.

[0121] By applying the embodiment of the present invention, a feedback mechanism is proposed based on the integration of a multimodal large model and a text-generated image large model, that is, when the output image is unsafe, the input description text or the features of the description text are modified. Through loop iteration, the security requirements are met under the premise of ensuring semantic integrity, ensuring that the image content generated when the user provides the image description meets the security standards, and at the same time improving the efficiency of generating secure images. Moreover, the security standards can be customized by the user, flexibly adapting to a variety of application scenarios, and solving the security requirements in different scenarios.

[0122] Based on the same inventive concept, the embodiment of the present invention also provides a security image generating device, such as Figure 5 As shown, the apparatus 500 may include:

[0123] An acquisition module 501 is used to acquire a target description text;

[0124] An encoding module 502 is used to output a target text encoding for the target description text using a preset large language model;

[0125] A generating module 503 is used to generate candidate images based on the target text encoding by using a preset text-generated image model;

[0126] A judgment module 504 is used to determine whether the candidate image is safe based on preset safety rules using a preset detection model;

[0127] Feedback module 505 is used to feed back abnormal information to the preset large language model when the candidate image is unsafe, so that the preset large language model outputs a new target text encoding based on the abnormal information and the semantics of the target description text; return to the step of generating a candidate image based on the target text encoding by using the preset text-image model until the candidate image is safe;

[0128] The output module 506 is configured to output the safe candidate image as a target image.

[0129] In a possible embodiment, the abnormal information includes: description information of the violation points in the candidate image;

[0130] The preset large language model outputs a new target text encoding through the following steps:

[0131] Based on the violation point description information, modify the text related to the violation point description information in the target description text to obtain an updated description text;

[0132] A target loss is obtained based on a semantic loss and an avoidance loss, wherein the semantic loss is a semantic loss between the updated description text and the target description text, the avoidance loss is an avoidance loss between the updated description text and the violation point description information, and the target loss is positively correlated with the semantic loss and negatively correlated with the avoidance loss;

[0133] Adjusting the updated description text based on the target loss until the target loss converges;

[0134] A new target text encoding is output based on the updated description text when the target loss converges.

[0135] In a possible embodiment, the abnormal information includes: candidate image features and description information of illegal points in the candidate image;

[0136] The step of outputting a target text encoding for the target description text using a preset large language model includes:

[0137] Extracting text features of the target description text using the preset large language model;

[0138] Outputting the target text encoding based on the text features;

[0139] The preset large language model outputs a new target text encoding through the following steps:

[0140] Using a cross attention mechanism, determining each feature point in the candidate image features that is associated with the violation point description information as a violation description feature;

[0141] Using the violation description feature to adjust the text feature using a negative gradient adjustment method to obtain an updated text feature;

[0142] Based on the updated text features, a new target text encoding is obtained.

[0143] Among them, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in the present invention are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0144] The exemplary embodiment of the present invention further provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and the computer program is used to enable the electronic device to perform a method according to an embodiment of the present invention when executed by the at least one processor.

[0145] Exemplary embodiments of the present invention also provide a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform a method according to an embodiment of the present invention.

[0146] An exemplary embodiment of the present invention further provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor of a computer, the computer is used to enable the computer to perform a method according to an embodiment of the present invention.

[0147] refer to Figure 6, a block diagram of an electronic device 600 that can be used as a server or client of the present invention will now be described, which is an example of a hardware device that can be applied to various aspects of the present invention. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0148] like Figure 6 As shown, the electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0149] A plurality of components in the electronic device 600 are connected to the I / O interface 605, including: an input unit 606, an output unit 607, a storage unit 608, and a communication unit 609. The input unit 606 may be any type of device capable of inputting information to the electronic device 600, and the input unit 606 may receive input digital or character information, and generate key signal inputs related to user settings and / or function control of the electronic device. The output unit 607 may be any type of device capable of presenting information, and may include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 608 may include, but is not limited to, a disk, an optical disk. The communication unit 609 allows the electronic device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth™ device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0150] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above. For example, in some embodiments, any of the above-described security image generation methods may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via the ROM 602 and / or the communication unit 609. In some embodiments, the computing unit 601 may be configured to perform any of the above-described security image generation methods in any other appropriate manner (e.g., by means of firmware).

[0151] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0152] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0153] As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0154] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0155] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0156] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.

Claims

1. A method for generating a secure image, It is characterized in that The method comprises: Get the target description text; Outputting a target text encoding for the target description text using a preset large language model; Generate candidate images based on the target text encoding using a preset text-image model; Determining whether the candidate image is safe based on preset safety rules using a preset detection model; In the case where the candidate image is unsafe, the abnormal information is fed back to the preset large language model, so that the preset large language model outputs a new target text encoding based on the abnormal information and the semantics of the target description text; and the step of generating the candidate image based on the target text encoding by using the preset text-image model is returned until the candidate image is safe; The safe candidate image is output as a target image.

2. The method according to claim 1, It is characterized in that The abnormal information includes: description information of the illegal points in the candidate image; The preset large language model outputs a new target text encoding through the following steps: Based on the violation point description information, modify the text related to the violation point description information in the target description text to obtain an updated description text; A target loss is obtained based on a semantic loss and an avoidance loss, wherein the semantic loss is a semantic loss between the updated description text and the target description text, the avoidance loss is an avoidance loss between the updated description text and the violation point description information, and the target loss is positively correlated with the semantic loss and negatively correlated with the avoidance loss; Adjusting the updated description text based on the target loss until the target loss converges; A new target text encoding is output based on the updated description text when the target loss converges.

3. The method according to claim 2, It is characterized in that The semantic loss is the semantic similarity between the updated description text and the target description text, the avoidance loss is the semantic similarity between the updated description text and the violation point description information, and the target loss is obtained by the following formula: L=αL 1 -βL 2 Among them, L is the target loss, L 1 is the semantic loss, L 2 is the avoidance loss, α is the first preset weight, and β is the second preset weight.

4. The method according to claim 1, It is characterized in that The abnormal information includes: candidate image features and description information of illegal points in the candidate image; The step of outputting a target text encoding for the target description text using a preset large language model includes: Extracting text features of the target description text using the preset large language model; Outputting the target text encoding based on the text features; The preset large language model outputs a new target text encoding through the following steps: Using a cross attention mechanism, determining each feature point in the candidate image features that is associated with the violation point description information as a violation description feature; Using the violation description feature to adjust the text feature using a negative gradient adjustment method to obtain an updated text feature; Based on the updated text features, a new target text encoding is obtained.

5. The method according to claim 1, It is characterized in that The preset safety rules include text rules and image rules. The text rules include description information of violation points, and the image rules include images with violation points marked.

6. A safety image generating device, It is characterized in that The device comprises: An acquisition module is used to obtain the target description text; An encoding module, used for outputting a target text encoding for the target description text using a preset large language model; A generation module, used for generating candidate images based on the target text encoding by using a preset text-image model; A judgment module, used to determine whether the candidate image is safe based on preset safety rules using a preset detection model; A feedback module is used to feed back abnormal information to the preset large language model when the candidate image is unsafe, so that the preset large language model outputs a new target text encoding based on the abnormal information and the semantics of the target description text; and return to the step of generating a candidate image based on the target text encoding by using the preset text-image model until the candidate image is safe; An output module is used to output the safe candidate image as a target image.

7. The device according to claim 6, It is characterized in that The abnormal information includes: description information of the illegal points in the candidate image; The preset large language model outputs a new target text encoding through the following steps: Based on the violation point description information, modify the text related to the violation point description information in the target description text to obtain an updated description text; A target loss is obtained based on a semantic loss and an avoidance loss, wherein the semantic loss is a semantic loss between the updated description text and the target description text, the avoidance loss is an avoidance loss between the updated description text and the violation point description information, and the target loss is positively correlated with the semantic loss and negatively correlated with the avoidance loss; Adjusting the updated description text based on the target loss until the target loss converges; A new target text encoding is output based on the updated description text when the target loss converges.

8. The device according to claim 6, It is characterized in that The abnormal information includes: candidate image features and description information of illegal points in the candidate image; The step of outputting a target text encoding for the target description text using a preset large language model includes: Extracting text features of the target description text using the preset large language model; Outputting the target text encoding based on the text features; The preset large language model outputs a new target text encoding through the following steps: Using a cross attention mechanism, determining each feature point in the candidate image features that is associated with the violation point description information as a violation description feature; Using the violation description feature to adjust the text feature using a negative gradient adjustment method to obtain an updated text feature; Based on the updated text features, a new target text encoding is obtained.

9. An electronic device, include: processor; as well as Memory for storing programs, The program includes instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 5.

10. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to make a computer execute the method according to any one of claims 1-5.

Citation Information

Cited By

  • Method and apparatus for generating picture, computing device and computer program product

    CN120032002A

  • Method and apparatus for generating image, computing device and program product

    CN120451295A

  • Image processing method and device, computer equipment and storage medium

    CN121527596A