Model generation method and image generation method

By pruning the feature extraction unit and distilling the denoising unit of the generative AI model, the target task model is generated, which solves the problem of high computing resource consumption of existing AI technology and improves the reasoning speed and efficiency.

CN118379219BActive Publication Date: 2024-09-13ALIBABA DAMO (HANGZHOU) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410802151.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-09-13
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

Existing generative AI technology, especially the diffusion model, has high reasoning complexity when generating images, resulting in excessive consumption of computing resources, slow reasoning speed, and high time cost.

Method used

By pruning the initial feature extraction unit of the task model to be processed, redundant sub-units are reduced, and combined with distillation of the initial denoising unit, the target task model is generated. The computing resource parameters of the target task model are less than or equal to the preset resource threshold, reducing the Compute resource consumption.

Benefits of technology

It improves the inference speed of the generated model, shortens the processing time, reduces the consumption of computing resources, and avoids the problem of insufficient computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118379219B
    Figure CN118379219B
Patent Text Reader

Abstract

The embodiments of the present specification provide a model generation method and an image generation method, wherein the model generation method includes: obtaining a task model to be processed, wherein a resource parameter to be processed of the task model to be processed is greater than a preset resource threshold, and the resource parameter to be processed is used to characterize the amount of computing resources used to run the task model to be processed; in an initial feature extraction unit of the task model to be processed, determining a sub-unit to be pruned, and deleting the sub-unit to be pruned from the initial feature extraction unit to obtain a target feature extraction unit; distilling an initial denoising unit in the task model to be processed to obtain a target denoising unit; generating a target task model based on the target feature extraction unit and the target denoising unit, wherein a target resource parameter of the target task model is less than or equal to the preset resource threshold, and the target resource parameter is used to characterize the amount of computing resources used to run the target task model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of artificial intelligence technology, and in particular to a model generation method and an image generation method. Background Art

[0002] In recent years, artificial intelligence (AI) technology has made great progress, especially the development of generative AI technology, which has also achieved a qualitative improvement in the quality of image generation. However, generative AI technology represented by diffusion models has extremely high reasoning complexity when applied. Generating an image often requires multiple loop iterations, slow reasoning speed, and high time cost, which results in the use of a large amount of computing resources in the process of running the model, resulting in a large consumption of computing resources. Therefore, there is an urgent need for a method to solve the technical problem of high computing resource consumption caused by slow model reasoning speed and high time cost. Summary of the invention

[0003] In view of this, the embodiments of this specification provide a model generation method and an image generation method. One or more embodiments of this specification also relate to a model generation device and an image generation device, a computing device, a computer-readable storage medium and a computer program product to solve the technical defects existing in the prior art.

[0004] According to a first aspect of an embodiment of this specification, a model generation method is provided, including:

[0005] Acquire a task model to be processed, wherein a resource parameter to be processed of the task model to be processed is greater than a preset resource threshold, and the resource parameter to be processed is used to characterize the amount of computing resources used to run the task model to be processed;

[0006] In the initial feature extraction unit of the task model to be processed, a sub-unit to be pruned is determined, and the sub-unit to be pruned is deleted from the initial feature extraction unit to obtain a target feature extraction unit;

[0007] Distilling the initial denoising unit in the task model to be processed to obtain a target denoising unit;

[0008] A target task model is generated according to the target feature extraction unit and the target denoising unit, wherein a target resource parameter of the target task model is less than or equal to the preset resource threshold, and the target resource parameter is used to characterize the amount of computing resources used to run the target task model.

[0009] According to a second aspect of an embodiment of this specification, there is provided a model generation device, including:

[0010] An acquisition module is configured to acquire a task model to be processed, wherein a resource parameter to be processed of the task model to be processed is greater than a preset resource threshold, and the resource parameter to be processed is used to characterize the amount of computing resources used to run the task model to be processed;

[0011] A deletion module is configured to determine a sub-unit to be pruned in an initial feature extraction unit of the task model to be processed, and delete the sub-unit to be pruned from the initial feature extraction unit to obtain a target feature extraction unit;

[0012] A distillation module is configured to distill the initial denoising unit in the task model to be processed to obtain a target denoising unit;

[0013] A generation module is configured to generate a target task model based on the target feature extraction unit and the target denoising unit, wherein a target resource parameter of the target task model is less than or equal to the preset resource threshold, and the target resource parameter is used to characterize the amount of computing resources used to run the target task model.

[0014] According to a third aspect of an embodiment of this specification, there is provided an image generation method, which is applied to a cloud-side device, and includes:

[0015] In response to an image generation instruction sent by a target terminal, sending at least one preset model posture image to the target terminal;

[0016] Acquire a reference model posture image and a model image to be processed returned by the target terminal based on the at least one preset model posture image;

[0017] Inputting the model image to be processed and the reference model posture image into an image processing model to obtain a target model image corresponding to the model image to be processed, wherein the target model image is obtained by denoising the reference model posture image according to the model image to be processed, and the image processing model includes a target denoising unit and a target feature extraction unit;

[0018] The target model image is sent to the target terminal.

[0019] According to a fourth aspect of the embodiments of this specification, there is provided an image generation device, which is applied to a cloud-side device, including:

[0020] A first sending module is configured to send at least one preset model posture image to the target terminal in response to an image generation instruction sent by the target terminal;

[0021] An image acquisition module, configured to acquire a reference model posture image and a model image to be processed returned by the target terminal based on the at least one preset model posture image;

[0022] An input module is configured to input the model image to be processed and the reference model posture image into an image processing model to obtain a target model image corresponding to the model image to be processed, wherein the target model image is obtained by denoising the reference model posture image according to the model image to be processed, and the image processing model includes a target denoising unit and a target feature extraction unit;

[0023] The second sending module is configured to send the target model image to the target terminal.

[0024] According to a fifth aspect of an embodiment of this specification, a computing device is provided, including:

[0025] Memory and processor;

[0026] The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the above-mentioned model generation method or image generation method are implemented.

[0027] According to a sixth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the above-mentioned model generation method or image generation method are implemented.

[0028] According to a seventh aspect of the embodiments of this specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the above-mentioned model generation method or image generation method when executed by a processor.

[0029] An embodiment of the present specification realizes that after obtaining the task model to be processed, the redundant sub-units in the initial feature extraction unit in the task model to be processed are pruned to achieve lightweight of the task model to be processed, and the amount of computing resources used is reduced when running the pruned task model to be processed; the initial denoising unit in the task model to be processed is distilled to reduce the number of time steps for iterative denoising of the initial denoising unit, thereby improving the inference speed of the generated target task model, shortening the processing time of the target task model, and further reducing the amount of computing resources consumed when running the target task model. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 is a flow chart of a model generation method provided by an embodiment of this specification;

[0031] Figure 2 It is a schematic diagram of the architecture of a task model to be processed provided by an embodiment of this specification;

[0032] Figure 3 It is a schematic diagram of the architecture of a target task model provided by an embodiment of this specification;

[0033] Figure 4 It is a schematic diagram of an application flow of a target task model provided by an embodiment of this specification;

[0034] Figure 5 is a processing flow chart of a model generation method provided by an embodiment of this specification;

[0035] Figure 6 It is a structural schematic diagram of a model generation device provided by an embodiment of this specification;

[0036] Figure 7 This is a schematic diagram of an application scenario of an image generation method provided by an embodiment of this specification;

[0037] Figure 8 is a flow chart of an image generation method provided by an embodiment of this specification;

[0038] Fig. 9 is a structural schematic diagram of an image generating device provided by an embodiment of this specification;

[0039] Fig.10 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0040] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0041] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0042] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0043] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0044] First, the terms involved in one or more embodiments of this specification are explained.

[0045] Stable Diffusion: A network structure for generation tasks, mainly composed of a variational autoencoder (VAE) and an image information creator (Unet) structure.

[0046] LCM (Latent Consistency Models): Latent consistency model.

[0047] Knowledge Distillation: is a machine learning model compression method that is used to transfer the knowledge of a large model (teacher model) to a smaller model (student model).

