Task-universal lightweight visual basis model construction method
By using the latent space diffusion generation model and LoRA module in the visual basic model, combined with task-specific decoder training, the high cost and low transferability problems of the visual basic model are solved, and low-cost, low-cost, and low-cost visual perception and generation tasks are achieved. Universal support.
Patent Information
- Application Number
- CN202410491184.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-23
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-04-23
AI Technical Summary
Existing visual basic models have high training costs and storage costs, lack good portability, cannot meet the needs of users for personalized functions, and are not suitable for actual deployment and applications.
By training the latent space diffusion generation model based on a large-scale visual language data set, an initial lightweight visual basic model is constructed, and the LoRA module is inserted into the U-Net structure, combined with task-specific decoders for training, to obtain the final lightweight visual basic model. Model.
It achieves universal support for various visual perception and generation tasks, reduces training and storage costs, improves model transferability, and is suitable for actual deployment and application.
Smart Images

Figure CN118586445A
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of universal visual models in computer image processing, and in particular to a method for constructing a lightweight basic visual model that is universal for various tasks. Background Art
[0002] The general model has performed well in the field of natural language processing and has been widely used, which has promoted the development of general visual models. In the field of image and video generation, the diffusion generation model based on large-scale visual language pre-training has shown outstanding results and has been widely used in tasks such as text image generation, image denoising, and image restoration.
[0003] In related technologies, Transformer architecture and a large number of multimodal visual or visual-language datasets can be used for large-scale pre-training to obtain a large-scale visual basic model; sequences or images can also be used to uniformly represent the input or output space of visual tasks, and joint training can be performed on multiple datasets, so that multiple visual tasks can be solved through a unified model. In addition, the latent space diffusion model can be used to reduce the model calculation space from the image space to the latent space, thereby expanding the scale of visual language pre-training.
[0004] However, related technologies have high training and storage costs, lack good portability, cannot meet users' needs for personalized functions, are not suitable for actual deployment and application, and are in urgent need of improvement. Summary of the invention
[0005] The present application provides a method for constructing a lightweight visual basic model that is universal for various tasks, in order to solve the problems in the related technologies, such as high training and storage costs, lack of good portability, inability to meet the needs of user personalized functions, and unsuitability for actual deployment and application.
[0006] The first aspect of the present application provides a method for constructing a lightweight visual foundation model that is universal for all tasks, comprising the following steps: training a latent space diffusion generation model based on a target large-scale visual language dataset, and using the latent space diffusion generation model to construct an initial lightweight visual foundation model; selecting a dataset corresponding to at least one task and a lightweight task-specific decoder; based on the dataset and the decoder, training the initial lightweight visual foundation model to obtain a final lightweight visual foundation model.
[0007] Optionally, in one embodiment of the present application, the initial lightweight visual base model is constructed using the latent space diffusion generation model, including: extracting the U-Net structure of the latent space diffusion generation model; inserting a LoRA (Low-Rank Adaptation) module into the linear layer and convolutional layer in the U-Net structure to obtain the initial lightweight visual base model.
[0008] Optionally, in one embodiment of the present application, the initial lightweight visual base model is trained to obtain the final lightweight visual base model, including: when the task is a visual generation task, sampling noise from a standard Gaussian distribution, passing the true result with the noise added as a conditional input into the U-Net structure, generating a prediction result of the noise, so that during training, the loss function is obtained by using the mean square error loss between the sampled noise and the prediction result.
[0009] Optionally, in one embodiment of the present application, the initial lightweight visual base model is trained to obtain the final lightweight visual base model, including: when the task is a visual perception task, comparing the predicted results and the actual results generated by the model, and using a task-specific loss function for training.
[0010] A second aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a lightweight visual basic model construction method that is universal for the above tasks.
[0011] The third aspect of the present application provides a computer program product, including a computer program, which, when executed, implements a lightweight visual basic model construction method that is applicable to the above tasks.
[0012] The embodiment of the present application can use the trained latent space diffusion generation model to construct an initial lightweight visual basic model, and complete the construction of the final lightweight visual basic model by inserting a lightweight trainable decoder, which can achieve universal support for various visual perception and generation tasks at low training and storage costs. Thus, the problems in the related technology such as high training and storage costs, lack of good portability, inability to meet the needs of user personalized functions, and unsuitability for actual deployment and application are solved.
[0013] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0015] Figure 1 A flowchart of a method for constructing a lightweight visual basic model that is universal for various tasks provided in accordance with an embodiment of the present application;
[0016] Figure 2 A visual schematic diagram of a prediction generation result provided according to an embodiment of the present application;
[0017] Figure 3 A flowchart of lightweight visual basic model training and application provided according to an embodiment of the present application;
[0018] Figure 4 The present invention is a flowchart of the working principle of a method for constructing a lightweight visual basic model that is universal for various tasks provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0019] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0020] The following describes a method for constructing a lightweight visual basic model that is universal for tasks in an embodiment of the present application with reference to the accompanying drawings. In view of the problems mentioned in the above background technology, such as high training and storage costs, lack of good portability, inability to meet the needs of user personalized functions, and unsuitability for actual deployment and application, the present application provides a method for constructing a lightweight visual basic model that is universal for tasks. In this method, the trained latent space diffusion generation model can be used to construct an initial lightweight visual basic model, and the construction of the final lightweight visual basic model is completed by inserting a lightweight trainable decoder, which can achieve universal support for various visual perception and generation tasks at low training and storage costs. Thus, the problems in the related technology, such as high training and storage costs, lack of good portability, inability to meet the needs of user personalized functions, and unsuitability for actual deployment and application, are solved.
[0021] Specifically, Figure 1 The present invention is a flowchart of a method for constructing a lightweight visual basic model that is universal for various tasks according to an embodiment of the present application.
[0022] like Figure 1 As shown in the figure, the method for constructing a lightweight visual basic model that can be used for this task includes the following steps:
[0023] In step S101, a latent space diffusion generation model is trained based on a target large-scale visual language dataset, and an initial lightweight visual basic model is constructed using the latent space diffusion generation model.
[0024] It can be understood that the target large-scale visual language dataset of the embodiment of the present application can be but not limited to LAION-5B (Large-scale Artificial Intelligence Open Network 5 Billion, Large-scale Artificial Intelligence Open Network 5 Billion dataset), etc., and the present application does not impose any specific restrictions.
[0025] As a possible implementation method, the embodiment of the present application can train a latent space diffusion generation model on a target large-scale visual language dataset to enable it to have good text-generated graph capabilities, and then construct an initial lightweight visual basic model.
[0026] Optionally, in one embodiment of the present application, an initial lightweight visual base model is constructed using a latent space diffusion generation model, including: extracting a U-Net structure of the latent space diffusion generation model; inserting a LoRA module into the linear layer and convolutional layer in the U-Net structure to obtain an initial lightweight visual base model.
[0027] In the actual implementation process, the embodiment of the present application uses the latent space diffusion generation model to construct a lightweight visual basic model, which can be:
[0028] First, the embodiment of the present application can extract the U-Net structure in the trained latent space diffusion generation model as the backbone network of the initial lightweight visual basic model, and then perform feature extraction.
[0029] Then, the embodiment of the present application inserts the LoRA module into the linear layer and the convolutional layer in the U-Net structure, thereby constructing the initial lightweight visual basic model.
[0030] Furthermore, the embodiment of the present application can fix the U-Net structure and insert LoRA modules and decoders corresponding to different tasks into the linear layer and convolution layer in the U-Net structure, so that the initial lightweight visual basic model can handle multiple tasks and thus have the ability to solve different tasks.
[0031] In step S102, a data set corresponding to at least one task and a lightweight task-specific decoder are selected.
[0032] It is understandable that the tasks may be, but are not limited to, visual perception tasks, visual generation tasks, etc., and this application does not impose specific restrictions. For example, the visual perception tasks of the embodiments of this application may include, but are not limited to, image generation, depth estimation, object detection, image classification, semantic segmentation, image segmentation, human posture estimation, and 3D human mesh reconstruction, etc., and this application does not impose specific restrictions; the visual generation tasks may include, but are not limited to, denoising, rain removal, blur removal, low-light enhancement, and image super-resolution, etc., and this application does not impose specific restrictions.
[0033] As a possible implementation method, the embodiments of the present application can select different data sets and lightweight task-specific decoders according to different tasks.
[0034] For example, the data set corresponding to the visual perception task may be, but is not limited to, the ADE20k data set, the NYUv2 data set, the RefCOCO data set, the COCO-Pose data set, the 3DPW data set, etc. This application does not impose any specific restrictions.
[0035] In step S103, the initial lightweight visual base model is trained based on the data set and the decoder to obtain a final lightweight visual base model.
[0036] As a possible implementation method, the embodiment of the present application can train the initial lightweight visual basic model according to the data set and the decoder, and then obtain the final lightweight visual basic model to solve different tasks. Among them, when the embodiment of the present application is trained on the corresponding data set, the parameters of the U-Net structure can be fixed during the training process, and only the LoRA module and the decoder can be learned.
[0037] Specifically, the embodiment of the present application can use the U-Net structure to realize feature extraction, that is, the embodiment of the present application first compresses the input data set through the image encoder, reduces the dimension to generate the latent space description of the image, and then uses the image description model to extract the text description corresponding to the input data set, and generates the corresponding vector description through the conditional encoder. Under the prompt of the vector description, the U-Net structure calculates and processes the input latent space description. Among them, the image description model can be set by a person skilled in the art according to the actual situation, and this application does not make specific restrictions.
[0038] Furthermore, the present embodiment of the application fixes the parameters of the U-Net structure, and the learning of the LoRA module and decoder can be understood as follows: In order to avoid the huge storage cost caused by the change of the U-Net structure parameters, the present embodiment of the application chooses to completely fix the training parameters of the U-Net structure, and inserts a trainable lightweight LoRA module into the linear layer and convolution layer of the U-Net structure. Specifically, the LoRA module of the present embodiment of the application takes into account the training parameter matrix The change ΔW when migrating to the downstream task is decomposed into the product of two low-rank matrices, namely ΔW = AB, where And r<<min(d,k). Therefore, when the embodiment of the present application performs migration training, it is only necessary to learn these two low-rank matrices, thereby significantly reducing the amount of trainable parameters of the model. In addition, in the embodiment of the present application, each downstream task is trained to obtain a specific LoRA module, and the parameters of the fixed U-Net structure are implemented by inserting the LoRA module specified by the task, so that it calculates the output result corresponding to the task. At the same time, the decoder of each task in the embodiment of the present application is also lightweight. In order to increase support for new tasks each time, the embodiment of the present application only needs to additionally store the LoRA module and decoder parameters trained on the corresponding task. As a result, the embodiment of the present application greatly reduces the storage space overhead while also reducing the difficulty of migration training.
[0039] For example, the specific visualization effect of the embodiment of the present application can be as follows: Figure 2 The embodiment of the present application is applicable to many real application scenarios and can handle a variety of tasks. For example, the embodiment of the present application can support first repairing or enhancing an image, and then predicting a depth estimation result or predicting a human body posture in the image.
[0040] Optionally, in one embodiment of the present application, the initial lightweight visual base model is trained to obtain the final lightweight visual base model, including: when the lightweight task is a visual generation task, sampling noise from a standard Gaussian distribution, passing the true result with noise as a conditional input into the U-Net structure, generating a noise prediction result, and obtaining a loss function by using the mean square error loss between the sampled noise and the prediction result during training.
[0041] In the actual implementation process, the initial lightweight visual basic model of the embodiment of the present application can be trained to obtain the final lightweight visual basic model capable of solving the corresponding task.
[0042] In some embodiments, in the case of visual generation tasks, the embodiments of the present application can follow the conventional method of the latent space diffusion generation model, and finally obtain the generation result through multiple iterations of the U-Net structure. In other words, the embodiments of the present application can directly use the output result of the U-Net structure, and then use the decoder to convert the output result of the U-Net structure into the corresponding prediction result or generation result.
[0043] For example, Figure 3As shown, in the visual generation task of the embodiment of the present application, during the training process, noise can be sampled from a standard Gaussian distribution, where ∈~N(0,1), ∈ is the sampled noise, and the real result with the noise is passed into the U-Net structure as a conditional input, and then the prediction result of the noise is generated. During training, the loss function adopts the mean square error loss between the sampled noise and the prediction result, where the expression of the mean square error can be: in, is the prediction result of the noise, t is the sampling time, c is the conditional input, and then the trained plug-in B and U-Net structure are obtained, where plug-in B can include the LoRA module and decoder corresponding to the visual generation task.
[0044] Furthermore, in the application process of the visual generation task, the embodiment of the present application can use different plug-ins according to different tasks, that is, the embodiment of the present application can directly apply the final lightweight visual basic model obtained.
[0045] Optionally, in one embodiment of the present application, the initial lightweight visual base model is trained to obtain the final lightweight visual base model, including: when the lightweight task is a visual perception task, comparing the predicted results and the actual results generated by the model, and using a task-specific loss function for training.
[0046] In some other embodiments, in the case of visual perception tasks, the embodiment of the present application can integrate the feature maps of multiple resolutions and the cross-attention maps in the U-Net structure to form image features as output results. In other words, the embodiment of the present application can obtain the prediction result through the decoder after passing through the U-Net structure once.
[0047] For example, Figure 3 As shown, the visual perception task of the embodiment of the present application can directly compare the predicted results and the actual results generated by the model during the training process, and use the task-specific loss function for training, thereby obtaining the trained plug-in A and U-Net structure, wherein plug-in A can include the LoRA module and decoder corresponding to the visual perception task. Among them, the task-specific loss function can be set by a person skilled in the art according to the actual situation, and this application does not make specific restrictions.
[0048] Furthermore, in the application process of visual perception tasks, the embodiments of the present application can use different plug-ins according to different tasks, that is, the embodiments of the present application can directly apply the final lightweight visual basic model obtained.
[0049] Combine the following Figure 4 As shown, the working principle of the method for constructing a lightweight visual basic model that is applicable to the tasks proposed in the embodiment of the present application is introduced in detail using a specific embodiment.
[0050] in, Figure 4 The present invention is a flowchart of the working principle of a method for constructing a lightweight visual basic model that is universal for various tasks provided according to an embodiment of the present application.
[0051] Step S401: Input. That is, the embodiment of the present application can input different images into the final lightweight visual basic model according to different tasks. For example, the embodiment of the present application can select an image with a task prompt of "restaurant with tables and chairs".
[0052] Step S402: Encoding. That is, the embodiment of the present application can first compress the input image through an image encoder, reduce the dimension to generate a latent space description of the image, extract the text description corresponding to the input image, and use the conditional encoder to generate a corresponding vector description.
[0053] Step S403: U-Net structure. That is, the U-Net structure of the embodiment of the present application can perform computational processing on the generated latent space description. Specifically, for visual perception tasks, the embodiment of the present application can use the image features formed by integrating the feature maps of multiple resolutions and the cross-attention maps in the U-Net structure as the output result; for visual generation tasks, the embodiment of the present application can directly use the output result of the U-Net structure.
[0054] Step S404: Output. That is, the embodiment of the present application can use the corresponding LoRA module and decoder according to different tasks to convert the output result of the U-Net structure into a prediction result or a generation result corresponding to the task.
[0055] According to the method for constructing a lightweight visual basic model that is universal for all tasks proposed in the embodiment of the present application, the trained latent space diffusion generation model can be used to construct the initial lightweight visual basic model, and by inserting a lightweight trainable decoder, the construction of the final lightweight visual basic model is completed to achieve the processing and resolution of different tasks, and to achieve universal support for various visual perception and generation tasks at low training and storage costs. This solves the problems in the related technology, such as high training and storage costs, lack of good portability, inability to meet the needs of user personalized functions, and unsuitability for actual deployment and application.
[0056] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a lightweight visual basic model construction method that is applicable to the above tasks.
[0057] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed, implements a lightweight visual basic model construction method that is universal for the above tasks.
[0058] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0059] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0060] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0061] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or N wirings (electronic devices), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways as necessary and then storing it in a computer memory.
[0062] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented by hardware, as in another embodiment, it can be implemented by any one or a combination of multiple of the following technologies known in the art: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0063] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0064] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0065] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for constructing a lightweight visual basic model that can be used for various tasks, characterized in that: The following steps are involved: Based on a target large-scale visual language dataset, a latent space diffusion generation model is trained, and an initial lightweight visual basic model is constructed using the latent space diffusion generation model; Select at least one task-specific dataset and a lightweight task-specific decoder; Based on the data set and the decoder, the initial lightweight visual base model is trained to obtain a final lightweight visual base model.
2. The method according to claim 1, characterized in that The method of using the latent space diffusion generation model to construct an initial lightweight visual basic model includes: Extracting the U-Net structure of the latent space diffusion generation model; The low-rank adaptation LoRA module is inserted into the linear layer and the convolutional layer in the U-Net structure to obtain the initial lightweight visual base model.
3. The method according to claim 2, characterized in that The training of the initial lightweight visual basic model to obtain a final lightweight visual basic model includes: When the task is a visual generation task, noise is sampled from a standard Gaussian distribution, and the true result with the noise added is passed into the U-Net structure as a conditional input to generate a prediction result of the noise, so that during training, the loss function is obtained by using the mean square error loss between the sampled noise and the prediction result.
4. The method according to claim 1, characterized in that: The training of the initial lightweight visual basic model to obtain a final lightweight visual basic model includes: In the case where the task is a visual perception task, the predictions generated by the model are compared with the true results and trained using a task-specific loss function.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement a lightweight visual basic model construction method that is universal for tasks as described in any one of claims 1 to 4.
6. A computer program product, characterized in that It comprises a computer program, which, when executed, is used to implement a lightweight visual basic model construction method applicable to any task as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Training visual language grounding models using separation loss
US20230061647A1
Vehicle and Control Method Thereof
US20230256939A1
Cited By
Multitask visual basic model image generation method based on diffusion model
CN119919523A
Task universal visual model construction method based on self-supervised representation
CN121365691A
