Image generation method, device, electronic device and computer readable storage medium
By calling the overfitting state image fine-tuning model and other image fine-tuning models, the target image that meets the preset style is generated, which solves the problem that the image generation model in the prior art is difficult to meet the image style of the project matching, and achieves the balance of image quality and style.
Patent Information
- Application Number
- CN202311276479.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2025-04-08
AI Technical Summary
In actual business application requirements, it is difficult to generate image styles that meet project matching, and the image quality cannot meet actual needs.
By calling at least two image fine-tuning models, at least one of which is in an overfit state, the target image is generated based on the first sample image training of the preset style, and combined with other image fine-tuning models, the image style transfer is realized.
While ensuring the quality of the output image, image style migration is achieved so that the generated target images meet the actual business application needs.
Smart Images

Figure CN119784888A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image generating method, device, electronic device and computer-readable storage medium. Background Art
[0002] Artificial Intelligence (AI) painting is a way of computer-generated painting. AI painting mainly consists of two parts: one is the analysis and judgment of the image, i.e. "learning", and the other is the processing and restoration of the image, i.e. "output". With the rapid development of AI painting technology, AI has been continuously learning from tens of thousands of images and paintings. Nowadays, it has reached the point where you only need to input clear and easy-to-understand text descriptions to get a good image in a very short time.
[0003] However, for actual business application needs, the quality of images produced by some image generation models cannot meet the standards of actual business application needs, for example, the image style cannot meet the project matching requirements. Therefore, it is urgent to propose a method for generating AI images that can meet the actual business application needs while ensuring the quality of the output images.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] In view of this, the embodiments of the present application at least provide an image generation method, device, electronic device and computer-readable storage medium, which achieve the purpose of image style transfer while ensuring the quality of the output image, so that the generated target image meets the actual business application needs.
[0006] This application mainly includes the following aspects:
[0007] In a first aspect, an embodiment of the present application provides an image generation method, the method comprising: obtaining target indication information for generating a target image; calling at least two image fine-tuning models, and generating the target image satisfying a preset style according to the target indication information; wherein, among the at least two image fine-tuning models, there is at least one first fine-tuning model that is in an overfitting state, and the first fine-tuning model is trained based on a first sample image of the preset style.
[0008] In a second aspect, an embodiment of the present application also provides an image generating device, comprising: an acquisition module, used to acquire target indication information for generating a target image; a generation module, used to call at least two image fine-tuning models, and generate the target image satisfying a preset style according to the target indication information; wherein, among the at least two image fine-tuning models, there is at least one first fine-tuning model that is in an overfitting state, and the first fine-tuning model is trained based on a first sample image of the preset style.
[0009] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor to execute the steps of the image generation method described in the first aspect or any possible implementation manner of the first aspect.
[0010] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the image generation method described in the first aspect or any possible implementation manner of the first aspect are executed.
[0011] The image generation method, device, electronic device and computer-readable storage medium provided in the embodiments of the present application can generate a target image that meets a preset style by calling at least two image fine-tuning models including a first fine-tuning model in an overfitting state, and generating target indication information of the target image according to the indication. Compared with the actual business application needs in the related art, the quality of the images output by some image generation models cannot meet the standards of the actual business application needs, for example, the image style cannot meet the project matching. The present application can achieve the purpose of quickly learning the image style that matches the project by calling the image fine-tuning model in the "overfitting" state, and then achieve the purpose of image style transfer while ensuring the quality of the output image by superimposing other image fine-tuning models, thereby making the generated target image meet the actual business application needs.
[0012] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0014] Figure 1 A flow chart of an image generation method provided by an embodiment of the present application is shown;
[0015] Figure 2 A flowchart of another image generation method provided in an embodiment of the present application is shown;
[0016] Figure 3 One of the functional module diagrams of an image generating device provided in an embodiment of the present application is shown;
[0017] Figure 4 A second functional module diagram of an image generating device provided in an embodiment of the present application is shown;
[0018] Figure 5 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0019] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art, under the guidance of the content of the present application, can add one or more other operations to the flowchart, or remove one or more operations from the flowchart.
[0020] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0021] In order to enable those skilled in the art to use the contents of this application, the following implementation methods are given in combination with the specific application scenario "AI image generation". For those skilled in the art, the general principles defined here can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application.
[0022] The following methods, devices, electronic devices or computer-readable storage media of the embodiments of the present application can be applied to any scenario requiring AI image generation. The embodiments of the present application are not limited to specific application scenarios. Any scheme using the image generation method and device provided by the embodiments of the present application is within the scope of protection of the present application.
[0023] The embodiments of the present application provide an image generation method, device, electronic device, and computer-readable storage medium. Specifically, the embodiments of the present application provide an image generation method applicable to an image generation device, and the image generation device can be integrated in an electronic device.
[0024] Here, the electronic device can be a terminal or other device, including but not limited to mobile terminals and fixed terminals. For example, mobile terminals include but are not limited to smart phones, smart watches, tablet computers, laptops, smart car terminals, etc., among which fixed terminals include but are not limited to desktop computers, smart TVs, etc.
[0025] In addition, the electronic device can also be a server or other device. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms, but is not limited to these.
[0026] The image generation method of the embodiment of the present application can be implemented by a terminal or a server.
[0027] It is worth noting that before this application was submitted, the quality of images produced by some image generation models could not meet the standards of actual business application needs, for example, the image style could not meet the requirements of project matching.
[0028] In view of the above problems, the embodiment of the present application can generate a target image that meets the preset style by calling at least two image fine-tuning models including a first fine-tuning model in an overfitting state, and generating the target image according to the target indication information; wherein the first fine-tuning model is obtained by training based on the first sample image of the preset style. In this way, while ensuring the quality of the output image, the purpose of image style transfer is achieved, so that the generated target image meets the actual business application requirements.
[0029] To facilitate understanding of the present application, the technical solution provided by the present application is described in detail below in conjunction with specific embodiments. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0030] like Figure 1 As shown, Figure 1 This is a flow chart of an image generation method provided in an embodiment of the present application. The image generation method provided in an embodiment of the present application comprises the following steps:
[0031] S101: Acquire target indication information for generating a target image.
[0032] Here, the target image is the image that the user indicates needs to be generated. The target indication information is used to indicate the image content information and image style information of the target image that is finally generated. Here, the image style of the target image should meet the preset style. Among them, the target indication information can be text indication information, that is, "image" is generated through "text", and the target indication information can also be image indication information, that is, "image" is generated through "image". The text indication information can indicate the color of the target image to be generated, the image content contained, the image style, etc.; the image indication information can be a sample image, which can indicate the color of the target image to be generated, the image content contained, the image style, etc. For example, the "mountains and rivers" sample image can indicate that a target image of "mountains and rivers" with a realistic style needs to be generated.
[0033] In some optional embodiments, the target indication information may be natural language text (i.e., text indication information) input by the user through voice or keyboard, etc. For example, the target indication information may be "I want to generate an avatar that is mainly black and white and includes a puppy."
[0034] For another example, in actual business application requirements, if a user wants to generate a landscape image, the user can use text to describe the landscape features of the landscape image that the user wants to generate, such as "lakes", "mountains", "grassland", etc.
[0035] In actual application, users can use natural language to describe their requirements for the generated target image when inputting text descriptions. The image generation model can understand this text description and convert it into text features, thereby affecting the final generated image results. In other words, users can intuitively control the generation process of the target image using natural language.
[0036] It is understandable that the entire text input by the user can be directly used as the target indication information, or the keywords obtained by processing the text description input by the user can be used as the target indication information. For example, the text description input by the user can be "I want to generate a landscape image with a forest as the main object and a realistic style", in which case the keywords "forest", "landscape", "realistic style" can be extracted from it as the target indication information, etc.
[0037] S102: Call at least two image fine-tuning models to generate the target image that meets a preset style according to the target indication information.
[0038] Among the at least two image fine-tuning models, there is at least one first fine-tuning model in an overfitting state, and the first fine-tuning model is trained based on a first sample image of the preset style.
[0039] It should be noted that the target image can be generated by calling at least two image fine-tuning models in any image generation model. Here, the image generation model is a model for intelligently generating images, which generally supports the "text generation image" function and the "image generation image" function. The image generation model can use artificial intelligence algorithms and deep learning technologies to automatically generate fine art painting images through training models, which can not only bring new ideas and inspiration to creation, but also improve creation efficiency and quality. Usually, the user can generate an image corresponding to the text indication information by inputting text indication information into the image generation model. Here, the image generation model is, for example, a deep learning model (Generative Adversarial Networks, GAN), a generation model based on an encoder-decoder framework (Variational Autoencoder, VAE), a GAN-based image generation model (StyleGAN), an image conversion model based on adversarial training (CycleGAN), a machine learning model (Stable Diffusion), and the like.
[0040] Among them, Stable Diffusion is also an AI painting tool. After training, it can gradually denoise random Gaussian noise to obtain samples of interest, such as generating images. Through Stable Diffusion, it is easy to generate corresponding pictures through text descriptions.
[0041] However, for actual business application needs, the quality of images produced by some image generation models cannot meet the standards of actual business application needs, for example, they cannot meet the image style matching of the project. Specifically, the training samples used by image generation models are usually diverse and different in image art style, which is suitable for the generation of general style images, but the generalization ability for some specific style images is weak.
[0042] Based on the above situation of the image generation model, it is considered that a model can be customized for a specific image style, such as an image fine-tuning model. Considering that the image fine-tuning model can be used in combination with the image generation model when generating images, the output image result can be adjusted. Furthermore, the trained image fine-tuning model can be directly used to fine-tune the image generation model to achieve the purpose of image style transfer, and images that match the image style required by the project to a certain extent can be generated, thereby producing images that meet the actual business application needs to a certain extent.
[0043] In some optional embodiments, the preset style in the present application is predetermined according to the image style corresponding to the actual business needs. A large number of sample images of the preset style can be obtained in advance, and the image fine-tuning model can be trained based on these sample images, so that the image fine-tuning model can learn the preset style, so that in actual applications, the output target image can have the preset style through the image fine-tuning model.
[0044] Here, image style can be understood as the subjective feeling that an image brings to the viewer, and image style can be reflected through the color, texture, etc. in the image. For example, images created by different people generally have different personal characteristics, and this personal characteristic is shown through the image as style. For example, each person's paintings generally have their own personal style, so each person's paintings can form their own distinctive and unique style. For example, Van Gogh's paintings have a distinct "Van Gogh style"; Da Vinci's paintings have a distinct "Da Vinci style", and so on. Alternatively, images can also be divided into multiple image styles based on the composition of the image. For example, image styles can be divided into impressionistic style, abstract style, realistic style, and so on. Alternatively, images can also be divided into multiple styles based on the material used to create the image or the texture of the image. For example, images can be divided into oil painting style, comic style, watercolor style, ink painting style, and so on. Textures such as traditional Chinese cloud patterns, simple flat graphics, and so on.
[0045] It should be noted that the image fine-tuning model is a "small model" trained and generated under a "big model (image generation model)". Simply put, the image fine-tuning model is a small fine-tuned model of the big model, that is, the image fine-tuning model is used to fine-tune the big model. Among them, the image fine-tuning model is like the low-rank adapter of large language models (LoRA), that is, the low-rank adaptation version of the large model. The LoRA model can adjust the characters in the image, the style in the image, etc. Therefore, the LoRA model can produce images that meet actual business needs to a certain extent. In addition, compared with the large model, the LoRA model has a small file size, is more convenient to call and is more controllable.
[0046] It can be understood that according to the different adjustment contents of the LoRA model, the LoRA model can be divided into multiple different LoRA models, such as character LoRA model, style LoRA model, background LoRA model, avatar frame LoRA model, prop icon LoRA model, interface icon LoRA model, accessories LoRA model, fashion LoRA model, etc.
[0047] Based on the above findings, how to use the image generation model and the image fine-tuning model together to generate target images that meet the standards of actual business application needs needs further in-depth thinking. In this regard, after a large number of experiments and tests, on the one hand, it was found that two or more different image fine-tuning models can be superimposed and used. For example, it is theoretically feasible to use a character image fine-tuning model and a style image fine-tuning model at the same time. In this way, the generated target image can have a fusion of different image styles, or a fusion of image style and image depiction details, etc., to meet the actual business application needs to a certain extent; on the other hand, it was found that compared with the normal state of the image fine-tuning model, the generalization and expression capabilities of the sample image style are stronger, so the "overfitting state" image fine-tuning model can more perfectly grasp the sample image style, so that the requirements of matching the image style corresponding to the project in the actual business application needs can be met.
[0048] For the first aspect mentioned above, specifically, at least two image fine-tuning models of different types are superimposed. For example, if the image generation model calls two image fine-tuning models, where the first fine-tuning model is a background LoRA model and the second fine-tuning model is an avatar frame LoRA model, the background LoRA model is used to learn the style feature information of the first sample image of a preset style, and the avatar frame LoRA model is used to learn the detail feature information of the second sample image. In this way, the image generation model can be fine-tuned to achieve the purpose of detail supplement and style migration.
[0049] Regarding the second aspect mentioned above, specifically, model training usually avoids overfitting and pursues fitting to improve the ability to learn from one example and apply it to other cases. However, the image output in this normal state is generally indicative of the style, and the background layer of the generated image is relatively messy, which cannot meet the needs of specific image styles in actual business needs. Therefore, the embodiment of the present application deliberately uses an image fine-tuning model that is close to the "overfitting" state. A simple explanation of "overfitting" is that the model output picture is too similar to the sample picture, and the model training pursues the "fitting state" to achieve the purpose of perfectly mastering the style of the sample image.
[0050] Here, the embodiment of the present application achieves the purpose of quickly learning the preset style by intentionally obtaining an image fine-tuning model that is in an "overfitting" state, and then superimposes the image fine-tuning model for use, thereby generating a target image that meets the style requirements of the project in the image generation model, and the target image can meet the standards of actual business application requirements.
[0051] Moreover, the embodiments of the present application not only enhance the usability of the image fine-tuning model in an overfitting state, but also can better utilize the model that seems to have failed training, and can efficiently produce target images that meet actual business needs, which can help art practitioners better utilize image generation models for creative assistance.
[0052] In the embodiment of the present application, by calling at least two image fine-tuning models including a first fine-tuning model in an overfitting state, and generating target indication information of a target image according to an indication, a target image that meets a preset style can be generated; wherein the first fine-tuning model is obtained by training based on a first sample image of the preset style. In this way, while ensuring the quality of the output image, the purpose of image style transfer is achieved, so that the generated target image meets the actual business application requirements.
[0053] like Figure 2 As shown, Figure 2 This is a flowchart of another image generation method provided in an embodiment of the present application. The image generation method provided in an embodiment of the present application comprises the following steps:
[0054] S201: Acquire target indication information for generating a target image.
[0055] S202: According to the preset weights respectively configured for the at least two image fine-tuning models, the at least two image fine-tuning models are called into the image generation model, and the target image satisfying the preset style is generated according to the target indication information.
[0056] Here, considering that the image fine-tuning model is a "plug-in" that affects the image generation model, by configuring different weights for the image fine-tuning model, the image results output by the image generation model can be adjusted to varying degrees. However, if the configured weight is too high, it will cause serious deformation of the entire output image. If the configured weight is too small, the entire output image will not be adjusted to the expected effect. The image output results of the image fine-tuning model under different weights, for example, when the weight is 0, there is actually no effect. When the weight reaches above 0.5, it may start to produce broken images. For some image fine-tuning models, even the painting style and background style will change at 0.3. Therefore, in actual use, they will start from 0.1 and slowly increase to test the limit that the image generation model can tolerate without deformation.
[0057] In addition, different image fine-tuning models have different degrees of interference with the image generation model, and the weight settings of different image fine-tuning models are usually different, so the preset weights need to be configured based on the test results. For this application, at least two image fine-tuning models are involved in calling the image generation model, so it also involves the impact of different weight combinations on the image generation model. It should be understood that for different combinations of image fine-tuning models, the configured weight combinations are also different, and the configuration of the weight combination depends on the final output image quality effect.
[0058] In a specific implementation, preset weights can be configured in advance for at least two trained image fine-tuning models to be called by the image generation model. The specific weight values of the preset weights here are mainly set based on the test results of whether the image output by the image generation model meets the actual business needs, that is, the size of the preset weight is set according to the output image effect and quality of the actual business needs. For at least two image fine-tuning models, it also involves the influence of the combination of at least two preset weights on the image output effect. Therefore, the setting of the preset weights is also affected by the relationship between the at least two image fine-tuning models. Only when the preset weights of the at least two image fine-tuning models can satisfy the image results output by the image generation model to meet the actual business needs, in this way, by calling the at least two image fine-tuning models superimposed with preset weights by the image generation model, the output effect of the target image can be further improved to meet the expected needs.
[0059] Here, the user needs to configure the preset weights for each image fine-tuning model called in the UI interface before instructing to generate the target image. The preset weights can be entered manually or automatically filled in based on the test results of the image generation model.
[0060] In one example, if the image generation model calls two image fine-tuning models, where the first fine-tuning model is the background LoRA model and the second fine-tuning model is the avatar frame LoRA model, the preset weight configured for the background LoRA model is the first preset weight, and the preset weight configured for the avatar frame LoRA model is the second preset weight. For example, the first preset weight of the background LoRA model is set to 1, and the second preset weight of the avatar frame LoRA model is set to 0.6. When the first preset weight of the background LoRA model is less than 1, the output image will be more biased towards the composition logic of the avatar frame (the "ring" image feature appears), rather than the composition logic of the background, so the first preset weight of the background LoRA model can be fixed to 1. Similarly, if the second preset weight of the avatar frame LoRA model is between 0.6 and 1, the ring composition will affect the image quality produced by the background LoRA model, and when the second preset weight is less than 0.6, the refined features will be lost. Therefore, the first preset weight of the background LoRA model can be fixed to 1, and the second preset weight of the avatar frame LoRA model can be set to 0.6. Under such a weight combination, an image that meets the business application requirements can be output.
[0061] In some optional embodiments, before S201 obtains the target indication information for generating the target image, it also includes determining the preset weights respectively configured for the at least two image fine-tuning models according to the following steps: obtaining multiple weight combinations corresponding to the at least two image fine-tuning models; calling the at least two image fine-tuning models configured with the weight combination into the image generation model, and obtaining the first image according to the test indication information; respectively determining the degree of match between the first image obtained based on the weight combination and the preset style; based on the degree of match between the first image obtained by the weight combination and the preset style, determining the preset weights respectively configured for the at least two image fine-tuning models.
[0062] Here, the ratio setting of the weights of at least two image fine-tuning models is determined by modifying the weights multiple times and outputting the image effect results of the AI picture. In a specific implementation, after completing the training of the at least two image fine-tuning models respectively, under each weight combination, the at least two image fine-tuning models configured with the weight combination are called into the image generation model, and the first image is obtained according to the test indication information. Then, the preset weights of the at least two image fine-tuning models finally used for the call are selected according to the degree of match between the image effect of the first image and the preset style.
[0063] Here, when comparing the output image effects of an image generation model that calls at least two image fine-tuning models with different weight combinations, you can use an XYZ chart to set the weights and generate a comparison chart based on your needs, so you can more easily observe the impact of different weight values on the output image. For numerical parameters, the XYZ chart can directly input a value or a range.
[0064] In some optional embodiments, before actually using the image generation model to call at least two image fine-tuning models to generate the target image, it is necessary to train each image fine-tuning model separately. Here, the training process of the first fine-tuning model in the overfitting state is first described. The first fine-tuning model includes the background LoRA model, and the background LoRA model is trained according to the following steps: obtaining the first sample image corresponding to the preset style and the first annotation information corresponding to the first sample image; based on the first sample image, the first annotation information corresponding to the first sample image, and calling the image generation model with the first initial LoRA model, the first initial LoRA model is iteratively trained, and when the first initial LoRA model reaches the overfitting condition, the network parameters in the first initial LoRA model are stopped from being updated to generate the background LoRA model in the overfitting state.
[0065] It should be noted that since the first fine-tuning model provided in the present application is a model in an overfitting state, the training process of the first fine-tuning model is different from the training process of the normal fine-tuning model. The specific difference lies in the model training cutoff condition. The training cutoff condition of the first fine-tuning model in the embodiment of the present application is that the first initial LoRA model reaches the overfitting condition.
[0066] Here, the first fine-tuning model is taken as an example of the background LoRA model. The background LoRA model is trained based on a first sample image (background image) of a preset style and the first annotation information corresponding to the first sample image, wherein the first annotation information includes one or more of the following: image style information, subject information, and image texture information of the first sample image. For example, the first annotation information is "ink painting style + mountain + cloud pattern". Usually, high-quality background material images are selected in the project, and each background material image is cropped to a preset size as the first sample image, and the first sample image is annotated to obtain the first annotation information.
[0067] It should be noted that the annotation information of the sample image can be annotated using an automatic annotation tool or manually.
[0068] In some optional embodiments, the present application provides two methods for determining whether the first initial LoRA model reaches the overfitting condition. Method 1 is to determine whether the first initial LoRA model reaches the overfitting condition according to the following steps: input the first sample image into the image generation model that calls the first initial LoRA model to obtain a first output image; determine the similarity between the first output image and the corresponding first sample image; based on the similarity between the first output image and multiple first sample images in a preset ratio, determine whether the first initial LoRA model reaches the overfitting condition.
[0069] In a specific implementation, in the judgment of the overfitting condition, the first output image produced by the image generation model can be compared with the first sample image. If the similarity between most of the first output images output by the image generation model and the corresponding training sample set (first sample image) is greater than a preset threshold, it means that the first initial LoRA model has learned the feature information of the first sample image set, that is, it has perfectly mastered the preset style of the first sample image. In this case, it can be determined that the first initial LoRA model has reached the overfitting condition. Here, the preset ratio can be set according to the actual business application requirements, for example, set to 80%.
[0070] In some optional embodiments, method two, determining whether the first initial LoRA model reaches the overfitting condition according to the following steps: calling the first initial LoRA model in the image generation model, generating a second output image according to the first sample indication information, and generating a third output image according to the second sample indication information; the image visual elements of the first sample indication information and the second sample indication information are different; based on the difference between the second output image and the third output image, determining whether the first initial LoRA model reaches the overfitting condition.
[0071] In the specific implementation, in the judgment of overfitting conditions, it is also possible to make a judgment based on the difference of the output images corresponding to the different sample indication information before and after. For example, the output images of sample indication information with different image visual elements have little or no change in visual factors, indicating that the model has reached an overfitting state and cannot "learn from one example and apply it to other situations", that is, it has achieved the purpose of full learning. Even if the visual factors in the sample indication information are changed, the output images still have a large similarity, and will not change or change to a small extent due to a slight change in the sample indication information. In this case, it can also be determined that the first initial LoRA model has reached the overfitting condition.
[0072] Among them, the image visual elements are the basic elements that constitute the image and are the basis for the image to express information. There are many aspects to consider for the composition of image visual elements, such as shape, color, texture, etc. In one example, the first sample indication information includes green, and the second sample indication information includes blue.
[0073] It should be understood that in normal AI model training, an overfitting model is not used directly, but training is continued until a relatively optimal model is trained. However, this application intentionally outputs a model with an overfitting tendency in order to learn the project style to the greatest extent possible.
[0074] In some optional embodiments, before training the first initial LoRA model, the method also includes: pre-setting target values of training parameters for training the first initial LoRA model; based on each first sample image and the first annotation information corresponding to each first sample image, and calling the image generation model with the first initial LoRA model, iteratively training the first initial LoRA model, including: iteratively training the first initial LoRA model according to the first sample image, the first annotation information corresponding to the first sample image, the target values of the training parameters, and calling the image generation model with the first initial LoRA model; wherein the target values of the training parameters are values that make the degree of model overfitting meet a preset degree threshold.
[0075] In one example, if the purpose of the first fine-tuning model is to adjust the image style, for example, the first fine-tuning model is a background LoRA model, and the LoRA model mainly focuses on color learning and style learning in the image.
[0076] Here, when training any model, it is necessary to set the training parameters in advance. The specific values of the training parameters will have a certain impact on the training effect of the model. The specific values of some training parameters will also affect the overfitting degree of the model. That is, there is a certain correlation between the training parameters and the overfitting degree of the model. Therefore, how to select the specific values of the training parameters is very important.
[0077] Here, the training parameters include but are not limited to the number of training learning steps, the total number of the first sample images, and the total number of learning times for the first sample images. The number of training learning steps is the number of learning steps for learning each first sample image. According to the common knowledge in the art, it is generally believed that the number of training learning steps for each image should be within a certain range, such as between 100 and 150 steps. The higher the number of learning steps, the higher the degree of overfitting of the model. Therefore, the first fine-tuning model trained can be made close to the overfitting state by adjusting the number of training learning steps for each image, that is, increasing the number of training learning times for the first sample image.
[0078] It should be noted that the indicators that affect the overfitting of the LoRA model are as follows: the number of training sample data sets (the total number of multiple first sample images), the number of training learning steps, the number of epochs (the number of times the AI has learned all the training sample data sets, etc.); among them, the more training sample data sets there are, the less likely it is to overfit, and the fewer training learning steps, the less likely it is to overfit.
[0079] Among them, 1 epoch means learning all training sample data sets only once, and 20 epochs means learning all training sample data sets 20 times. Total number of training steps = number of training sample data sets * number of training learning steps * number of epochs. For example, selecting 200 training learning steps, 100 training sample data sets, and 1 epoch can make the first fine-tuning model close to the overfitting state.
[0080] In some optional embodiments, for the second fine-tuning model in a normal state, the second fine-tuning model is trained according to the following steps: obtaining a second sample image containing a main object and second annotation information corresponding to the second sample image; the second sample image is an image after preprocessing the image background; based on the second sample image, the second annotation information corresponding to the second sample image, and calling the image generation model with the second initial LoRA model, the second initial LoRA model is iteratively trained, and when the second initial LoRA model reaches the training cutoff condition, the updating of the network parameters in the second initial LoRA model is stopped to obtain the second fine-tuning model.
[0081] Here, the first sample image and the second sample image have different contents involved in the selected sample images because the purposes of the trained models are different. For example, the first fine-tuning model is a background LoRA model, and the sample images used to train the background LoRA model are background images, such as landscape images. The second fine-tuning model is an avatar frame LoRA model, and the sample images used to train the avatar frame LoRA model are avatar frame images. For example, by stacking the background LoRA model and the avatar frame LoRA model for calling, different models can play different roles in the generation of the entire target image. The role of the background frame LoRA model is to make the target image have a preset style, and the role of the avatar frame LoRA model is to make the details of the target image richer, so as to obtain a target image that meets actual business needs.
[0082] For the second fine-tuning model, if the purpose of the second fine-tuning model is to depict details, the training sample image can be pre-processed with a pure background color, that is, a pure background color is added, and in the image annotation, background-related annotation words are added to make the main object of the avatar frame clearer, and when background-related words are input, the initial LoRA model can generate a cleaner avatar frame icon.
[0083] The training cutoff condition includes an overfitting condition. The second fine-tuning model can be a normal state model (ie, an optimal model) or an overfitting state model; whether the second fine-tuning model is a normal state or an overfitting state depends on the needs of actual business application requirements.
[0084] In some optional embodiments, if the second fine-tuning model is an avatar frame LoRA model, the second annotation information includes one or more of the following: the name of the second sample image, background color information and subject information, for example, avatar frame + bird + gray background.
[0085] In some specific embodiments, the specific implementation steps of the image generation method are illustrated. For example, the image generation model only calls two image fine-tuning models, a first fine-tuning model and a second fine-tuning model, wherein the first fine-tuning model is a background LoRA model, and the second fine-tuning model is an avatar frame LoRA model. The background LoRA model is used to realize image style transfer, and the avatar frame LoRA model is used to supplement details. Specifically, the image generation method in this specific embodiment may include the following steps:
[0086] Step 1: Preparation of training sample set.
[0087] Specifically, collect high-quality background material images in the project, crop them to a size of 512x512 pixels, for example, and select more than 100 high-quality material images.
[0088] Step 2: Perform text annotation on the sample set content.
[0089] Specifically, for example, the first sample image is labeled as: xxx style + main object in the image + texture name (for example: ink style, mountain, cloud pattern).
[0090] Step 3: Set training parameters.
[0091] Specifically, the image file and the annotation txt file are placed in the same folder, the number of training steps for each image is set to, for example, 200 steps, and other training parameters are adjusted to intentionally make the first fine-tuning model reach a state close to "overfitting".
[0092] Step 4: Start AI training.
[0093] Specifically, the above image data and standard information are sent to the image generation model for model fine-tuning training. After the background image LoRA model is trained in the above manner, the above steps are repeated to train the avatar frame LoRA model. Among them, the avatar frame images are mostly drawn by vectors, with higher accuracy and clearer main objects, which can facilitate the subsequent refinement of the generated image.
[0094] Step 5: Superposition and weighting of LoRA model.
[0095] Specifically, after completing the training of the two LoRA models, the background LoRA model weight is set to, for example, 1, and the avatar frame LoRA model weight is set to, for example, 0.6, to achieve the purpose of detail supplement and style migration.
[0096] Step 6: Output of target image.
[0097] Specifically, two LoRA models are called in the image generation model to generate target images that meet the project style and business requirements based on the input target indication information.
[0098] In the embodiment of the present application, by calling at least two image fine-tuning models including a first fine-tuning model in an overfitting state, and generating target indication information of a target image according to an indication, a target image that meets a preset style can be generated; wherein the first fine-tuning model is obtained by training based on a first sample image of the preset style. In this way, while ensuring the quality of the output image, the purpose of image style transfer is achieved, so that the generated target image meets the actual business application requirements.
[0099] Based on the same application concept, an image generating device corresponding to the image generating method provided in the above embodiment is also provided in the embodiment of the present application. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the image generating method in the above embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0100] like Figure 3 , Figure 4 As shown, Figure 3 This is one of the functional module diagrams of an image generating device 300 provided in an embodiment of the present application. Figure 4 FIG2 is a second functional module diagram of an image generating device 300 provided in an embodiment of the present application. Figure 3As shown, the image generating device 300 includes: an acquisition module 310, used to obtain target indication information for generating a target image; a generation module 320, used to call at least two image fine-tuning models, and generate the target image that satisfies a preset style according to the target indication information; wherein, among the at least two image fine-tuning models, there is at least one first fine-tuning model that is in an overfitting state, and the first fine-tuning model is trained based on a first sample image of the preset style.
[0101] In some optional embodiments, such as Figure 4 As shown, the generation module 320 includes a weight configuration unit 321 and a calling unit 322; the weight configuration unit 321 is used to configure the preset weights for the at least two image fine-tuning models respectively; the calling unit 322 is used to call the at least two image fine-tuning models into the image generation model, and generate the target image that meets the preset style according to the target indication information.
[0102] In some optional embodiments, such as Figure 4 As shown, the weight configuration unit 321 is used to determine the preset weights respectively configured for the at least two image fine-tuning models according to the following steps before obtaining the target indication information for generating the target image: obtaining multiple weight combinations corresponding to the at least two image fine-tuning models; calling the at least two image fine-tuning models configured with the weight combination into the image generation model, and obtaining the first image according to the test indication information; respectively determining the matching degree between the first image obtained based on the weight combination and the preset style; based on the matching degree between the first image obtained by the weight combination and the preset style, determining the preset weights respectively configured for the at least two image fine-tuning models.
[0103] In some optional embodiments, such as Figure 4 As shown, the at least two image fine-tuning models include at least a background LoRA model, and also include an avatar frame LoRA model or a prop icon LoRA model.
[0104] In some optional embodiments, such as Figure 4As shown, the image generating device 300 also includes a model training module 330, and the model training module 330 is used for the first fine-tuning model including the background LoRA model, and the background LoRA model is trained according to the following steps to obtain the first sample image corresponding to the preset style and the first annotation information corresponding to the first sample image; based on the first sample image, the first annotation information corresponding to the first sample image, and the image generation model calling the first initial LoRA model, the first initial LoRA model is iteratively trained, and when the first initial LoRA model reaches the over-fitting condition, the updating of the network parameters in the first initial LoRA model is stopped to generate the background LoRA model in an over-fitting state.
[0105] In some optional embodiments, the first annotation information includes one or more of the following: image style information, subject object information, and image texture information of the first sample image.
[0106] In some optional embodiments, such as Figure 4 As shown, the model training module 330 is specifically used to determine whether the first initial LoRA model reaches the overfitting condition according to the following steps: inputting the first sample image into the image generation model that calls the first initial LoRA model to obtain a first output image; determining the similarity between the first output image and the corresponding first sample image; based on the similarity between the first output image and multiple first sample images in a preset ratio, determining whether the first initial LoRA model reaches the overfitting condition.
[0107] In some optional embodiments, such as Figure 4 As shown, the model training module 330 is specifically used to determine whether the first initial LoRA model reaches the overfitting condition according to the following steps: calling the first initial LoRA model in the image generation model, generating a second output image according to the first sample indication information, and generating a third output image according to the second sample indication information; the image visual elements of the first sample indication information and the second sample indication information are different; based on the difference between the second output image and the third output image, determining whether the first initial LoRA model reaches the overfitting condition.
[0108] In some optional embodiments, such as Figure 4As shown, the image generating device 300 also includes a parameter setting module 340; the parameter setting module 340 is used to pre-set the target value of the training parameter for training the first initial LoRA model before training the first initial LoRA model; the first initial LoRA model is iteratively trained based on each first sample image and the first annotation information corresponding to each first sample image, and the image generation model that calls the first initial LoRA model, including: iteratively training the first initial LoRA model according to the first sample image, the first annotation information corresponding to the first sample image, the target value of the training parameter, and the image generation model that calls the first initial LoRA model; wherein the target value of the training parameter is a value that makes the degree of overfitting of the model meet a preset degree threshold.
[0109] In some optional embodiments, the training parameters include one or more of the following: the number of training learning steps, the total number of the first sample images, and the total number of learning times for the first sample images.
[0110] In some optional embodiments, the model training module 330 is specifically used to train a second fine-tuning model: obtain a second sample image containing a main object and second annotation information corresponding to the second sample image; the second sample image is an image after preprocessing the image background; based on the second sample image, the second annotation information corresponding to the second sample image, and calling the image generation model with a second initial LoRA model, iteratively train the second initial LoRA model, and when the second initial LoRA model reaches the training cutoff condition, stop updating the network parameters in the second initial LoRA model to obtain the second fine-tuning model.
[0111] In some optional embodiments, the training cutoff condition includes an overfitting condition.
[0112] In some optional embodiments, the second annotation information includes one or more of the following: the name of the second sample image, background color information, and subject object information.
[0113] In the embodiment of the present application, the target indication information for generating the target image is obtained by the acquisition module 310, and at least two image fine-tuning models including the first fine-tuning model in an overfitting state are called by the calling module 320, and the target indication information for generating the target image is generated according to the indication, so that the target image that meets the preset style can be generated; wherein the first fine-tuning model is obtained by training based on the first sample image of the preset style. In this way, while ensuring the quality of the output image, the purpose of image style transfer is achieved, so that the generated target image meets the actual business application requirements.
[0114] Based on the same application concept, see Figure 5 As shown, it is a schematic diagram of the structure of an electronic device 500 provided in an embodiment of the present application, including: a processor 510, a memory 520 and a bus 530, wherein the memory 520 stores machine-readable instructions executable by the processor 510, and when the electronic device 500 is running, the processor 510 communicates with the memory 520 through the bus 530, and the machine-readable instructions are executed by the processor 510 when running to perform the steps of the image generation method described in any of the above embodiments.
[0115] Specifically, when the machine-readable instructions are executed by the processor 510, the following processing can be performed: obtaining target indication information for generating a target image; calling at least two image fine-tuning models, and generating the target image that satisfies a preset style according to the target indication information; wherein, among the at least two image fine-tuning models, there is at least one first fine-tuning model that is in an overfitting state, and the first fine-tuning model is trained based on a first sample image of the preset style.
[0116] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: calling the at least two image fine-tuning models into the image generation model according to the preset weights respectively configured for the at least two image fine-tuning models, and generating the target image satisfying the preset style according to the target indication information.
[0117] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: before obtaining the target indication information for generating the target image, obtaining multiple weight combinations corresponding to the at least two image fine-tuning models; calling the at least two image fine-tuning models configured with the weight combination into the image generation model, and obtaining a first image according to the test indication information; respectively determining the degree of match between the first image obtained based on the weight combination and the preset style; and determining the preset weights respectively configured for the at least two image fine-tuning models based on the degree of match between the first image obtained based on the weight combination and the preset style.
[0118] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: obtaining a first sample image corresponding to the preset style and first annotation information corresponding to the first sample image; iteratively training the first initial LoRA model based on the first sample image, the first annotation information corresponding to the first sample image, and calling the image generation model with the first initial LoRA model, and when the first initial LoRA model reaches an overfitting condition, stopping the updating of the network parameters in the first initial LoRA model to generate the background LoRA model in an overfitting state.
[0119] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: input the first sample image into the image generation model that calls the first initial LoRA model to obtain a first output image; determine the similarity between the first output image and the corresponding first sample image; and determine whether the first initial LoRA model meets the overfitting condition based on the similarity between the first output image and multiple first sample images in a preset ratio.
[0120] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: calling the first initial LoRA model in the image generation model, generating a second output image according to the first sample indication information, and generating a third output image according to the second sample indication information; the image visual elements of the first sample indication information and the second sample indication information are different; based on the difference between the second output image and the third output image, determining whether the first initial LoRA model meets the overfitting condition.
[0121] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: before training the first initial LoRA model, iteratively train the first initial LoRA model according to the first sample image, the first annotation information corresponding to the first sample image, the target value of the training parameter, and the image generation model that calls the first initial LoRA model; wherein the target value of the training parameter is a value that makes the degree of overfitting of the model meet a preset degree threshold.
[0122] In some optional embodiments, when the machine-readable instructions are executed by the processor 510, the following processing may be performed: obtaining a second sample image containing a subject and second annotation information corresponding to the second sample image; the second sample image is an image after preprocessing the image background;
[0123] Based on the second sample image, the second annotation information corresponding to the second sample image, and the image generation model calling the second initial LoRA model, the second initial LoRA model is iteratively trained, and when the second initial LoRA model reaches the training cutoff condition, the updating of the network parameters in the second initial LoRA model is stopped to obtain the second fine-tuning model.
[0124] In the embodiment of the present application, in the image generation model, by calling at least two image fine-tuning models including the first fine-tuning model in an overfitting state, and generating the target image according to the target indication information, a target image that meets the preset style can be generated; wherein the first fine-tuning model is obtained by training based on the first sample image of the preset style. In this way, while ensuring the quality of the output image, the purpose of image style transfer is achieved, so that the generated target image meets the actual business application requirements.
[0125] Based on the same application concept, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the image generation method provided in the above embodiment are executed.
[0126] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the storage medium is run, the above-mentioned image generation method can be executed, and the machine-readable instructions can perform the following processing when executed by the processor 510: obtaining target indication information for generating a target image; calling at least two image fine-tuning models, and generating the target image that meets a preset style according to the target indication information; wherein, among the at least two image fine-tuning models, there is at least one first fine-tuning model that is in an overfitting state, and the first fine-tuning model is trained based on a first sample image of the preset style.
[0127] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: calling the at least two image fine-tuning models into the image generation model according to the preset weights respectively configured for the at least two image fine-tuning models, and generating the target image satisfying the preset style according to the target indication information.
[0128] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: before obtaining the target indication information for generating the target image, obtaining multiple weight combinations corresponding to the at least two image fine-tuning models; calling the at least two image fine-tuning models configured with the weight combination into the image generation model, and obtaining a first image according to the test indication information; respectively determining the degree of match between the first image obtained based on the weight combination and the preset style; and determining the preset weights respectively configured for the at least two image fine-tuning models based on the degree of match between the first image obtained based on the weight combination and the preset style.
[0129] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: obtaining a first sample image corresponding to the preset style and first annotation information corresponding to the first sample image; iteratively training the first initial LoRA model based on the first sample image, the first annotation information corresponding to the first sample image, and calling the image generation model with the first initial LoRA model, and when the first initial LoRA model reaches an overfitting condition, stopping the updating of the network parameters in the first initial LoRA model to generate the background LoRA model in an overfitting state.
[0130] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: input the first sample image into the image generation model that calls the first initial LoRA model to obtain a first output image; determine the similarity between the first output image and the corresponding first sample image; and determine whether the first initial LoRA model meets the overfitting condition based on the similarity between the first output image and multiple first sample images in a preset ratio.
[0131] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: calling the first initial LoRA model in the image generation model, generating a second output image according to the first sample indication information, and generating a third output image according to the second sample indication information; the image visual elements of the first sample indication information and the second sample indication information are different; based on the difference between the second output image and the third output image, determining whether the first initial LoRA model meets the overfitting condition.
[0132] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: before training the first initial LoRA model, iteratively train the first initial LoRA model according to the first sample image, the first annotation information corresponding to the first sample image, the target value of the training parameter, and the image generation model that calls the first initial LoRA model; wherein the target value of the training parameter is a value that makes the degree of overfitting of the model meet a preset degree threshold.
[0133] In some optional embodiments, the machine-readable instructions may perform the following processing when executed by the processor 510: obtaining a second sample image containing a subject and second annotation information corresponding to the second sample image; the second sample image is an image after preprocessing the image background; based on the second sample image, the second annotation information corresponding to the second sample image, and calling the image generation model with the second initial LoRA model, iteratively training the second initial LoRA model, and when the second initial LoRA model reaches the training cutoff condition, stopping the updating of the network parameters in the second initial LoRA model to obtain the second fine-tuning model.
[0134] In the embodiment of the present application, by calling at least two image fine-tuning models including a first fine-tuning model in an overfitting state, and generating target indication information of a target image according to an indication, a target image that meets a preset style can be generated; wherein the first fine-tuning model is obtained by training based on a first sample image of the preset style. In this way, while ensuring the quality of the output image, the purpose of image style transfer is achieved, so that the generated target image meets the actual business application requirements.
[0135] In the embodiment of the present application, the computer program can also execute other machine-readable instructions when run by the processor to execute other methods described in the embodiment. For the specific execution method steps and principles, please refer to the description of the embodiment, which will not be repeated here.
[0136] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0137] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0138] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0139] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0140] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.
[0141] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. An image generation method, characterized in that: The method comprises: Obtain target indication information for generating a target image; Calling at least two image fine-tuning models to generate the target image satisfying a preset style according to the target indication information; Among the at least two image fine-tuning models, there is at least one first fine-tuning model in an overfitting state, and the first fine-tuning model is trained based on a first sample image of the preset style.
2. The method according to claim 1, characterized in that The calling of at least two image fine-tuning models to generate the target image satisfying a preset style according to the target indication information includes: According to the preset weights respectively configured for the at least two image fine-tuning models, the at least two image fine-tuning models are called into the image generation model, and the target image satisfying the preset style is generated according to the target indication information.
3. The method according to claim 2, characterized in that Before acquiring the target indication information for generating the target image, the preset weights respectively configured for the at least two image fine-tuning models are determined according to the following steps: Obtaining multiple weight combinations corresponding to the at least two image fine-tuning models; Calling the at least two image fine-tuning models configured with the weight combination into the image generation model, and obtaining a first image according to the test indication information; respectively determining a degree of match between the first image obtained based on the weight combination and the preset style; Based on the matching degree between the first image and the preset style obtained by the weight combination, the preset weights respectively configured for the at least two image fine-tuning models are determined.
4. The method according to claim 1, characterized in that: The at least two image fine-tuning models include at least a background LoRA model, and also include an avatar frame LoRA model or a prop icon LoRA model.
5. The method according to claim 4, characterized in that The first fine-tuning model includes the background LoRA model, and the background LoRA model is obtained by training according to the following steps: Acquire a first sample image corresponding to the preset style and first annotation information corresponding to the first sample image; Based on the first sample image, the first annotation information corresponding to the first sample image, and the image generation model that calls the first initial LoRA model, the first initial LoRA model is iteratively trained, and when the first initial LoRA model reaches an overfitting condition, the updating of the network parameters in the first initial LoRA model is stopped to generate the background LoRA model in an overfitting state.
6. The method according to claim 5, characterized in that The first annotation information includes one or more of the following: image style information, main object information, and image texture information of the first sample image.
7. The method according to claim 5, characterized in that Determine whether the first initial LoRA model meets the overfitting condition according to the following steps: Inputting the first sample image into the image generation model that calls the first initial LoRA model to obtain a first output image; determining a similarity between the first output image and the corresponding first sample image; Based on the similarity between the first output image and the plurality of first sample images in a preset ratio, it is determined whether the first initial LoRA model meets the overfitting condition.
8. The method according to claim 5, characterized in that Determine whether the first initial LoRA model meets the overfitting condition according to the following steps: calling the first initial LoRA model in the image generation model, generating a second output image according to the first sample indication information, and generating a third output image according to the second sample indication information; the image visual elements of the first sample indication information and the second sample indication information are different; Based on the difference between the second output image and the third output image, it is determined whether the first initial LoRA model meets the overfitting condition.
9. The method according to claim 5, characterized in that Before training the first initial LoRA model, the method further includes: presetting a target value of a training parameter for training the first initial LoRA model; The iterative training of the first initial LoRA model based on each first sample image and the first annotation information corresponding to each first sample image, and calling the image generation model having the first initial LoRA model, includes: Iteratively training the first initial LoRA model according to the first sample image, the first annotation information corresponding to the first sample image, the target value of the training parameter, and the image generation model calling the first initial LoRA model; The target value of the training parameter is a value that makes the overfitting degree of the model meet a preset degree threshold.
10. The method according to claim 9, characterized in that The training parameters include one or more of the following: the number of training learning steps, the total number of the first sample images, and the total number of learning times for the first sample images.
11. The method according to claim 5, characterized in that The second fine-tuning model is trained according to the following steps: Acquire a second sample image containing the subject and second annotation information corresponding to the second sample image; the second sample image is an image obtained by preprocessing the image background; Based on the second sample image, the second annotation information corresponding to the second sample image, and the image generation model calling the second initial LoRA model, the second initial LoRA model is iteratively trained, and when the second initial LoRA model reaches the training cutoff condition, the updating of the network parameters in the second initial LoRA model is stopped to obtain the second fine-tuning model.
12. The method according to claim 11, characterized in that The training cutoff condition includes an overfitting condition.
13. The method according to claim 11, characterized in that The second annotation information includes one or more of the following: the name of the second sample image, background color information, and subject object information.
14. An image generating device, characterized in that: The device comprises: An acquisition module, used for acquiring target indication information for generating a target image; A generating module, used for calling at least two image fine-tuning models to generate the target image satisfying a preset style according to the target indication information; Among the at least two image fine-tuning models, there is at least one first fine-tuning model in an overfitting state, and the first fine-tuning model is trained based on a first sample image of the preset style.
15. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor to execute the steps of the image generation method as described in any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image generation method according to any one of claims 1 to 13 are executed.
Citation Information
Cited By
Motion video generation method and device, electronic equipment and storage medium
CN120264038A