[0048] In recent years, AI technology has made great progress, especially the development of generative AI technology, which has also achieved a qualitative improvement in the quality of image generation. However, generative AI technology represented by diffusion model has extremely high reasoning complexity when applied. Generating an image often requires multiple loop iterations, slow reasoning speed, and high time cost, which requires a large amount of computing resources to be used in the process of running the model, resulting in a large consumption of computing resources.

[0049] In this specification, a model generation method and an image generation method are provided. This specification also involves a model generation device and an image generation device, a computing device, a computer-readable storage medium and a computer program product, which are described in detail one by one in the following embodiments.

[0050] See also Figure 1 , Figure 1 A flow chart of a model generation method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0051] Step 102: Acquire a task model to be processed, wherein a resource parameter to be processed of the task model to be processed is greater than a preset resource threshold, and the resource parameter to be processed is used to characterize the amount of computing resources used to run the task model to be processed.

[0052] In current practical applications, various models are gradually being applied to various fields. With the continuous iteration of the model, although the model performance and capabilities are constantly improving, the iterated model also has large-scale model parameters and the model structure is becoming more and more complex. As a result, a large amount of computing resources will be used when running the model, resulting in the consumption of computing resources. In this way, if the model needs to be deployed on a device with limited computing resources, it may cause users to be unable to use the model normally, such as smart mobile devices, which often have limited storage space and limited computing resources. For another example, if the device that deploys the model runs multiple processing tasks in parallel, a large amount of computing resources are required. At this time, there may be a situation of insufficient computing resources. Based on this, when running the model, it is particularly important to reduce the computing resources consumed by the model operation.

[0053] Among them, the pending task model refers to the model used to perform the data conversion task. The pending task model is a trained model that can be directly used to perform the data conversion task. The data conversion task can specifically be a character posture conversion task, a writing style conversion task, an audio type conversion task, etc. Taking the character posture conversion task as an example, the pending task model can identify the character a in image 1 and convert the posture of character a to generate image 2 of character a containing the new posture; taking the writing style conversion task as an example, the pending task model can determine that the writing style of text 1 is style A, and after processing text 1, convert the writing style of text 1 from style A to style B, etc.

[0054] See also Figure 2 , Figure 2 FIG. 1 shows a schematic diagram of the architecture of a task model to be processed according to an embodiment of the present specification. Figure 2As shown, the task model to be processed includes a first encoder, a second encoder, a reference encoder, a decoder, an initial feature extraction unit and an initial denoising unit, and the initial feature extraction unit and the initial denoising unit include a self-attention subunit and a cross-attention subunit respectively. In practical applications, after obtaining the task data to be processed, that is, the task data to be processed by the data conversion task performed by the task model to be processed, the task data to be processed can specifically be image, text, audio and other data, and the specific form of the task data to be processed can be determined according to the actual application situation.

[0055] Since the pending task model is used to perform data conversion tasks, before the pending task model performs data conversion on the pending task data, it is necessary to provide the pending task model with a basis for data conversion, namely, reference task data. The reference task data corresponds to the pending task data, and can also be data such as images, texts, and audios. For example, if the pending task data is a person image, and the data conversion task is to convert the person posture in the person image, then the reference task data can be a reference posture image, that is, an image containing a person posture, and the person posture in the reference posture image is different from the person posture in the pending task data. For another example, if the pending task data is a text paragraph, and the data conversion task is to convert the writing style of the text paragraph, then the reference task data can be a text prompt word used to prompt the pending task model to convert the writing style, such as "Please convert the writing style of this text paragraph to XX style."

[0056] After obtaining the task data to be processed and the reference task data corresponding to the task data to be processed, the task data to be processed is input into the first encoder of the task model to be processed, the task data to be processed is encoded, the features encoded by the first encoder are input into the initial feature extraction unit (specifically the input self-attention subunit) for feature extraction, and the data after feature extraction are input into the initial denoising unit (specifically the input self-attention subunit); the task data to be processed is input into the second encoder, the task data to be processed is encoded, the features encoded by the second encoder are input into the initial denoising unit (specifically the input cross-attention subunit); the reference task data is input into the reference encoder of the task model to be processed, the reference task data is encoded, the features encoded by the reference task data are input into the initial denoising unit, the input feature extracted data and the features encoded by the second encoder are used as denoising conditions, the encoded features of the reference task data are iteratively denoised, and after the denoising is completed, it is decoded by the decoder and output to obtain the task data after data conversion.

[0057] Furthermore, the training process of the task model to be processed is explained.

[0058] In a specific implementation manner provided in this specification, the task model to be processed is obtained by training according to the following method:

[0059] Acquire sample training data, wherein the sample training data includes sample task data, sample reference data corresponding to the sample task data, and sample label data corresponding to the sample task data;

[0060] Inputting the sample task data and the sample reference data into the task model to be processed to obtain predicted task data;

[0061] Calculating a model loss value of the task model to be processed according to the prediction task data and the sample label data;

[0062] The model parameters of the task model to be processed are adjusted according to the model loss value, and the task model to be processed is continued to be trained until a training stop condition is reached.

[0063] The sample training data refers to the sample data used to train the task model to be processed, and the sample training data includes the sample task data, the sample reference data corresponding to the sample task data, and the sample label data corresponding to the sample task data. The sample task data refers to the task data to be processed that needs to be converted by the task model to be processed during the training of the task model to be processed; the sample reference data refers to the reference task data that needs to be converted by the task model to be processed during the training of the task model to be processed, that is, the reference task data corresponding to the sample task data; the sample label data refers to the actual task data after the sample task data is converted.

[0064] The sample training data can be the sample data (including sample task data, sample reference data and sample label data) obtained in the sample training data set, or it can be the data pair (including sample task data, sample reference data and sample label data) created in a customized manner before training the task model to be processed; the sample training data set refers to the set consisting of sample task data, sample reference data and sample label data; the prediction task data refers to the task data after data conversion output by inputting the sample task data and sample reference data into the task model to be processed; the model loss value refers to the difference between the sample label data and the prediction task data, which is used to measure the difference between the sample label data and the prediction task data.

[0065] Specifically, the sample task data, sample reference data and sample label data are obtained through the above-mentioned method of obtaining sample task data, sample reference data and sample label data, and the sample task data and sample reference data are input into the task model to be processed to obtain the predicted task data.

[0066] The task model to be processed is used to generate task data after data conversion of sample task data. At this time, the task model to be processed is a model that has not been trained yet. There will be a deviation between the determined prediction task data and the actual sample label data. The model parameters of the task model to be processed need to be adjusted accordingly. Specifically, the model loss value of the task model to be processed is calculated according to the output prediction task data and sample label data. The loss function for calculating the model loss value can be a 0-1 loss function, a square loss function, a cross entropy loss function, etc. in actual applications. In this specification, preferably, a cross entropy loss function or a square loss function is selected as the loss function for calculating the model loss value, and the model parameters of the task model to be processed are adjusted according to the model loss value. The adjusted model parameters are used for the next batch of sample training data to continue training the task model to be processed until the stop condition of the model training is reached.

[0067] Specifically, the model training stopping conditions include that the model loss value is less than a preset threshold and / or the training rounds reach a preset round.

[0068] In a specific implementation provided in this specification, taking the model loss value being less than a preset threshold as the training stop condition as an example, the preset threshold is 0.2. When the loss value is less than 0.2, it is considered that the training of the task model to be processed is completed.

[0069] In another specific implementation provided in the present specification, taking the preset number of training rounds as the training stop condition as an example, the preset number of training rounds is 30 rounds. When the number of training rounds of the training sample training data reaches 30 rounds, it is considered that the training of the task model to be processed is completed.

[0070] In another specific implementation provided in the present specification, two training stop conditions, namely a preset threshold and a preset training round, are set, and the model loss value and the training round are determined at the same time. When either the model loss value or the training round meets the training stop condition, the training of the task model to be processed is considered to be completed.

[0071] It should be noted that in one or more embodiments provided in this specification, the training of the task model to be processed is based on the pre-trained task model to be processed. During the training of the task model to be processed, the model parameters of the first encoder and the second encoder can be frozen, that is, the first encoder and the second encoder do not participate in the model training, and the initial feature extraction unit, the initial denoising unit and the reference encoder are trained.

[0072] The pending resource parameter is used to characterize the amount of computing resources used to run the pending task model. The preset resource threshold refers to the upper limit of the amount of computing resources available to the pending task model when running the pending task model. Computing resources can specifically include CPU (Central Processing Unit) resources, memory resources, etc.

[0073] In actual applications, after obtaining the model of the task to be processed, it is determined whether the amount of computing resources used to run the model of the task to be processed has reached the preset resource threshold according to the resource parameters to be processed. If it has reached it, it means that the amount of computing resources of the device where the data of the task to be processed is about to be insufficient. In view of this situation of insufficient computing resources, the model of the task to be processed can be lightweight processed so that the processed model can consume less computing resources, and the processed model can be run to perform the data conversion task. In this way, it is possible to reduce the consumption of computing resources without affecting the data conversion task.

[0074] Step 104: in the initial feature extraction unit of the task model to be processed, determine the sub-unit to be pruned, and delete the sub-unit to be pruned from the initial feature extraction unit to obtain a target feature extraction unit.

[0075] In one or more embodiments provided in the present specification, the initial feature extraction unit of the task model to be processed is obtained by copying the initial denoising unit. Since the function implemented by the initial feature extraction unit is different from that of the initial denoising unit, the initial feature extraction unit is specifically used for feature extraction. Therefore, relative to the initial denoising unit, there will be redundant sub-units in the initial feature extraction unit. In order to achieve lightweight processing of the task model to be processed, the redundant sub-units in the initial feature extraction unit can be pruned.

[0076] The sub-unit to be pruned refers to a redundant sub-unit in the initial feature extraction unit, and the target feature extraction unit refers to a feature extraction unit after the sub-unit to be pruned in the initial feature extraction unit is removed.

[0077] Based on this, in a specific implementation manner provided in this specification, in the initial feature extraction unit of the task model to be processed, determining the sub-unit to be pruned includes:

[0078] In the initial feature extraction unit of the task model to be processed, determining a cross-attention subunit;

[0079] The cross-attention sub-unit is determined as a sub-unit to be pruned.

[0080] As described above, in one or more embodiments provided in this specification, the initial feature extraction unit is used to perform feature extraction. Since the data features extracted from the task data to be processed are the same at any time step, there is no need to perform iterative denoising when performing feature extraction on the task data to be processed based on the initial feature extraction unit. In practical applications, iterative denoising is often performed through cross-attention sub-units. Based on this, after obtaining and copying the initial denoising unit, the cross-attention sub-units existing in the copied initial feature extraction unit can be identified, and the identified cross-attention sub-units are determined as sub-units to be pruned, and the identified cross-attention sub-units (i.e., sub-units to be pruned) are deleted from the copied initial feature extraction unit to obtain the target feature extraction unit.

[0081] By identifying and deleting redundant sub-units in the initial feature extraction unit, lightweight processing of the task model to be processed can be achieved. Since the redundant sub-units in the initial feature extraction unit are removed, the extraction result will not be affected when feature extraction is performed based on the target feature extraction unit (i.e., the feature extraction unit after removing the redundant sub-units).

[0082] Step 106: distill the initial denoising unit in the task model to be processed to obtain a target denoising unit.

[0083] In practical applications, the iterative denoising process through the initial denoising unit requires multiple loop iterations to complete the denoising. In the process of loop iteration, a large amount of computing resources will also be consumed. In order to further reduce the consumption of computing resources by the task model to be processed, the loop iteration process of the initial denoising unit can also be distilled to reduce the time step of the initial denoising unit training iteration.

[0084] The target denoising unit refers to a denoising unit obtained by distilling the initial denoising unit.

[0085] In a specific implementation provided in this specification, the initial denoising unit in the task model to be processed is distilled to obtain a target denoising unit, including:

[0086] Acquire sample distillation training data, wherein the sample distillation training data includes sample reference data, sample extraction features, sample encoding features and sample noise data;

[0087] Inputting the sample reference data, the sample extraction feature, the sample encoding feature and the sample noise data into the initial denoising unit to obtain first sample denoised data corresponding to the sample reference data at a first time step and second sample denoised data corresponding to the sample reference data at a second time step;

[0088] Calculating a distillation loss value of the initial denoising unit according to the first sample denoising data and the second sample denoising data;

[0089] The parameters of the initial denoising unit are adjusted according to the distillation loss value, and the initial denoising unit is continued to be distilled until a distillation stop condition is reached to obtain a target denoising unit.

[0090] Among them, the sample distillation training data refers to the sample data used for distillation training of the initial denoising unit, and the sample distillation training data includes sample reference data, sample extraction features, sample encoding features and sample noise data. The sample reference data is the reference task data that needs to be denoised by the initial denoising unit during the distillation training of the initial denoising unit; the sample extraction features refer to the data features of the sample task data extracted by the initial feature extraction unit; the sample encoding features refer to the encoding features obtained by encoding the sample task data by the second encoder; the sample noise data is the noise data added to the sample task data during the distillation training of the initial denoising unit. The sample distillation training data can be the sample data obtained in the sample distillation training data set; the sample distillation training data set refers to the set consisting of the sample reference data, the sample extraction features, the sample encoding features and the sample noise data.

[0091] The first time step refers to any time step or any time step interval in the initial denoising unit loop iteration process, and the first time step is not the last time step or the last time step interval in the initial denoising unit loop iteration process. The time step interval refers to an interval consisting of at least two consecutive time steps. The first sample denoised data refers to the denoised data generated after the sample reference data is denoised at the first time step. The second time step refers to the next time step of the first time step in the initial denoising unit loop iteration process. If the first time step is specifically a time step, the second time step is the next time step of the first time step; if the first time step is specifically a time step interval, the second time step is the next time step interval of the first time step. The second sample denoised data refers to the denoised data generated after the sample reference data is denoised at the second time step. The distillation loss value refers to the difference between the first sample denoised data and the second sample denoised data, and is used to measure the difference between the first sample denoised data and the second sample denoised data.

[0092] Specifically, sample reference data, sample extraction features, sample coding features and sample noise data are obtained, and the sample reference data, sample extraction features, sample coding features and sample noise data are input into an initial denoising unit to obtain first sample denoised data corresponding to the sample reference data at a first time step and second sample denoised data corresponding to the sample reference data at a second time step.

[0093] In order to reduce the number of iterations of the initial denoising unit, the denoised data of the sample reference data at different time steps or different time step intervals can be made consistent, that is, the first sample denoised data is made consistent with the second sample denoised data. Since there is a deviation between the determined first sample denoised data and the second sample denoised data, the parameters of the initial denoising unit need to be adjusted accordingly.

[0094] Specifically, the distillation loss value of the initial denoising unit is calculated based on the determined first sample denoising data and the second sample denoising data. The loss function for calculating the distillation loss value can be a 0-1 loss function, a square loss function, a cross entropy loss function, etc. in actual applications. In this specification, preferably, the cross entropy loss function is selected as the loss function for calculating the distillation loss value, and the parameters of the initial denoising unit are adjusted according to the distillation loss value. The sample distillation training data for the next time step is used based on the adjusted parameters, and the distillation training of the initial denoising unit is continued until the stop condition of the distillation training is reached to obtain the target denoising unit.

[0095] Specifically, the distillation training stop condition includes that the distillation loss value is less than a preset distillation threshold and / or the distillation training rounds reach a preset round.

[0096] In a specific implementation provided in the present specification, taking the distillation loss value being less than a preset distillation threshold as the stopping condition for distillation training as an example, the preset distillation threshold is 0.1. When the distillation loss value is less than 0.1, it is considered that the initial denoising unit distillation training is completed.

[0097] In another specific implementation provided in the present specification, taking the preset distillation training rounds as the distillation training stop condition as an example, the preset distillation training rounds are 50 rounds. When the distillation training rounds of the training sample distillation training data reach 50 rounds, the initial denoising unit distillation training is considered to be completed.

[0098] In another specific implementation manner provided in the present specification, two distillation training stop conditions, namely a preset distillation threshold and a preset distillation training round, are set, and the distillation loss value and the distillation training round are determined at the same time. When either the distillation loss value or the distillation training round meets the distillation training stop condition, the distillation training of the initial denoising unit is considered to be completed.

[0099] Furthermore, the initial denoising unit is trained by distillation in order to perform lightweight processing on the task model to be processed, so that the amount of computing resources consumed by the model can be less than or equal to the preset resource threshold, thereby solving the problem of insufficient computing resources. Therefore, in order to accurately grasp the amount of computing resources consumed by the lightweight task model, which can be less than or equal to the preset resource threshold, the number of loop iterations to which the initial denoising unit needs to be reduced can also be determined based on the preset resource threshold.

[0100] Based on this, in a specific implementation provided in this specification, the initial denoising unit in the task model to be processed is distilled to obtain a target denoising unit, including:

[0101] Determining a target number of iteration steps corresponding to the initial denoising unit according to the preset resource threshold;

[0102] According to the target number of iterations, the initial denoising unit is distilled to obtain a target denoising unit.

[0103] The target number of iteration steps refers to the upper limit of the number of iteration steps corresponding to the initial denoising unit when the amount of computing resources used to run the task model to be processed is less than or equal to the preset resource threshold.

[0104] Specifically, a preset resource threshold is determined, and an upper limit of the number of iteration steps required for iterative denoising of the initial denoising unit is determined according to the preset resource threshold. The initial denoising unit is distilled and trained according to the upper limit of the number of iteration steps, i.e., the target number of iteration steps, to obtain a distilled target denoising unit, and the number of iteration steps required for the target denoising unit during the iterative denoising process is the target number of iteration steps.

[0105] It should be noted that the target number of iteration steps is determined according to the preset resource threshold, that is, the upper limit of the number of time steps required for iterative denoising of the target denoising unit generated after distillation. In practical applications, the target denoising unit can also be distilled into a denoising unit with a number less than the target number of iteration steps, which can be determined based on the actual application situation.

[0106] Further, in a specific implementation provided in this specification, the initial denoising unit is distilled according to the target iteration step to obtain a target denoising unit, including:

[0107] Acquire sample distillation training data, wherein the sample distillation training data includes sample reference data, sample extraction features, sample encoding features and sample noise data;

[0108] Inputting the sample reference data, the sample extraction feature, the sample encoding feature and the sample noise data into the initial denoising unit to obtain first sample denoised data corresponding to the sample reference data at a first time step and second sample denoised data corresponding to the sample reference data at a second time step;

[0109] Calculating a distillation loss value of the initial denoising unit according to the first sample denoising data and the second sample denoising data;

[0110] The parameters of the initial denoising unit are adjusted according to the distillation loss value, and the initial denoising unit is continued to be distilled until the number of iteration steps of the initial denoising unit reaches the target number of iteration steps, thereby obtaining a target denoising unit.

[0111] Similar to the above-mentioned method of performing distillation training on the initial denoising unit, the initial denoising model is distilled and trained until the iteration number of the initial denoising unit reaches the target iteration number, or is less than the target iteration number. Then, the distillation training of the initial denoising unit is stopped, and the denoising unit obtained by the last distillation is determined as the target denoising unit.

[0112] The model generation method provided in this specification obtains the target denoising unit by distilling the initial denoising unit in the initial task model, so as to reduce the number of time steps required for iterative denoising of the initial denoising unit in iterative denoising, thereby shortening the time for iterative denoising based on the target denoising unit and further reducing the consumption of computing resources by the target denoising unit.

[0113] Step 108: Generate a target task model based on the target feature extraction unit and the target denoising unit, wherein a target resource parameter of the target task model is less than or equal to the preset resource threshold, and the target resource parameter is used to characterize the amount of computing resources used to run the target task model.

[0114] After obtaining the target feature extraction unit and the target denoising unit, the target task model can be generated based on the target feature extraction unit and the target denoising unit. Figure 3 , Figure 3 FIG. 1 shows a schematic diagram of the architecture of a target task model provided according to an embodiment of this specification. Figure 3 As shown, the generated target task model also includes a first encoder, a second encoder, a reference encoder and a decoder. Unlike the task model to be processed, the feature extraction unit in the target task model is a target feature extraction unit after pruning the initial feature extraction unit, that is, the target feature extraction unit does not include a cross-attention sub-unit; and the denoising unit in the target task model is a target denoising unit after distilling the initial denoising unit, that is, the number of time steps required for iterative denoising in the target denoising unit is less than the number of time steps required for iterative denoising in the initial denoising unit.

[0115] To avoid the situation where the task model consumes a large amount of computing resources or the computing resources of the device are insufficient to support the running of the task model, the lightweight target task model can be deployed in the application device, and data conversion tasks can be performed based on the target task model.

[0116] In a specific implementation provided in this specification, after generating the target task model, the method further includes:

[0117] Acquire task data to be processed and reference task data corresponding to the task data to be processed;

[0118] The task data to be processed and the reference task data are input into the target task model to obtain target task data corresponding to the task data to be processed, wherein the target task data is obtained by denoising the reference task data according to the task data to be processed.

[0119] Among them, the task data to be processed refers to the task data that needs to be processed for the data conversion task executed by the target task model; the reference task data refers to the basis for the target task model to perform data conversion on the task data to be processed; the target task data refers to the task data after data conversion of the task data to be processed generated by the target task model based on the reference task data.

[0120] Specifically, after obtaining the task data to be processed and the reference task data corresponding to the task data to be processed, the task data to be processed and the reference task data are input into the target task model, and the target task data after data conversion of the task data to be processed can be obtained. For example, the task data to be processed is an image containing a person a, and the reference task data is an image of a person's skeleton posture. By inputting the task data to be processed and the reference task data into the target task model, an image containing a person a in the same posture as the person's skeleton posture in the reference task data can be obtained, that is, the target task data.

[0121] The following explains the specific processing process of the target task model.

[0122] In a specific implementation provided in this specification, the target task model includes an encoder and a decoder;

[0123] Inputting the task data to be processed and the reference task data into the target task model to obtain the target task data corresponding to the task data to be processed includes:

[0124] Inputting the task data to be processed into the encoder to obtain the coding features to be processed corresponding to the task data to be processed, and inputting the reference task data into the encoder to obtain the reference coding features corresponding to the reference task data;

[0125] Inputting the to-be-processed coding feature into the target feature extraction unit to obtain the to-be-processed extracted feature;

[0126] Inputting the to-be-processed extracted features, the to-be-processed coded features and the reference coded features into the target denoising unit to obtain target data features;

[0127] The target data features are input into the decoder to obtain target task data.

[0128] Among them, the coding feature to be processed refers to the coding feature obtained after encoding the task data to be processed; the reference coding feature refers to the coding feature obtained after encoding the reference task data; the extracted feature to be processed refers to the data feature obtained after feature extraction of the task data to be processed based on the target feature extraction unit, specifically the extracted feature obtained after feature extraction of the coding feature to be processed; the target data feature refers to the data feature generated after denoising the reference coding feature based on the coding feature to be processed and the extracted feature to be processed. The target feature extraction unit is used to extract the data features of the task data to be processed. The target denoising unit is used to perform cyclic denoising on the reference task data. The target feature extraction unit and the target denoising unit can specifically be Unet structures.

[0129] Specifically, after obtaining the task data to be processed and the reference task data, the task data to be processed and the reference task data are respectively input into the encoder of the target task model, and the coding features to be processed corresponding to the task data to be processed and the reference coding features corresponding to the reference task data can be obtained. The coding features to be processed obtained by encoding are input into the target feature extraction unit of the target task model, and the extracted features to be processed of the task data to be processed can be obtained. Furthermore, the extracted features to be processed, the coding features to be processed and the reference coding features are input into the target denoising unit of the target task model, and the extracted features to be processed and the coding features to be processed are used as denoising conditions to denoise the reference coding features to obtain the target data features, and then the target data features are input into the decoder of the target task model, and the decoder decodes the obtained target data features to obtain the target task data.

[0130] Furthermore, when the task data to be processed is an image containing an object to be processed, and the object to be processed is a person or animal with various body parts such as face, hands, and feet, in order to improve the image quality of the generated target image (i.e., the target task data), the important parts of the object to be processed can be cropped to focus on processing the cropped parts. In practical applications, the parts that need to be focused on in the subsequent processing can be customized by the user, such as face, feet, etc. At this time, a local encoder can be added to the target task model to encode the cropped part image, and the encoded features are input into the target denoising unit for subsequent processing.

[0131] Furthermore, the implementation process of inputting the task data to be processed into the encoder to obtain the coding features to be processed corresponding to the task data to be processed is specifically as follows:

[0132] In a specific implementation provided in this specification, the encoder includes a first encoder and a second encoder;

[0133] Inputting the task data to be processed into the encoder to obtain the coding features to be processed corresponding to the task data to be processed, including:

[0134] Inputting the task data to be processed into the first encoder to obtain a first coding feature to be processed corresponding to the task data to be processed;

[0135] The task data to be processed is input into the second encoder to obtain a second coding feature to be processed corresponding to the task data to be processed.

[0136] The first encoder and decoder may specifically be the encoder and decoder constituting a VAE (Variational Autoencoder), and the second encoder may specifically be an image encoder or text encoder in a CLIP (Contrastive Language-Image Pre-training) model or other models, and both the first encoder and the second encoder are used to encode the task data to be processed. The first encoding feature to be processed refers to the encoding feature obtained after the first encoder encodes the task data to be processed; the second encoding feature to be processed refers to the encoding feature obtained after the second encoder encodes the task data to be processed.

[0137] Specifically, the task data to be processed is input into the encoder of the target task model, that is, the task data to be processed is input into the first encoder of the target task model to obtain the first coding feature to be processed corresponding to the task data to be processed, and the task data to be processed is input into the second encoder of the target task model to obtain the second coding feature to be processed corresponding to the task data to be processed. As described above, if the task data to be processed is an image containing an object to be processed, and when the object to be processed is a person or an animal, the target part of the object to be processed can be cropped to obtain the target part image, therefore, a local encoder can be added to the target task model, the cropped part image is input into the local encoder, and the target part coding feature corresponding to the cropped part image is obtained.

[0138] Accordingly, inputting the reference task data into the encoder of the target task model is inputting the reference task data into the reference encoder of the target task model, and obtaining the reference encoding features corresponding to the reference task data. The reference encoder is used to encode the reference task data.

[0139] Furthermore, after obtaining the first coding feature to be processed, the first coding feature to be processed can be calculated by a target feature extraction unit of the target task model to extract data features of the task data to be processed.

[0140] In a specific implementation manner provided in this specification, the coding feature to be processed is input into the target feature extraction unit to obtain the extracted feature to be processed, including:

[0141] Inputting the first to-be-processed coding feature into the target feature extraction unit to obtain a to-be-processed key feature and a to-be-processed value feature;

[0142] The key feature to be processed and the value feature to be processed are determined as the extracted features to be processed.

[0143] Among them, the key feature to be processed refers to the key feature of the task data to be processed obtained based on the self-attention calculation, and is specifically expressed in the form of a key feature vector, i.e., a key feature vector. The value feature to be processed refers to the value feature of the task data to be processed obtained based on the self-attention calculation, and is specifically expressed in the form of a value feature vector, i.e., a value feature vector.

[0144] Specifically, after obtaining the first coding feature to be processed, the first coding feature to be processed is input into the feature extraction unit of the target task model, so as to extract the data feature of the task data to be processed by calculating the first coding feature to be processed. In practical applications, the target feature extraction unit includes a self-attention subunit, and the first coding feature to be processed is input into the target feature extraction unit, specifically, the first coding feature to be processed is input into the self-attention subunit of the target feature extraction unit, and the key feature to be processed and the value feature to be processed of the first coding feature to be processed are obtained by performing self-attention calculation on the first coding feature to be processed, and the key feature to be processed and the value feature to be processed are determined as the extracted features to be processed of the task data to be processed.

[0145] The target denoising unit includes a self-attention subunit and a cross-attention subunit. The target denoising unit is used to denoise the reference task data, so the noise data also needs to be input into the target denoising unit.

[0146] In a specific implementation provided in this specification, the target denoising unit includes a self-attention subunit and a cross-attention subunit;

[0147] Inputting the to-be-processed extracted features, the to-be-processed coded features, and the reference coded features into the target denoising unit to obtain target data features, including:

[0148] Inputting the reference coding feature and preset noise data into the target denoising unit, inputting the to-be-processed extracted feature into the self-attention subunit, and inputting the second to-be-processed coding feature into the cross-attention subunit;

[0149] The reference coding feature is denoised according to the extracted feature to be processed and the second coding feature to be processed to obtain a denoised reference feature, the denoised reference feature is determined as a new reference coding feature, and the step of denoising the reference coding feature according to the extracted feature to be processed and the second coding feature to be processed is continued until the iteration stop condition is reached to obtain the target data feature.

[0150] Specifically, the reference coding feature and the preset noise data are input into the target denoising unit, the extracted features to be processed, i.e., the key features to be processed and the value features to be processed, are input into the self-attention subunit of the target denoising unit, and the second coding feature to be processed is input into the cross-attention subunit of the target denoising unit. The reference coding feature is guided to be denoised by the second coding feature to be processed, the key features to be processed and the value features to be processed to obtain the denoised reference feature. At this point, the first iterative denoising of the reference coding feature is completed. The denoised reference feature is used as a new reference coding feature, and the new reference coding feature (i.e., the denoised reference feature) is continued to be denoised until the iteration is completed to obtain the target data feature. Furthermore, after the iterative denoising is completed, the obtained target data feature is input into the decoder, and the target data feature is decoded to obtain the target task data.

[0151] Executing data conversion tasks based on the lightweight target task model can improve the processing efficiency of the target task model and reduce the consumption of computing resources by the target task model on the basis of ensuring the accuracy of the output target task data.

[0152] See also Figure 4 , Figure 4 FIG. 1 shows a schematic diagram of an application process of a target task model provided according to an embodiment of this specification. Figure 4 As shown, the target task model includes a VAE encoder, a VAE decoder, a reference encoder, a second encoder, a target feature extraction unit, and a target denoising unit. Figure 4The dotted box part indicates that the cross-attention subunit has been deleted from the target feature extraction unit. Obtain the task data to be processed and the reference task data corresponding to the task data to be processed, input the task data to be processed into the VAE encoder of the target task model, and obtain the first coding feature to be processed. Input the obtained first coding feature to be processed into the target feature extraction unit of the target task model, specifically input the first coding feature to be processed into the self-attention subunit of the target feature extraction unit, obtain the key feature to be processed and the value feature to be processed by performing self-attention calculation on the first coding feature to be processed, and input the key feature to be processed and the value feature to be processed into the target denoising unit of the target task model, specifically input the key feature to be processed and the value feature to be processed into the self-attention subunit of the target denoising unit. Input the task data to be processed into the second encoder of the target task model to obtain the second coding feature to be processed. Input the second coding feature to be processed into the target denoising unit of the target task model, specifically input the second coding feature to be processed into the cross-attention subunit of the target denoising unit.

[0153] Input the reference task data into the reference encoder of the target task model, encode the reference task data, and obtain the reference coding features. Input the noise data and the reference coding features into the target denoising unit of the target task model, that is, after adding noise to the reference coding features, input them into the target denoising unit. In the target denoising unit, the key features to be processed, the value features to be processed, and the second coding features to be processed are used as guiding conditions for denoising the reference coding features after adding noise, and denoising reference features are obtained. The obtained denoised reference features are used as new reference coding features, and iterative denoising is continued until the iterative denoising is completed to obtain the target data features. The denoised target data features are input into the VAE decoder of the target task model, and the target data features are decoded to obtain the target task data.

[0154] The model generation method provided in the present specification includes: obtaining a task model to be processed, wherein a resource parameter to be processed of the task model to be processed is greater than a preset resource threshold, and the resource parameter to be processed is used to characterize the amount of computing resources used to run the task model to be processed; in an initial feature extraction unit of the task model to be processed, determining a sub-unit to be pruned, and deleting the sub-unit to be pruned from the initial feature extraction unit to obtain a target feature extraction unit; distilling an initial denoising unit in the task model to be processed to obtain a target denoising unit; generating a target task model according to the target feature extraction unit and the target denoising unit, wherein a target resource parameter of the target task model is less than or equal to the preset resource threshold, and the target resource parameter is used to characterize the amount of computing resources used to run the target task model.

[0155] An embodiment of the present specification realizes that after obtaining the task model to be processed, the redundant sub-units in the initial feature extraction unit in the task model to be processed are pruned to achieve lightweight of the task model to be processed, and the amount of computing resources used is reduced when running the pruned task model to be processed; the initial denoising unit in the task model to be processed is distilled to reduce the number of time steps for iterative denoising of the initial denoising unit, improve the inference speed of the generated target task model, shorten the processing time of the target task model, and further reduce the amount of computing resources consumed when running the target task model. Avoid the situation where the task model consumes a large amount of computing resources, or the computing resources of the device are insufficient to support the running of the task model.

[0156] The following combination Figure 5 , the model generation method is further described. Among them, Figure 5 A process flow chart of a model generation method provided by an embodiment of this specification is shown, such as Figure 5 As shown, after obtaining the task model to be processed, the cross-attention sub-unit in the initial feature extraction unit of the task model to be processed is identified, and the cross-attention sub-unit is determined as the sub-unit to be pruned, so that the sub-unit to be pruned is deleted from the initial feature extraction unit, and the feature extraction unit after deleting the sub-unit to be pruned is determined as the target feature extraction unit.

[0157] According to the LCM distillation technology, the initial denoising unit of the task model to be processed is distilled and trained. By making the denoising data generated by the initial denoising unit at each time step or time step interval consistent, the number of time steps for iterative denoising of the initial denoising unit is reduced, and the iterative denoising time of the initial denoising unit is greatly shortened, thereby generating the target denoising unit. Then, the following can be obtained: Figure 5 The target task model shown consists of a target feature extraction unit with the cross-attention sub-unit removed and a target denoising unit after distillation.

[0158] By pruning the cross-attention sub-units in the initial feature extraction unit in the task model to be processed, the task model to be processed is made lightweight, and the amount of computing resources used is reduced when running the pruned task model to be processed; the initial denoising unit in the task model to be processed is distilled to reduce the number of time steps for iterative denoising of the initial denoising unit, thereby improving the inference speed of the generated target task model and shortening the processing time of the target task model.

[0159] After the target task model is generated, the target task model can be used to perform data conversion tasks to reduce the consumption of computing resources for running the target task model. The specific implementation process of using the target task model to perform data conversion tasks can be found in the above content, and this specification will not be repeated here.

[0160] Corresponding to the above method embodiment, this specification also provides a model generation device embodiment, Figure 6 FIG. 1 shows a schematic diagram of a model generation device provided by an embodiment of the present specification. Figure 6 As shown, the device comprises:

[0161] The acquisition module 602 is configured to acquire a task model to be processed, wherein a resource parameter to be processed of the task model to be processed is greater than a preset resource threshold, and the resource parameter to be processed is used to characterize the amount of computing resources used to run the task model to be processed;

[0162] The deleting module 604 is configured to determine a sub-unit to be pruned in the initial feature extraction unit of the task model to be processed, and delete the sub-unit to be pruned from the initial feature extraction unit to obtain a target feature extraction unit;

[0163] A distillation module 606 is configured to distill the initial denoising unit in the task model to be processed to obtain a target denoising unit;

[0164] The generation module 608 is configured to generate a target task model based on the target feature extraction unit and the target denoising unit, wherein the target resource parameter of the target task model is less than or equal to the preset resource threshold, and the target resource parameter is used to characterize the amount of computing resources used to run the target task model.

[0165] Optionally, the deleting module 604 is further configured to:

[0166] In the initial feature extraction unit of the task model to be processed, determining a cross-attention subunit;

[0167] The cross-attention sub-unit is determined as a sub-unit to be pruned.

[0168] Optionally, the distillation module 606 is further configured to:

[0169] Acquire sample distillation training data, wherein the sample distillation training data includes sample reference data, sample extraction features, sample encoding features and sample noise data;

[0170] Inputting the sample reference data, the sample extraction feature, the sample encoding feature and the sample noise data into the initial denoising unit to obtain first sample denoised data corresponding to the sample reference data at a first time step and second sample denoised data corresponding to the sample reference data at a second time step;

[0171] Calculating a distillation loss value of the initial denoising unit according to the first sample denoising data and the second sample denoising data;

[0172] The parameters of the initial denoising unit are adjusted according to the distillation loss value, and the initial denoising unit is continued to be distilled until a distillation stop condition is reached to obtain a target denoising unit.

[0173] Optionally, the distillation module 606 is further configured to:

[0174] Determining a target number of iteration steps corresponding to the initial denoising unit according to the preset resource threshold;

[0175] According to the target number of iterations, the initial denoising unit is distilled to obtain a target denoising unit.

[0176] Optionally, the distillation module 606 is further configured to:

[0177] Acquire sample distillation training data, wherein the sample distillation training data includes sample reference data, sample extraction features, sample encoding features and sample noise data;

[0178] Inputting the sample reference data, the sample extraction feature, the sample encoding feature and the sample noise data into the initial denoising unit to obtain first sample denoised data corresponding to the sample reference data at a first time step and second sample denoised data corresponding to the sample reference data at a second time step;

[0179] Calculating a distillation loss value of the initial denoising unit according to the first sample denoising data and the second sample denoising data;

[0180] The parameters of the initial denoising unit are adjusted according to the distillation loss value, and the initial denoising unit is continued to be distilled until the number of iteration steps of the initial denoising unit reaches the target number of iteration steps, thereby obtaining a target denoising unit.

[0181] Optionally, the device further comprises:

[0182] A data acquisition module is configured to acquire task data to be processed and reference task data corresponding to the task data to be processed;

[0183] The data input module is configured to input the task data to be processed and the reference task data into the target task model to obtain the target task data corresponding to the task data to be processed, wherein the target task data is obtained by denoising the reference task data based on the task data to be processed.

[0184] Optionally, the target task model includes an encoder and a decoder;

[0185] The data input module is further configured to:

[0186] Inputting the task data to be processed into the encoder to obtain the coding features to be processed corresponding to the task data to be processed, and inputting the reference task data into the encoder to obtain the reference coding features corresponding to the reference task data;

[0187] Inputting the to-be-processed coding feature into the target feature extraction unit to obtain the to-be-processed extracted feature;

[0188] Inputting the to-be-processed extracted features, the to-be-processed coded features and the reference coded features into the target denoising unit to obtain target data features;

[0189] The target data features are input into the decoder to obtain target task data.

[0190] Optionally, the encoder includes a first encoder and a second encoder;

[0191] The data input module is further configured to:

[0192] Inputting the task data to be processed into the first encoder to obtain a first coding feature to be processed corresponding to the task data to be processed;

[0193] The task data to be processed is input into the second encoder to obtain a second coding feature to be processed corresponding to the task data to be processed.

[0194] Optionally, the data input module is further configured to:

[0195] Inputting the first to-be-processed coding feature into the target feature extraction unit to obtain a to-be-processed key feature and a to-be-processed value feature;

[0196] The key feature to be processed and the value feature to be processed are determined as the extracted features to be processed.

[0197] Optionally, the target denoising unit includes a self-attention subunit and a cross-attention subunit;

[0198] The data input module is further configured to:

[0199] Inputting the reference coding feature and preset noise data into the target denoising unit, inputting the to-be-processed extracted feature into the self-attention subunit, and inputting the second to-be-processed coding feature into the cross-attention subunit;

[0200] The reference coding feature is denoised according to the extracted feature to be processed and the second coding feature to be processed to obtain a denoised reference feature, the denoised reference feature is determined as a new reference coding feature, and the step of denoising the reference coding feature according to the extracted feature to be processed and the second coding feature to be processed is continued until the iteration stop condition is reached to obtain the target data feature.

[0201] Optionally, the device further comprises a training module configured to:

[0202] Acquire sample training data, wherein the sample training data includes sample task data, sample reference data corresponding to the sample task data, and sample label data corresponding to the sample task data;

[0203] Inputting the sample task data and the sample reference data into the task model to be processed to obtain predicted task data;

[0204] Calculating a model loss value of the task model to be processed according to the prediction task data and the sample label data;

[0205] The model parameters of the task model to be processed are adjusted according to the model loss value, and the task model to be processed is continued to be trained until a training stop condition is reached.

[0206] The model generation device provided in the present specification includes: an acquisition module, configured to acquire a task model to be processed, wherein a resource parameter to be processed of the task model to be processed is greater than a preset resource threshold, and the resource parameter to be processed is used to characterize the amount of computing resources used to run the task model to be processed; a deletion module, configured to determine a sub-unit to be pruned in an initial feature extraction unit of the task model to be processed, and delete the sub-unit to be pruned from the initial feature extraction unit to obtain a target feature extraction unit; a distillation module, configured to distill an initial denoising unit in the task model to be processed to obtain a target denoising unit; a generation module, configured to generate a target task model based on the target feature extraction unit and the target denoising unit, wherein a target resource parameter of the target task model is less than or equal to the preset resource threshold, and the target resource parameter is used to characterize the amount of computing resources used to run the target task model.

[0207] An embodiment of the present specification realizes that after obtaining the task model to be processed, the redundant sub-units in the initial feature extraction unit in the task model to be processed are pruned to achieve lightweight of the task model to be processed, and the amount of computing resources used is reduced when running the pruned task model to be processed; the initial denoising unit in the task model to be processed is distilled to reduce the number of time steps for iterative denoising of the initial denoising unit, improve the inference speed of the generated target task model, shorten the processing time of the target task model, and further reduce the amount of computing resources consumed when running the target task model. Avoid the situation where the task model consumes a large amount of computing resources, or the computing resources of the device are insufficient to support the running of the task model.

[0208] The above is a schematic scheme of a model generation device of this embodiment. It should be noted that the technical scheme of the model generation device and the technical scheme of the above model generation method belong to the same concept, and the details not described in detail in the technical scheme of the model generation device can be referred to the description of the technical scheme of the above model generation method.

[0209] In actual e-commerce application scenarios, before selling goods, merchants often take different model photos for the same product in order to achieve better sales results. These model photos include model photos in different poses, so that purchasing users can understand the products in more detail and decide whether to buy the corresponding products. However, these product model photos are usually taken by merchants themselves or obtained using photo editing software, which will consume a lot of time and energy of merchants, and cost labor costs, which is a heavy burden for merchants.

[0210] See also Figure 7 , Figure 7 FIG. 1 is a schematic diagram showing an application scenario of an image generation method provided according to an embodiment of the present specification. Figure 7 The sales interface corresponding to any product is shown, and the products displayed on the sales interface include five different model display pictures. In one or more embodiments provided in this specification, an image generation method is provided, which can obtain a model image to be processed and a reference model posture image provided by a user (merchant), and process the model image to be processed and the reference model posture image based on an image processing model to generate a target model image corresponding to the model image to be processed, and the model in the target model image has the same posture as that in the reference model posture image. Figure 7For example, based on the image generation method provided in this specification, the merchant only needs to provide any one of the five model display pictures provided by the merchant, and provide the reference model posture images corresponding to the other four model display pictures. The image processing model extracts features from the model display pictures provided by the merchant through the target feature extraction unit, and inputs the extracted image features into the target denoising unit. The target denoising unit denoises the reference model posture image with the image features as the denoising condition, and generates a target model image corresponding to the reference model posture image. The image processing model provided in this specification is specifically the specific application of the target task model in the above-mentioned model generation method in the e-commerce scenario, which can realize the lightweight of the image processing model, reduce the reasoning complexity of the image processing model, shorten the image processing time, improve the efficiency of image processing, and reduce the image processing model's consumption of computing resources.

[0211] See also Figure 8 , Figure 8 A flowchart of an image generation method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0212] Step 802: In response to an image generation instruction sent by a target terminal, at least one preset model posture image is sent to the target terminal.

[0213] The image generation method is applied to a cloud-side device. The image generation instruction refers to an instruction generated by a target terminal for obtaining a target model image corresponding to a model image to be processed. The target model image refers to an image obtained by transforming the pose of a model in the model image to be processed based on a reference model pose image. The preset model pose image refers to a pre-constructed reference model pose image.

[0214] Specifically, the target terminal generates an image generation instruction and sends the image generation instruction to the cloud side device. After receiving the image generation instruction sent by the target terminal, the cloud side device obtains at least one preset model pose image and sends the obtained at least one preset model pose image to the target terminal.

[0215] Step 804: Acquire a reference model pose image and a model image to be processed returned by the target terminal based on the at least one preset model pose image.

[0216] Specifically, the target terminal may determine one of at least one preset model pose image as a reference model pose image for subsequent image processing of the model image to be processed, and the cloud-side device may obtain the reference model pose image selected by the target terminal.

[0217] Step 806: input the model image to be processed and the reference model posture image into an image processing model to obtain a target model image corresponding to the model image to be processed.

[0218] The target model image is obtained by denoising the reference model posture image according to the model image to be processed, and the image processing model includes a target denoising unit and a target feature extraction unit.

[0219] Step 808: Send the target model image to the target terminal.

[0220] In the image generation method, after obtaining the model image to be processed and the reference model posture image, the model image to be processed and the reference model posture image are input into the image processing model for image processing, and the specific implementation process is the same as the implementation process of performing the data conversion task based on the target task model in the above-mentioned model generation method. The specific implementation process of the image generation method can refer to the implementation process of performing the data conversion task based on the target task model in the above-mentioned model generation method, and this specification will not repeat it here. After generating the target model image corresponding to the model image to be processed, the target model image can be sent to the target terminal.

[0221] An embodiment of the present specification realizes that the image processing is performed on the model image to be processed and the reference model posture image through the image processing model, specifically, the target feature extraction unit and the target denoising unit based on the image processing model are used to denoise the reference model posture image according to the model image to be processed to generate the target model image, so that the target model image has the posture corresponding to the reference model posture image, thereby realizing the generation of images of different postures for the model image to be processed, without the need for the user to obtain images of different postures through manual methods, which greatly reduces the workload and burden of the user. In addition, due to the image processing model, specifically the specific application of the target task model in the above-mentioned model generation method in the e-commerce scenario, the image processing model can be lightweight, the reasoning complexity of the image processing model can be reduced, and the image processing model's consumption of computing resources can be reduced.

[0222] Corresponding to the above method embodiment, this specification also provides an image generating device embodiment, Fig. 9 FIG. 1 shows a schematic diagram of the structure of an image generating device provided by an embodiment of the present specification. Fig. 9 As shown, the device is applied to a cloud-side device, including:

[0223] A first sending module 902 is configured to send at least one preset model posture image to the target terminal in response to an image generation instruction sent by the target terminal;

[0224] An image acquisition module 904 is configured to acquire a reference model posture image and a model image to be processed returned by the target terminal based on the at least one preset model posture image;

[0225] An input module 906 is configured to input the model image to be processed and the reference model posture image into an image processing model to obtain a target model image corresponding to the model image to be processed, wherein the target model image is obtained by denoising the reference model posture image according to the model image to be processed, and the image processing model includes a target denoising unit and a target feature extraction unit;

[0226] The second sending module 908 is configured to send the target model image to the target terminal.

[0227] The image generation device provided in this specification performs image processing on the model image to be processed and the reference model posture image through the image processing model, specifically, a target feature extraction unit and a target denoising unit based on the image processing model, denoises the reference model posture image according to the model image to be processed to generate a target model image, so that the target model image has the posture corresponding to the reference model posture image, thereby realizing the generation of images of different postures for the model image to be processed, without the need for the user to obtain images of different postures through manual methods, greatly reducing the workload and burden of the user. In addition, due to the image processing model, specifically the specific application of the target task model in the above-mentioned model generation method in the e-commerce scenario, the image processing model can be lightweight, the reasoning complexity of the image processing model can be reduced, and the image processing model's consumption of computing resources can be reduced.

[0228] The above is a schematic scheme of an image generating device of this embodiment. It should be noted that the technical scheme of the image generating device and the technical scheme of the above image generating method belong to the same concept, and the details not described in detail in the technical scheme of the image generating device can be referred to the description of the technical scheme of the above image generating method.

[0229] Fig.10 The block diagram of a computing device 1000 according to an embodiment of the present specification is shown. The components of the computing device 1000 include but are not limited to a memory 1010 and a processor 1020. The processor 1020 is connected to the memory 1010 via a bus 1030, and the database 1050 is used to store data.

[0230] The computing device 1000 also includes an access device 1040 that enables the computing device 1000 to communicate via one or more networks 1060. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1040 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).

[0231] In one embodiment of the present specification, the above components of the computing device 1000 and Fig.10 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.10 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0232] The computing device 1000 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 1000 may also be a mobile or stationary server.

[0233] The processor 1020 is used to execute the following computer program / instructions, which, when executed by the processor, implement the steps of the above-mentioned model generation method or image generation method.

[0234] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computing device embodiment, since it is basically similar to the model generation method or image generation method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the model generation method or image generation method embodiment.

[0235] An embodiment of the present specification also provides a computer-readable storage medium storing a computer program / instruction, which implements the steps of the above-mentioned model generation method or image generation method when executed by a processor.

[0236] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computer-readable storage medium embodiment, since it is basically similar to the model generation method or image generation method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the model generation method or image generation method embodiment.

[0237] An embodiment of the present specification also provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned model generation method or image generation method when executed by a processor.

[0238] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the above-mentioned model generation method or image generation method belong to the same concept, and the details not described in detail in the technical scheme of the computer program product can be referred to the description of the technical scheme of the above-mentioned model generation method or image generation method.

[0239] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0240] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0241] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0242] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0243] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.

Claims

1. A model generation method, comprising: Acquire a task model to be processed, wherein a resource parameter to be processed of the task model to be processed is greater than a preset resource threshold, and the resource parameter to be processed is used to characterize the amount of computing resources used to run the task model to be processed; In the initial feature extraction unit of the task model to be processed, a sub-unit to be pruned is determined, and the sub-unit to be pruned is deleted from the initial feature extraction unit to obtain a target feature extraction unit; Distilling the initial denoising unit in the task model to be processed to obtain a target denoising unit; Generate a target task model according to the target feature extraction unit and the target denoising unit, wherein a target resource parameter of the target task model is less than or equal to the preset resource threshold, and the target resource parameter is used to characterize the amount of computing resources used to run the target task model; Acquire task data to be processed and reference task data corresponding to the task data to be processed, wherein the task data to be processed includes a task image to be processed; Input the task data to be processed into the first encoder of the target task model to obtain the first coding feature to be processed corresponding to the task data to be processed, input the task data to be processed into the second encoder of the target task model to obtain the second coding feature to be processed corresponding to the task data to be processed, input the reference task data into the reference encoder of the target task model to obtain the reference coding feature corresponding to the reference task data, wherein the first coding feature to be processed is used to be input into the target feature extraction unit for feature extraction, and the second coding feature to be processed is used to be input into the target denoising unit as a denoising condition to denoise the reference coding feature; Inputting the first to-be-processed coding feature into the target feature extraction unit to obtain an to-be-processed extracted feature; Inputting the to-be-processed extracted feature, the second to-be-processed coded feature, and the reference coded feature into the target denoising unit to obtain a target data feature; The target data features are input into the decoder of the target task model to obtain target task data.

2. The method according to claim 1, wherein determining the subunit to be pruned in the initial feature extraction unit of the task model to be processed comprises: In the initial feature extraction unit of the task model to be processed, determining a cross-attention subunit; The cross-attention sub-unit is determined as a sub-unit to be pruned.

3. The method according to claim 1, wherein the initial denoising unit in the task model to be processed is distilled to obtain a target denoising unit, comprising: Acquire sample distillation training data, wherein the sample distillation training data includes sample reference data, sample extraction features, sample encoding features and sample noise data; Inputting the sample reference data, the sample extraction feature, the sample encoding feature and the sample noise data into the initial denoising unit to obtain first sample denoised data corresponding to the sample reference data at a first time step and second sample denoised data corresponding to the sample reference data at a second time step; Calculating a distillation loss value of the initial denoising unit according to the first sample denoising data and the second sample denoising data; The parameters of the initial denoising unit are adjusted according to the distillation loss value, and the initial denoising unit is continued to be distilled until a distillation stop condition is reached to obtain a target denoising unit.

4. The method according to claim 1, wherein the initial denoising unit in the task model to be processed is distilled to obtain a target denoising unit, comprising: Determining a target number of iteration steps corresponding to the initial denoising unit according to the preset resource threshold; According to the target number of iterations, the initial denoising unit is distilled to obtain a target denoising unit.

5. The method according to claim 4, wherein the initial denoising unit is distilled according to the target iteration step to obtain a target denoising unit, comprising: Acquire sample distillation training data, wherein the sample distillation training data includes sample reference data, sample extraction features, sample encoding features and sample noise data; Inputting the sample reference data, the sample extraction feature, the sample encoding feature and the sample noise data into the initial denoising unit to obtain first sample denoised data corresponding to the sample reference data at a first time step and second sample denoised data corresponding to the sample reference data at a second time step; Calculating a distillation loss value of the initial denoising unit according to the first sample denoising data and the second sample denoising data; The parameters of the initial denoising unit are adjusted according to the distillation loss value, and the initial denoising unit is continued to be distilled until the number of iteration steps of the initial denoising unit reaches the target number of iteration steps, thereby obtaining a target denoising unit.

6. The method according to claim 1, inputting the first to-be-processed coding feature into the target feature extraction unit to obtain the to-be-processed extracted feature, comprising: Inputting the first to-be-processed coding feature into the target feature extraction unit to obtain a to-be-processed key feature and a to-be-processed value feature; The key feature to be processed and the value feature to be processed are determined as the extracted features to be processed.

7. The method of claim 1, wherein the target denoising unit comprises a self-attention subunit and a cross-attention subunit; Inputting the to-be-processed extracted feature, the second to-be-processed coded feature, and the reference coded feature into the target denoising unit to obtain a target data feature, comprising: Inputting the reference coding feature and preset noise data into the target denoising unit, inputting the to-be-processed extracted feature into the self-attention subunit, and inputting the second to-be-processed coding feature into the cross-attention subunit; The reference coding feature is denoised according to the extracted feature to be processed and the second coding feature to be processed to obtain a denoised reference feature, the denoised reference feature is determined as a new reference coding feature, and the step of denoising the reference coding feature according to the extracted feature to be processed and the second coding feature to be processed is continued until the iteration stop condition is reached to obtain the target data feature.

8. The method according to claim 1, wherein the task model to be processed is obtained by training according to the following method: Get sample training data, where The sample training data includes sample task data, sample reference data corresponding to the sample task data, and sample label data corresponding to the sample task data; Inputting the sample task data and the sample reference data into the task model to be processed to obtain predicted task data; Calculating a model loss value of the task model to be processed according to the prediction task data and the sample label data; The model parameters of the task model to be processed are adjusted according to the model loss value, and the task model to be processed is continued to be trained until a training stop condition is reached.

9. An image generation method, applied to a cloud-side device, comprising: In response to an image generation instruction sent by a target terminal, sending at least one preset model posture image to the target terminal; Acquire a reference model posture image and a model image to be processed returned by the target terminal based on the at least one preset model posture image; Inputting the model image to be processed and the reference model posture image into an image processing model to obtain a target model image corresponding to the model image to be processed, wherein the target model image is obtained by denoising the reference model posture image according to the model image to be processed, the image processing model comprises a target denoising unit and a target feature extraction unit, and the image processing model is obtained according to the method described in any one of claims 1 to 5 above; The target model image is sent to the target terminal.

10. A computing device comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer program / instructions are executed by the processor, the steps of the method according to any one of claims 1 to 9 are implemented.

11. A computer-readable storage medium storing a computer program / instruction, wherein the computer program / instruction, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.

12. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.