Data processing method and apparatus

By fusing the denoised image and random noise predicted by multiple historical step sizes in the diffusion model, the problem of time-consuming sampling of the diffusion model is solved, and a more efficient sampling process is achieved.

WO2025026210A1PCT designated stage expired Publication Date: 2025-02-06HUAWEI TECH CO LTD

Patent Information

Application Number
PCT/CN2024/107782
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-07-28
Filing Date
2024-07-26
Publication Date
2025-02-06

AI Technical Summary

Technical Problem

When generating high-fidelity images, the original sampling method takes a long time, resulting in limited application in downstream tasks.

Method used

By acquiring multiple historical step predictions to fuse the denoised image and random noise, the sampling error is reduced, thereby reducing the number of samples.

Benefits of technology

In the same calculation consumption, the sampling error is reduced, the number of sampling times is reduced, and the efficiency of the generation process is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024107782_06022025_PF_FP_ABST
    Figure CN2024107782_06022025_PF_FP_ABST
Patent Text Reader

Abstract

A data processing method, applied to the field of artificial intelligence, and comprising: obtaining a plurality of first images and random noise, wherein the different first images are denoised images predicted by a denoising module in a diffusion model at different historical steps; and fusing the plurality of first images and the random noise to obtain a denoised image of the current step. According to the present application, when the denoised images are predicted, the denoised images predicted at different historical steps are fused, such that the sampling error can be reduced under the same calculation consumption, thereby reducing the sampling frequency.
Need to check novelty before this filing date? Find Prior Art

Description

A data processing method and device thereof

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on July 28, 2023, with application number 202310950031.2 and invention name “A data processing method and device thereof”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of artificial intelligence, and in particular to a data processing method and device thereof. Background Art

[0003] Artificial Intelligence (AI) is the theory, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a branch of computer science that seeks to understand the essence of intelligence and develop new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.

[0004] The stable diffusion model (also known as the diffusion model) is a generative model used to generate high-fidelity multimedia data such as images, audio, and video. The diffusion model generates images through a diffusion process. The model trains and infers the model by performing multiple diffusion and inverse diffusion operations on noise. This makes the generation process of the diffusion model more stable and less prone to problems such as mode collapse.

[0005] Generative models simulate data distributions to generate new data that approximately follows a target distribution. The diffusion model, one of the most powerful generative models in recent years, defines a forward Markov chain that gradually adds noise to the data and then learns the inverse process of converting the noise into data.

[0006] To make the steady-state distribution close to the noise distribution, the diffusion model requires a sufficient number of iterations T (typically T = 1000). The original sampling method of the diffusion model is equivalent to inversely sampling T Markov chains, which is very time-consuming and hinders the widespread application of the diffusion model in downstream tasks.

[0007] Therefore, there is an urgent need to provide a fast and high-quality sampling method for diffusion models.

[0008] Summary of the Invention

[0009] The present application provides a data processing method that can reduce sampling errors while maintaining the same computational overhead, thereby reducing the number of sampling times.

[0010] In a first aspect, the present application provides a data processing method, which includes: acquiring multiple first images and random noise; different first images are denoised images predicted by the denoising module in the diffusion model at different historical step sizes; and fusing the multiple first images and the random noise to obtain a denoised image of the current step size.

[0011] When predicting a denoised image, the present application fuses the denoised images predicted at different historical step sizes, which can reduce the sampling error while maintaining the same computational overhead, thereby reducing the number of sampling times.

[0012] In one possible implementation, the method further includes: determining a first weight corresponding to each of the historical steps, each of the first weights being related to a numerical value obtained by mapping the historical step through a target mapping method, the target mapping method being used to determine the magnitude of the randomness of each step; and fusing the multiple first images with the random noise, including: fusing the multiple first images with the random noise according to the multiple first weights.

[0013] In an embodiment of the present application, a variance control function τ(t) can be applied to better control the randomness in the sampling process. Compared with the deterministic sampling method, randomness is introduced to improve the sampling quality. Compared with the existing random sampling method, the randomness in the sampling process is controllable.

[0014] In a possible implementation, each of the first weights is specifically obtained by performing a random Adams method on a value obtained by mapping the historical step length using the target mapping method.

[0015] The randomized Adams method can overcome the problems of low efficiency and slow convergence of the numerical format used in the existing technology.

[0016] In one possible implementation, the method further includes: determining a second weight corresponding to the random noise, the second weight being related to a numerical value obtained by mapping the historical step length through a target mapping method, the target mapping method being used to determine the magnitude of the randomness of each step length; and fusing the multiple first images with the random noise, including: fusing the multiple first images with the random noise according to the second weight.

[0017] In a possible implementation, fusing the multiple first images with the random noise includes: fusing a denoised image obtained with a latest step size, the multiple first images, and the random noise.

[0018] In one possible implementation, the method further includes: determining a third weight corresponding to the denoised image obtained by the most recent step, the third weight being related to a numerical value obtained by mapping the most recent step through a target mapping method, the target mapping method being used to determine the magnitude of the randomness of each step; and fusing the denoised image obtained by the most recent step, the multiple first images, and the random noise, including: fusing the denoised image obtained by the most recent step, the multiple first images, and the random noise according to the third weight.

[0019] In an embodiment of the present application, a linear combination of the model outputs of the previous steps, a linear scaling of the previous state and a Gaussian noise with analytic variance are used to obtain the next state (that is, the denoised image of the current step).

[0020] In a possible implementation, the target mapping method is a constant piecewise function.

[0021] In a possible implementation, the random noise is Gaussian random noise.

[0022] In one possible implementation, the fusing of the multiple first images and the random noise to obtain a denoised image of the current step length includes: fusing the multiple first images and the random noise to obtain an initial value of the denoised image of the current step length; processing the initial value through a denoising module in the diffusion model to obtain a processing result; and fusing the processing result, the multiple first images, and the random noise to obtain a denoised image of the current step length.

[0023] In one possible implementation, the method further includes: determining a fourth weight corresponding to the processing result, the fourth weight being related to a numerical value obtained by mapping the current step length through a target mapping method, the target mapping method being used to determine the size of the randomness of each step length; and fusing the processing result, the multiple first images and the random noise, including: fusing the processing result, the multiple first images and the random noise according to the fourth weight.

[0024] This is equivalent to correcting the result obtained by fusing the multiple first images with the random noise, thereby improving the prediction accuracy and reducing the number of sampling times. By introducing the prediction correction method, the sampling error is reduced while maintaining the same computational cost.

[0025] In a second aspect, the present application provides a data processing device, the device comprising:

[0026] an acquisition module, configured to acquire a plurality of first images and random noise; the different first images are denoised images predicted by the denoising module in the diffusion model at different historical step sizes;

[0027] A processing module is used to fuse the multiple first images and the random noise to obtain a denoised image of the current step size.

[0028] In a possible implementation, the processing module is further configured to:

[0029] Determining a first weight corresponding to each of the historical steps, each of the first weights is related to a value obtained by mapping the historical steps using a target mapping method, wherein the target mapping method is used to determine the magnitude of randomness of each step;

[0030] The processing module is specifically used to:

[0031] The multiple first images and the random noise are fused according to the multiple first weights.

[0032] In a possible implementation, each of the first weights is specifically obtained by performing a random Adams method on a value obtained by mapping the historical step length using the target mapping method.

[0033] In a possible implementation, the processing module is further configured to:

[0034] Determining a second weight corresponding to the random noise, the second weight being related to a value obtained by mapping the historical step lengths using a target mapping method, the target mapping method being used to determine a magnitude of randomness of each step length;

[0035] The processing module is specifically used to:

[0036] The multiple first images and the random noise are fused according to the second weight.

[0037] In a possible implementation, the processing module is specifically configured to:

[0038] The denoised image obtained by the most recent step size, the multiple first images and the random noise are fused.

[0039] In a possible implementation, the processing module is further configured to:

[0040] Determining a third weight corresponding to the denoised image obtained by the most recent step, the third weight being related to a value obtained by mapping the most recent step using a target mapping method, the target mapping method being used to determine a magnitude of randomness of each step;

[0041] The processing module is specifically used to:

[0042] The denoised image obtained by the most recent step size, the multiple first images and the random noise are fused according to the third weight.

[0043] In a possible implementation, the target mapping method is a constant piecewise function.

[0044] In a possible implementation, the random noise is Gaussian random noise.

[0045] In a possible implementation, the processing module is specifically configured to:

[0046] Fusing the multiple first images with the random noise to obtain an initial value of a denoised image of a current step size;

[0047] Processing the initial value by a denoising module in the diffusion model to obtain a processing result;

[0048] The processing result, the multiple first images and the random noise are fused to obtain a denoised image of the current step size.

[0049] In a possible implementation, the processing module is further configured to:

[0050] determining a fourth weight corresponding to the processing result, the fourth weight being related to a value obtained by mapping the current step length through a target mapping method, the target mapping method being used to determine a magnitude of randomness of each step length;

[0051] The processing module is specifically used to:

[0052] The processing result, the multiple first images and the random noise are fused according to the fourth weight.

[0053] In a third aspect, an embodiment of the present application provides a data processing device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to perform the first aspect and any optional method thereof.

[0054] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes the above-mentioned first aspect and any optional method thereof.

[0055] In a fifth aspect, an embodiment of the present application provides a computer program, which, when executed on a computer, enables the computer to execute the above-mentioned first aspect and any optional method thereof.

[0056] In a sixth aspect, the present application provides a chip system comprising a processor configured to support the execution of a data processing device to implement the functions described in the aforementioned aspects, such as transmitting or processing the data or information described in the aforementioned methods. In one possible design, the chip system further comprises a memory configured to store program instructions and data necessary for executing the device or training the device. The chip system may consist of a single chip or may include a chip and other discrete components. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] FIG1A is a schematic diagram of a structure of an artificial intelligence main framework;

[0058] 1B and 1C are schematic diagrams of the application system framework of the present invention;

[0059] FIG1D is a schematic diagram of an optional hardware structure of a terminal;

[0060] FIG2 is a schematic diagram of the structure of a server;

[0061] FIG3 is a schematic diagram of a system architecture of the present application;

[0062] FIG4A is a process of a cloud service;

[0063] FIG4B is a schematic diagram of an application scenario;

[0064] FIG4C is a schematic diagram of a network structure;

[0065] FIG4D is a schematic diagram of a network structure;

[0066] FIG4E is a schematic diagram of a network structure;

[0067] FIG5 is a flowchart of a data processing method provided in an embodiment of the present application;

[0068] FIG6 is a schematic diagram of a data processing method provided in an embodiment of the present application;

[0069] FIG7 is a schematic diagram of a data processing method provided in an embodiment of the present application;

[0070] FIG8 is a schematic diagram of a data processing method provided in an embodiment of the present application;

[0071] FIG9A is a schematic diagram of a data processing method provided in an embodiment of the present application;

[0072] FIG9B is a diagram illustrating the beneficial effects of an embodiment of the present application;

[0073] FIG10 is a schematic structural diagram of a data processing device provided in an embodiment of the present application;

[0074] FIG11 is a schematic diagram of the structure of an execution device provided in an embodiment of the present application;

[0075] FIG12 is a schematic diagram of a structure of a training device provided in an embodiment of the present application;

[0076] FIG13 is a schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION

[0077] The following describes the embodiments of the present invention in conjunction with the accompanying drawings. The terms used in the embodiments of the present invention are only used to explain the specific embodiments of the present invention, and are not intended to limit the present invention.

[0078] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0079] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, and this is merely a way of distinguishing the objects of the same attributes when describing them in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0080] As used herein, the terms "substantially," "about," and similar terms are used as terms of approximation, not as terms of degree, and are intended to take into account the inherent variations in measurements or calculations that one of ordinary skill in the art would recognize. Furthermore, the use of "may" when describing embodiments of the present invention refers to "one or more possible embodiments." As used herein, the terms "use," "using," and "used" may be considered synonymous with the terms "utilize," "utilizing," and "utilized," respectively. Additionally, the term "exemplary" is intended to refer to an example or illustration.

[0081] First, let's describe the overall workflow of an AI system. See Figure 1A, which shows a schematic diagram of the main AI framework. This AI framework will be explained from two perspectives: the "intelligent information chain" (horizontal axis) and the "IT value chain" (vertical axis). The "intelligent information chain" reflects the entire process from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. Throughout this process, data undergoes a condensed journey from "data-information-knowledge-wisdom." The "IT value chain," spanning the underlying infrastructure of human intelligence, information (provided and processed by technology), and the system's industrial ecosystem, reflects the value that AI brings to the information technology industry.

[0082] (1) Infrastructure

[0083] Infrastructure provides computing power for AI systems, enabling communication with the outside world and supporting this through a foundational platform. External communication occurs through sensors; computing power is provided by intelligent chips (CPUs, NPUs, GPUs, ASICs, FPGAs, and other hardware accelerators). The foundational platform includes a distributed computing framework and network-related platform guarantees and support, including cloud storage and computing, and interconnected networks. For example, sensors communicate with the outside world to acquire data, which is then fed into the intelligent chips within the distributed computing system provided by the foundational platform for computation.

[0084] (2) Data

[0085] Data above the infrastructure layer represents data sources for AI. This data includes graphics, images, voice, and text, as well as IoT data from traditional devices. This includes business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.

[0086] (3) Data processing

[0087] Data processing generally includes data training, machine learning, deep learning, search, reasoning, decision-making, etc.

[0088] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.

[0089] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.

[0090] Decision-making refers to the process of making decisions after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.

[0091] (4) General ability

[0092] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.

[0093] (5) Smart products and industry applications

[0094] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical application. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, smart cities, etc.

[0095] This application can be applied to the field of natural language processing in the field of artificial intelligence. Taking natural language processing as an example, the following will introduce multiple application scenarios that have been implemented in products.

[0096] First, we will introduce the application scenarios of this application. This application can be applied to, but is not limited to, applications with image generation, natural language synthesis, image classification, or retrieval functions (hereinafter referred to as generation applications) or cloud services provided by cloud-side servers. The following are introduced respectively:

[0097] 1. Generate application

[0098] The product form of the embodiment of the present application can be a generation type application. The generation type application can be run on a terminal device or a cloud-side server.

[0099] In a possible implementation, a generation application can implement an image generation task and obtain a processing result.

[0100] For example, the generation application may implement at least an image generation task based on a diffusion method, but is not limited thereto.

[0101] In one possible implementation, the user can open a generation application installed on the terminal device and input image data and text data (the text may be triggered by instructions and not necessarily actively input by the user). The generation application can process the image and text using a model trained by the method provided in the embodiment of the present application, or using the method provided in the embodiment of the present application, and present the processing results to the user (the presentation method may be but is not limited to display, playback, saving, uploading to the cloud side, etc.).

[0102] In one possible implementation, a user can open a generation application installed on a terminal device and input image data and text data. The generation application can send the image data and text data to a cloud-side server. The cloud-side server processes the image or text using a model trained using the method provided in an embodiment of the present application, and transmits the processing results back to the terminal device. The terminal device can present the processing results to the user (the presentation method may be, but is not limited to, display, playback, saving, uploading to the cloud side, etc.).

[0103] For example, the image generation task can be applied to, but not limited to, the following scenarios:

[0104] Scenario 1: Generation of autonomous driving scenario detection data.

[0105] In the context of autonomous driving test data generation, it is necessary to generate images with rich, realistic, and diverse traffic environments. These images should include various road types (e.g., city streets, highways), different weather conditions (sunny, rainy, snowy, etc.), multiple traffic participants (pedestrians, cyclists, cars, trucks, etc.), and various traffic rules and signals (traffic lights, stop signs, pedestrian crossings, etc.). Furthermore, the generated images need to take into account various camera perspectives and positions to simulate the visual perception capabilities of the autonomous driving system in actual road conditions. As shown in Figure 8, given the layout of the autonomous driving scene in the lower left corner, multiple autonomous driving data with the same layout can be generated (shown in the upper right corner of Figure 8).

[0106] Scenario 2: Smartwatch dial data generation.

[0107] When generating smartphone watch face data, it's necessary to generate diverse, personalized, and highly authentic watch face elements based on a specific watch face layout. These elements include hands (hour, minute, and second hands), day and date display, step counter, heart rate monitoring, battery level information, and more. Furthermore, the generated watch faces must consider various design styles, color schemes, and fonts to meet users' individual needs and aesthetic preferences.

[0108] Scenario 3: AI model generation for e-commerce scenarios.

[0109] In AI model generation in e-commerce scenarios, it is necessary to generate a variety of clothing combinations based on the input of a specified model look in order to present them to potential consumers. First, the model needs to receive the model look input by the user, such as body shape, posture and other features. Then, based on these features, the generation algorithm will generate a series of clothing combinations that match the model look. These combinations may include different types of tops, pants, skirts, coats, shoes, etc. During the generation process, the algorithm needs to take into account details such as the style, color, and pattern of the clothing, and ensure that the generated combinations are visually attractive and authentic. In addition, to meet the needs of different consumers, the generated clothing combinations should be diverse, covering different styles, occasions and seasons.

[0110] Next, the generation type application in the embodiment of this application is introduced from the functional architecture and the product architecture that realizes the function.

[0111] Referring to FIG. 1B , FIG. 1B is a schematic diagram of the functional architecture of a generation-type application in an embodiment of the present application:

[0112] In one possible implementation, as shown in FIG1B , a generation application 102 may receive input parameters 101 (e.g., including an image or text) and generate a processing result 103. The generation application 102 may be executed on (for example) at least one computer system and include computer code that, when executed by one or more computers, causes the computers to execute a model trained using the method provided in the embodiments of the present application.

[0113] Referring to FIG. 1C , FIG. 1C is a schematic diagram of the entity architecture for running a generation-type application in an embodiment of the present application:

[0114] Referring to FIG1C , FIG1C shows a schematic diagram of a system architecture. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers (FIG1C illustrates one server as an example), and the server 200 may provide image synthesis or natural language generation functions for one or more terminals.

[0115] Among them, the terminal 100 can be installed with a generation application, or a web page related to the image synthesis or natural language generation function can be opened. The above application and web page can provide an interface. The terminal 100 can receive the relevant parameters entered by the user on the image synthesis or natural language generation function interface, and send the above parameters to the server 200. The server 200 can obtain the processing results based on the received parameters and return the processing results to the terminal 100.

[0116] It should be understood that in some optional implementations, the terminal 100 can also complete the action of obtaining the processing result based on the received parameters by itself without the need for the cooperation of the server, and the embodiments of the present application are not limited to this.

[0117] Next, the product form of the terminal 100 in FIG1C is described;

[0118] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this.

[0119] FIG1D shows a schematic diagram of an optional hardware structure of the terminal 100 .

[0120] 1D , the terminal 100 may include components such as a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), a processor 170, an external interface 180, and a power supply 190. Those skilled in the art will appreciate that FIG1D is merely an example of a terminal or multi-function device and does not limit the terminal or multi-function device. The terminal or multi-function device may include more or fewer components than shown, or may combine certain components or have different components.

[0121] The input unit 130 can be used to receive input digital or character information and generate key signal input related to user settings and function control of the portable multifunction device. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can detect user touch operations on or near it (for example, operations performed on or near the touch screen using a finger, joint, stylus, or any other suitable object) and drive corresponding connected devices according to pre-set programs. The touch screen can detect user touch actions on the touch screen, convert the touch actions into touch signals and transmit them to the processor 170. It can also receive and execute commands sent by the processor 170; the touch signals include at least touch point coordinate information. The touch screen 131 provides an input interface and an output interface between the terminal 100 and the user. Touch screens can be implemented using various types, including resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch screen 131, the input unit 130 may also include other input devices. Specifically, the other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.

[0122] Among them, other input devices 132 can receive input image data or text data.

[0123] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file display, and / or playback of any multimedia file. In an embodiment of the present application, the display unit 140 may be used to display the interface of a generated application, processing results, etc.

[0124] Memory 120 can be used to store instructions and data. It primarily includes an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files and text. The instruction storage area can store software units such as the operating system, applications, and instructions required for at least one function, or subsets or extensions thereof. It may also include non-volatile random access memory (RAM). It provides processor 170 with management functions for the hardware, software, and data resources within the computing and processing device, supporting control software and applications. It is also used to store multimedia files and running programs and applications.

[0125] The processor 170 is the control center of the terminal 100. It connects all components of the terminal 100 using various interfaces and circuits. By executing instructions stored in the memory 120 and accessing data stored therein, it executes various functions of the terminal 100 and processes data, thereby providing overall control of the terminal device. Optionally, the processor 170 may include one or more processing units. Preferably, the processor 170 may integrate an application processor and a modem processor, with the application processor primarily processing the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 170. In some embodiments, the processor and memory may be implemented on a single chip; in other embodiments, they may be implemented on separate chips. The processor 170 may also generate corresponding operational control signals and send them to the corresponding components of the computing and processing device. It may also read and process data in the software, particularly the data and programs in the memory 120, to enable the various functional modules therein to perform their corresponding functions, thereby controlling the corresponding components to operate as instructed.

[0126] Among them, the memory 120 can be used to store software codes related to the data processing method, the processor 170 can execute the steps of the chip's data processing method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to achieve corresponding functions.

[0127] The RF unit 110 (optional) can be used to send and receive information or receive and send signals during a call. For example, after receiving downlink information from the base station, it is passed to the processor 170 for processing; in addition, it sends the designed uplink data to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF unit 110 can also communicate with network devices and other devices via wireless communication. This wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.

[0128] In this embodiment of the present application, the RF unit 110 may send image data or text data to the server 200 and receive a processing result sent by the server 200.

[0129] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.

[0130] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.

[0131] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to other devices for communication, or to connect a charger to charge the terminal 100 .

[0132] Although not shown, the terminal 100 may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied to the terminal 100 shown in FIG1D .

[0133] Next, the product form of the server 200 in FIG1C is described;

[0134] FIG2 provides a schematic diagram of the structure of a server 200. As shown in FIG2, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.

[0135] Bus 201 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, FIG2 shows only one thick line, but this does not imply that there is only one bus or only one type of bus.

[0136] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0137] The memory 204 may include volatile memory, such as random access memory (RAM). The memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard drive (HDD), or solid state drive (SSD).

[0138] The memory 204 may be used to store software codes related to the data processing method, and the processor 202 may execute the steps of the data processing method of the chip, and may also schedule other units to implement corresponding functions.

[0139] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.

[0140] It should be understood that the steps related to the model reasoning process in the embodiments of this application involve AI-related operations. When performing AI operations, the instruction execution architecture of the terminal device and server is not limited to the processor-memory architecture described above. The system architecture provided in the embodiments of this application is described in detail below with reference to Figure 3.

[0141] FIG3 is a schematic diagram of the system architecture provided by an embodiment of the present application. As shown in FIG3 , the system architecture 500 includes an execution device 510 , a training device 520 , a database 530 , a client device 540 , a data storage system 550 , and a data acquisition system 560 .

[0142] The execution device 510 includes a calculation module 511, an I / O interface 512, a pre-processing module 513, and a post-processing module 514. The calculation module 511 may include the target model / rule 501, and the pre-processing module 513 and the post-processing module 514 are optional.

[0143] The execution device 510 may be a terminal device or a server that runs the aforementioned generation application, or an image classification or retrieval application.

[0144] The data acquisition device 560 is used to collect training samples. The training samples can be image data or text data. After collecting the training samples, the data acquisition device 560 stores these training samples in the database 530.

[0145] The training device 520 can train the neural network to be trained (such as the neural network model in the embodiment of the present application (such as a text encoder, diffusion model, etc.)) based on the training samples maintained in the database 530 to obtain the target model / rule 501.

[0146] It should be understood that the training device 520 can perform a pre-training process on the neural network to be trained based on the training samples maintained in the database 530, or fine-tune the model based on the pre-training.

[0147] It should be noted that, in actual applications, the training samples maintained in the database 530 may not all be collected by the data acquisition device 560, but may also be received from other devices. It should also be noted that the training device 520 may not train the target model / rule 501 entirely based on the training samples maintained in the database 530, but may also obtain training samples from the cloud or other places for model training. The above description should not be used as a limitation on the embodiments of the present application.

[0148] The target model / rule 501 obtained through training with the training device 520 can be applied to different systems or devices, such as the execution device 510 shown in FIG3 . The execution device 510 can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality (AR) / virtual reality (VR) device, an in-vehicle terminal, etc., or a server, etc.

[0149] Specifically, the training device 520 may transfer the trained model to the execution device 510 .

[0150] In Figure 3, the execution device 510 is configured with an input / output (I / O) interface 512 for data interaction with an external device. The user can input data (such as image data or text data in the embodiment of the present application) into the I / O interface 512 through the client device 540.

[0151] Preprocessing module 513 and preprocessing module 514 are used to preprocess the input data received by I / O interface 512. It should be understood that preprocessing module 513 and preprocessing module 514 may be absent or only one preprocessing module may be present. If preprocessing module 513 and preprocessing module 514 are absent, computing module 511 may be used directly to process the input data.

[0152] When the execution device 510 preprocesses the input data, or when the computing module 511 of the execution device 510 performs calculations and other related processing, the execution device 510 can call the data, code, etc. in the data storage system 550 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing in the data storage system 550.

[0153] Finally, the I / O interface 512 provides the processed results to the client device 540 and thus to the user.

[0154] In the scenario shown in FIG3 , the user can manually input data, and this "manual input data" can be operated through the interface provided by I / O interface 512. In another scenario, client device 540 can automatically send input data to I / O interface 512. If user authorization is required for client device 540 to automatically send input data, the user can set the corresponding permissions in client device 540. The user can view the results output by execution device 510 on client device 540, and the specific presentation form can be a display, sound, action, or other specific method. Client device 540 can also serve as a data acquisition terminal, collecting input data input into I / O interface 512 and output results output from I / O interface 512 as new sample data, and storing them in database 530. Of course, collection can also be performed without client device 540, and instead the I / O interface 512 directly stores the input data input into I / O interface 512 and output results output from I / O interface 512 as new sample data in database 530.

[0155] It is worth noting that FIG3 is merely a schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationships between the devices, components, modules, etc. shown in the figure do not constitute any limitation. For example, in FIG3 , the data storage system 550 is an external memory relative to the execution device 510. In other cases, the data storage system 550 can also be placed in the execution device 510. It should be understood that the execution device 510 can be deployed in the client device 540.

[0156] From the inference side of the model:

[0157] In the embodiment of the present application, the computing module 511 of the above-mentioned execution device 510 can obtain the code stored in the data storage system 550 to implement the steps related to the model reasoning process in the embodiment of the present application.

[0158] In an embodiment of the present application, the computing module 511 of the execution device 510 may include a hardware circuit (such as an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a general-purpose processor, a digital signal processor (DSP), a microprocessor or a microcontroller, etc.), or a combination of these hardware circuits. For example, the training device 520 may be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.

[0159] Specifically, the computing module 511 of the execution device 510 can be a hardware system with an execution instruction function, and the steps related to the model reasoning process provided in the embodiment of the present application can be software codes stored in the memory. The computing module 511 of the execution device 510 can obtain the software code from the memory and execute the obtained software code to implement the steps related to the model reasoning process provided in the embodiment of the present application.

[0160] It should be understood that the computing module 511 of the execution device 510 can be a combination of a hardware system that does not have the function of executing instructions and a hardware system that has the function of executing instructions. Some of the steps related to the model reasoning process provided in the embodiment of the present application can also be implemented by the hardware system that does not have the function of executing instructions in the computing module 511 of the execution device 510, which is not limited here.

[0161] From the training side of the model:

[0162] In an embodiment of the present application, the above-mentioned training device 520 can obtain the code stored in the memory (not shown in Figure 3, which can be integrated into the training device 520 or deployed separately from the training device 520) to implement the steps related to model training in the embodiment of the present application.

[0163] In an embodiment of the present application, the training device 520 may include a hardware circuit (such as an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a general-purpose processor, a digital signal processor (DSP), a microprocessor or a microcontroller, etc.), or a combination of these hardware circuits. For example, the training device 520 may be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.

[0164] It should be understood that the training device 520 can be a combination of a hardware system that does not have the function of executing instructions and a hardware system that has the function of executing instructions. Some of the steps related to model training provided in the embodiments of the present application can also be implemented by the hardware system in the training device 520 that does not have the function of executing instructions, which is not limited here.

[0165] 2. Image synthesis cloud services provided by the server:

[0166] In a possible implementation, the server may provide the image synthesis function service to the terminal side through an application programming interface (API).

[0167] Among them, the terminal device can send relevant parameters (such as images, text and other data) to the server through the API provided by the cloud. The server can obtain processing results based on the received parameters, etc., and return the processing results to the terminal.

[0168] The description of the terminal and the server can be the same as that of the above embodiments, and will not be repeated here.

[0169] FIG4A shows a process of using a cloud service of image synthesis function provided by a cloud platform.

[0170] 1. Activate and purchase content review services.

[0171] 2. Users can download the software development kit (SDK) corresponding to the content review service. Usually, the cloud platform provides multiple development versions of the SDK for users to choose according to the requirements of the development environment, such as JAVA version SDK, Python version SDK, PHP version SDK, Android version SDK, etc.

[0172] 3. After the user downloads the corresponding version of the SDK to the local computer as needed, they import the SDK project into the local development environment, configure and debug it in the local development environment, and develop other functions in the local development environment, forming an application that integrates image synthesis capabilities.

[0173] 4. When an image synthesis application is used and needs to perform image synthesis, it can trigger an API call for this function. When the application triggers this function, it initiates an API request to a running instance of the image synthesis service in the cloud environment. The API request includes an image or text, and the running instance in the cloud environment processes the image and obtains the processing result.

[0174] 5. The cloud environment returns the processing results to the application, thus completing a call to the image synthesis function.

[0175] 4B , which is a schematic diagram of an application of image generation, can generate an image containing a head based on an image not containing a head.

[0176] Since the embodiments of the present application involve the application of a large number of neural networks, in order to facilitate understanding, the relevant terms and related concepts such as neural networks involved in the embodiments of the present application are first introduced below.

[0177] (1) Neural Network

[0178] A neural network can be composed of neural units. A neural unit can refer to an operation unit that takes xs (i.e., input data) and intercept 1 as input. The output of the operation unit can be:

[0179] Where s = 1, 2, ... n, n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal of the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple single neural units mentioned above, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field. The local receptive field can be an area composed of several neural units.

[0180] (2) Convolutional neural network (CNN) is a deep neural network with a convolutional structure. Convolutional neural network contains a feature extractor consisting of a convolution layer and a subsampling layer, which can be regarded as a filter. The convolution layer refers to the neuron layer in the convolutional neural network that performs convolution processing on the input signal. In the convolution layer of the convolutional neural network, a neuron can only be connected to some neurons in the adjacent layer. A convolution layer usually contains several feature planes, and each feature plane can be composed of some rectangularly arranged neural units. The neural units in the same feature plane share weights, and the shared weights here are convolution kernels. Shared weights can be understood as the way of extracting features is independent of position. The convolution kernel can be formalized as a matrix of random size, and the convolution kernel can obtain reasonable weights through learning during the training process of the convolutional neural network. In addition, the direct benefit of shared weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.

[0181] CNN is a very common neural network. The following section will focus on a detailed description of its structure, using Figure 4C. As previously mentioned in the basic concepts, a convolutional neural network is a deep neural network with a convolutional structure. It is a deep learning architecture, which uses machine learning algorithms to perform multiple levels of learning at different levels of abstraction. As a deep learning architecture, a CNN is a feed-forward artificial neural network, in which individual neurons respond to input images.

[0182] As shown in FIG4C , the convolutional neural network (CNN) 200 may include an input layer 210 , a convolutional layer / pooling layer 220 (wherein the pooling layer is optional), and a fully connected layer 230 .

[0183] Convolutional layer / pooling layer 220:

[0184] Convolutional layer:

[0185] As shown in FIG4C , the convolutional layer / pooling layer 220 may include layers 221-226. For example, in one implementation, layer 221 is a convolutional layer, layer 222 is a pooling layer, layer 223 is a convolutional layer, layer 224 is a pooling layer, layer 225 is a convolutional layer, and layer 226 is a pooling layer. In another implementation, layers 221 and 222 are convolutional layers, layer 223 is a pooling layer, layers 224 and 225 are convolutional layers, and layer 226 is a pooling layer. That is, the output of a convolutional layer can serve as the input of a subsequent pooling layer, or as the input of another convolutional layer to continue the convolution operation.

[0186] The following will take convolutional layer 221 as an example to introduce the internal working principle of a convolutional layer.

[0187] Convolution layer 221 can include multiple convolution operators, also known as kernels. In image processing, a convolution operator acts as a filter that extracts specific information from an input image matrix. A convolution operator is essentially a weight matrix, which is typically predefined. During the convolution operation, the weight matrix is ​​typically applied horizontally to the input image, pixel by pixel (or two pixels by two pixels, depending on the stride), thereby extracting specific features from the image. The size of the weight matrix should be related to the image size. It is important to note that the depth dimension of the weight matrix is ​​the same as the depth dimension of the input image. During the convolution operation, the weight matrix extends across the entire depth of the input image. Therefore, convolution with a single weight matrix produces a convolution output with a single depth dimension. However, in most cases, a single weight matrix is ​​not used. Instead, multiple weight matrices of the same size (rows × columns) are applied, i.e., multiple homogeneous matrices. The outputs of each weight matrix are stacked to form the depth dimension of the convolved image, where the dimension is determined by the "multiple" mentioned above. Different weight matrices can be used to extract different features from an image. For example, one weight matrix can be used to extract edge information, another weight matrix can be used to extract specific colors, and yet another weight matrix can be used to blur unwanted noise in the image. The weight matrices have the same size (rows × columns), and the feature maps extracted by these weight matrices are also the same size. The extracted feature maps of the same size are then merged to form the output of the convolution operation.

[0188] The weight values ​​in these weight matrices need to be obtained through a lot of training in practical applications. The weight matrices formed by the weight values ​​obtained through training can be used to extract information from the input image, so that the convolutional neural network 200 can make correct predictions.

[0189] When the convolutional neural network 200 has multiple convolutional layers, the initial convolutional layer (for example, 221) often extracts more general features, which can also be called low-level features. As the depth of the convolutional neural network 200 increases, the features extracted by the later convolutional layers (for example, 226) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.

[0190] Pooling layer:

[0191] Because it's often necessary to reduce the number of training parameters, pooling layers are often periodically introduced after convolutional layers. For example, in layers 221-226, as shown in the example of 220 in Figure 4C , a single convolutional layer can be followed by a pooling layer, or multiple convolutional layers can be followed by one or more pooling layers. In image processing, the sole purpose of a pooling layer is to reduce the spatial size of an image. Pooling layers can include average pooling and / or max pooling operators, which are used to downsample the input image to produce a smaller image. The average pooling operator calculates the average value of pixel values ​​within a specific range as the average pooling result. The max pooling operator takes the pixel with the largest value within a specific range as the max pooling result. Furthermore, just as the size of the weight matrix used in the convolutional layer should be related to the image size, the operators in the pooling layer should also be related to the image size. The output image size after processing by the pooling layer can be smaller than the size of the image input to the pooling layer. Each pixel in the output image of the pooling layer represents the average or maximum value of the corresponding subregion of the image input to the pooling layer.

[0192] Fully connected layer 230:

[0193] After being processed by the convolution layer / pooling layer 220, the convolutional neural network 200 is still insufficient to output the required output information. Because as mentioned above, the convolution layer / pooling layer 220 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (the required class information or other relevant information), the convolutional neural network 200 needs to use the fully connected layer 230 to generate one or a group of outputs of the required number of classes. Therefore, the fully connected layer 230 may include multiple hidden layers (231, 232 to 23n as shown in Figure 4C), and the parameters contained in the multiple hidden layers can be pre-trained based on relevant training data of a specific task type. For example, the task type may include image recognition, image classification, image super-resolution reconstruction, etc.

[0194] After the multiple hidden layers in the fully connected layer 230, that is, the last layer of the entire convolutional neural network 200 is the output layer 240. The output layer 240 has a loss function similar to the classification cross entropy, which is specifically used to calculate the prediction error. Once the forward propagation of the entire convolutional neural network 200 (as shown in Figure 4C, the propagation from 210 to 240 is forward propagation) is completed, the back propagation (as shown in Figure 4C, the propagation from 240 to 210 is back propagation) will begin to update the weight values ​​and biases of the aforementioned layers to reduce the loss of the convolutional neural network 200 and the error between the result output by the convolutional neural network 200 through the output layer and the ideal result.

[0195] It should be noted that the convolutional neural network 200 shown in Figure 4C is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models, for example, including only a part of the network structure shown in Figure 4C. For example, the convolutional neural network used in the embodiment of the present application can only include an input layer 210, a convolution layer / pooling layer 220 and an output layer 240.

[0196] It should be noted that the convolutional neural network 100 shown in Figure 4C is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models. For example, as shown in Figure 4D, multiple convolutional layers / pooling layers are run in parallel, and the extracted features are input into the fully connected layer 230 for processing.

[0197] (3) Deep Neural Networks

[0198] Deep Neural Network (DNN), also known as multi-layer neural network, can be understood as a neural network with many hidden layers. There is no special metric for "many" here. Based on the position of different layers in DNN, the neural network inside DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between are all hidden layers. The layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer. Although DNN looks complicated, the work of each layer is actually not complicated. Simply put, it is the following linear relationship expression: in, is the input vector, is the output vector, is the offset vector, W is the weight matrix (also called coefficient), and α() is the activation function. Each layer is just an input vector After such a simple operation, the output vector Since there are many DNN layers, the coefficient W and the offset vector The definition of these parameters in DNN is as follows: Take the coefficient W as an example: Assume that in a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as The superscript 3 represents the layer number of the coefficient W, while the subscripts correspond to the third layer index 2 of the output and the second layer index 4 of the input.

[0199] In summary, the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as

[0200] It's important to note that the input layer has no W parameter. In deep neural networks, more hidden layers allow the network to better capture complex real-world situations. Theoretically, a model with more parameters has higher complexity and greater "capacity," meaning it can handle more complex learning tasks. Training a deep neural network is essentially the process of learning the weight matrix, with the ultimate goal of obtaining the weight matrices for all layers of a trained deep neural network (a weight matrix formed by the vectors W across many layers).

[0201] (4) Transformer layer

[0202] Referring to FIG4E , FIG4E is a schematic diagram of the architecture of a transformer layer. As shown in FIG4E , the neural network includes an embedding layer and at least one transformer layer. The at least one transformer layer can be N transformer layers (N is an integer greater than 0), wherein each transformer layer includes an attention layer, an add & norm layer, a feed forward layer, and an add & normalization layer that are adjacent in sequence. In the embedding layer, the current input is embedded to obtain multiple feature vectors; in the attention layer, P input vectors are obtained from the previous layer of the transformer layer, and with any first input vector among the P input vectors as the center, based on the correlation between each input vector within a preset attention window and the first input vector, an intermediate vector corresponding to the first input vector is obtained, thereby determining the P intermediate vectors corresponding to the P input vectors; in the pooling layer, the P intermediate vectors are merged into Q output vectors, wherein the multiple output vectors obtained by the last transformer layer in at least one transformer layer are used as feature representations of the current input.

[0203] Next, the above steps are introduced in detail with reference to specific examples.

[0204] First, in the embedding layer, the current input is embedded to obtain multiple feature vectors.

[0205] The embedding layer can be called an input embedding layer. The current input can be a text input, for example, a paragraph of text or a sentence. The text can be Chinese text, English text, or text in other languages. After obtaining the current input, the embedding layer can embed each word in the current input to obtain a feature vector for each word. In some embodiments, as shown in Figure 4E, the embedding layer includes an input embedding layer and a positional encoding layer. In the input embedding layer, word embedding processing can be performed on each word in the current input to obtain a word embedding vector for each word. In the positional encoding layer, the position of each word in the current input can be obtained, and then a position vector is generated for the position of each word. In some examples, the position of each word can be the absolute position of each word in the current input. Taking the current input "How many numbers should I return Huabei" as an example, the position of "how many" can be represented as the first position, the position of "number" can be represented as the second position, and so on. In some examples, the position of each word can be the relative position between each word. Still taking the current input of "On which date should I repay" as an example, the position of "on which date" can be expressed as before "number", the position of "number" can be expressed as after "on which date" and before "should", etc. When the word embedding vector and position vector of each word in the current input are obtained, the position vector of each word and the corresponding word embedding vector can be combined to obtain the feature vector of each word, that is, to obtain multiple feature vectors corresponding to the current input. Multiple feature vectors can be represented as an embedding matrix with a preset dimension. The number of feature vectors in the multiple feature vectors can be set to M, and the preset dimension can be H, so that the multiple feature vectors can be represented as an M×H embedding matrix.

[0206] Next, P input vectors are obtained from the layer above the first transformer layer. Taking any first input vector among the P input vectors as the center, the intermediate vector corresponding to the first input vector is obtained based on the correlation between each input vector within a preset attention window and the first input vector. In this way, the P intermediate vectors corresponding to the P input vectors are determined. The attention layer can also be called a multi-head attention layer. In one example, the attention layer can be a fixed window multi-head attention layer.

[0207] In some embodiments, the first transformer layer may be the next layer of the above-mentioned embedding layer, and the P input vectors are the multiple feature vectors obtained from the embedding layer. In some embodiments, at least one transformer layer in the neural network provided by the embodiments of this specification also includes a second transformer layer. The second transformer layer is the previous layer of the first self-attention, and the P input vectors are the P output vectors output by the second transformer layer. In the last transformer layer in the neural network, the multiple output vectors obtained through the above steps can be used as a feature representation of the current input. The feature representation is a feature representation of the current input suitable for computer processing.

[0208] (5) Attention mechanism

[0209] The attention mechanism mimics the internal process of biological observation behavior, namely, a mechanism that aligns internal experience and external sensations to increase the observation precision of certain areas. It can quickly filter out high-value information from a large amount of information using limited attention resources. The attention mechanism can quickly extract important features from sparse data and is therefore widely used in natural language processing tasks, especially machine translation. The self-attention mechanism is an improvement on the attention mechanism, which reduces dependence on external information and is better at capturing the internal correlation of data or features. The essential idea of ​​the attention mechanism can be rewritten as the following formula:

[0210] Here, Lx = ||Source|| represents the length of the Source. This formula implies that the elements in the Source are imagined to consist of a series of data pairs. Given a Query element in the target, the similarity or correlation between the Query and each Key is calculated to obtain the weight coefficient for each Key's corresponding Value. The weighted sum of the Values ​​is then taken to obtain the final Attention value. Essentially, the Attention mechanism performs a weighted sum of the Values ​​of the Source elements, with the Query and Key used to calculate the weight coefficient for the corresponding Value. Conceptually, Attention can be understood as selectively filtering out a small amount of important information from a large amount of information and focusing on this important information, while ignoring the majority of less important information. This focusing process is reflected in the calculation of the weight coefficients: the larger the weight, the more focus is placed on the corresponding Value. In other words, the weight represents the importance of the information, while the Value represents the corresponding information. The self-attention mechanism can be understood as internal attention. The attention mechanism occurs between the Query element of the Target and all elements of the Source. The self-attention mechanism refers to the attention mechanism that occurs between the internal elements of the Source or the internal elements of the Target. It can also be understood as the attention calculation mechanism in the special case of Target = Source. The specific calculation process is the same, only the calculation object has changed.

[0211] (6) Loss function

[0212] During the training of a deep neural network, because we want the output of the deep neural network to be as close as possible to the desired predicted value, we can compare the current network's predicted value with the desired target value and then update the weight vector of each layer of the neural network based on the difference between the two. (Of course, before the first update, there is usually an initialization process, which pre-configures the parameters for each layer in the deep neural network.) For example, if the network's predicted value is too high, the weight vector is adjusted to make it predict a lower value. This adjustment is continued until the deep neural network can predict the desired target value or a value very close to the desired target value. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value." This is the loss function (or objective function), which is an important equation used to measure the difference between the predicted value and the target value. For example, the loss function output value (loss) indicates a greater difference, so training a deep neural network becomes a process of minimizing this loss.

[0213] (7) Backpropagation algorithm

[0214] The back propagation (BP) algorithm can be used to correct the size of the initial model parameters during training, reducing the model's error loss. Specifically, forward propagation of the input signal to the output generates error loss. This error loss information is then backpropagated to update the parameters in the initial model, thereby converging the error loss. The BP algorithm is a backward propagation movement driven by error loss, aiming to obtain optimal model parameters, such as the weight matrix.

[0215] (8) Diffusion model

[0216] A generative model used to generate data, such as images and text. The core idea of ​​the diffusion model is to diffuse noise into the data and then gradually remove the noise to restore the original data. The diffusion model consists of two stages: the forward process (noise diffusion) and the reverse process (noise removal and restoration).

[0217] The stable diffusion model (also known as the diffusion model) is a generative model used to generate high-fidelity multimedia data such as images, audio, and video. The diffusion model generates images through a diffusion process. The model trains and infers the model by performing multiple diffusion and inverse diffusion operations on noise. This makes the generation process of the diffusion model more stable and less prone to problems such as mode collapse.

[0218] Generative models simulate data distributions to generate new data that approximately follows a target distribution. The diffusion model, one of the most powerful generative models in recent years, defines a forward Markov chain that gradually adds noise to the data and then learns the inverse process of converting the noise into data.

[0219] To make the steady-state distribution close to the noise distribution, the diffusion model requires a sufficient number of iterations T (typically T = 1000). The original sampling method of the diffusion model is equivalent to inversely sampling T Markov chains, which is very time-consuming and hinders the widespread application of the diffusion model in downstream tasks.

[0220] Therefore, there is an urgent need to provide a fast and high-quality sampling method for diffusion models.

[0221] In order to solve the above problems, the present invention provides a data processing method. The data processing method of the present invention is described in detail below with reference to the accompanying drawings.

[0222] Referring to Figure 5, Figure 5 is a flow chart of a data processing method provided in an embodiment of the present application. As shown in Figure 5, a data processing method provided in an embodiment of the present application may include steps 501 to 502, and these steps are described in detail below.

[0223] 501. Acquire multiple first images and random noise; different first images are denoised images predicted by the denoising module in the diffusion model at different historical step lengths;

[0224] The embodiment corresponding to FIG5 may be an inference process of a diffusion model, or a feedforward process of diffusion model training, such as a model pre-training or model fine-tuning process.

[0225] The architecture of the diffusion model applicable to the embodiments of the present application includes but is not limited to the following two examples:

[0226] Architecture 1: Stable Diffusion-AIGC

[0227] Referring to Figure 6, it mainly includes an encoder module, a decoder module, a denoising module, and a conditional injection module. The encoder module is used to encode the image x from the RGB pixel space to the latent space to obtain the latent state representation z, and the decoder module is used to decode the latent state z from the latent space to the RGB pixel space. The denoising module is used to fit the score function of the diffusion process in the latent space, and the conditional injection module is used to inject conditional information into the U-Net.

[0228] The embodiment of the present application can be applied to the iterative denoising process in the latent space of Stable Diffusion-AIGC, that is, z T Combined with the denoising module information, it is converted into z T-1 in the process.

[0229] Architecture 2: ControlNet-AIGC

[0230] ControlNet-AIGC is a neural network architecture that efficiently adds new conditional controls. The principle of ControlNet-AIGC is shown in Figure 7. It replicates the parameters of the original denoising module and concatenates its output layer by layer. During fine-tuning, the parameters of the original denoising module are frozen (not included in training), while the parameters of the ControlNet module participate in training. After training, the newly concatenated denoising module replaces the original one.

[0231] The embodiment of the present application can be applied to the iterative denoising process of ControlNet-AIGC, that is, z TConvert the information of the ControlNet denoising module obtained through combined training into z T-1 during the process.

[0232] Next, the data processing method of the embodiment of the present application will be introduced:

[0233] In the noise diffusion stage of the diffusion model, for the input image, it can be encoded by an image encoder to obtain the image features corresponding to the image. Exemplarily, given an input image x, the latent feature z of the image can be obtained through the image encoder V (exemplarily, a convolutional neural network with downsampling can be used).

[0234] Optionally, the image encoder can be composed of a convolutional neural network, which is used to extract the full-image features with a smaller resolution to reduce the computational amount of the subsequent network. This encoder reduces the resolution of the original image from H*W to where r is the downsampling ratio.

[0235] In the denoising stage of the diffusion model, given a diffusion model x θ , sample a Gaussian random variable ξ that follows N(0, I) as the initial state of the diffusion model, that is

[0236] A time difference strategy can be selected. For example, select the time difference step 1e-3 = t M <t M-1 <...<t0 = 1. In the following process, as shown in Figure 8, taking the calculation process from time step t i to time step t i+1 as an example, the embodiment of the present application can calculate from time step t0 to t in accordance with this process​​​​​​​​​​When using the diffusion model for image generation, the original image (or the feature representation of the original image) can be denoised by the denoising module of the diffusion model. Specifically, the noise can be added according to the noise given by β t The variance given is gradually added to the sample Gaussian noise to produce a series of latent variables x1,x2,…,x T , where t is the number of steps to add noise (or it can be called step length), and N is the normal distribution:

[0240] Then learn a denoising module Φ θ (x t ,t) (that is, the denoising model in the diffusion model) to approximate the true posterior distribution, where u θ and Σ θ are the mean and variance predicted by the model:

[0241] p θ (x t-1 |x t )=N(u θ (x t ,t),∑ θ (x t ,t));

[0242] In order to perform the inverse denoising process, we sample from random noise x T Starting from N(0,I), the noise is gradually reduced and finally a sample x0 is obtained. The existing method uses a denoising network Φ θ (x t ,t), which predicts the noise component of the noise sample and the following training objectives:

[0243] Among them, t can be uniformly sampled from 1, 2, …, T, and ∈ is the noise added to the model at each step.

[0244] In an embodiment of the present application, when predicting a certain step length (noise can be predicted, or the denoised image can be predicted), the denoised image (that is, the first image) obtained by the denoising model in multiple historical step length predictions, as well as random noise, can be obtained.

[0245] For example, referring to the following formula, where X θ Can be a denoising model, t i is the most recent step length, t i+1 is the current step length, t i-j is the historical step length, which is equivalent to obtaining t i to t i-s+1 The output of the denoising model with a total of s historical steps.

[0246] It should be understood that model outputs of multiple historical steps defined in other ways can also be obtained, for example, the most recent 1, 3, 5, 7, or randomly selected, and this application is not limited thereto.

[0247] In a possible implementation, the random noise is Gaussian random noise.

[0248] In one possible implementation, the denoised image of the nearest step size can also be obtained (e.g., ).

[0249] It should be understood that the denoised image of the latest step may be the denoised image of the latest step obtained in a manner similar to step 502 in the subsequent embodiments, rather than the output of the denoising model.

[0250] 502. Fusing the multiple first images with the random noise to obtain a denoised image of the current step length;

[0251] In one possible implementation, a first weight corresponding to each historical step may be determined, each first weight being related to a value obtained by mapping the historical step using a target mapping method. The target mapping method is used to determine the magnitude of randomness of each step, and the multiple first images and the random noise are fused based on the first weight. In other words, the multiple first images are fused using each first weight as the weight of the corresponding first image.

[0252] For example, b in the above formula i-j It can be the first weight.

[0253] In one possible implementation, each of the first weights is obtained by applying a random Adams method to a value obtained by mapping the historical step lengths using the target mapping method. The random Adams method can overcome the problems of low efficiency and slow convergence of the numerical format used in the prior art.

[0254] Specifically, a target mapping method (e.g., a variance control function τ(t)) can be given. τ(t) can determine the magnitude of randomness in the sampling process. For example, the variance control function τ(t) can be a piecewise constant function.

[0255] The embodiment of the present application applies the variance control function τ(t), which can better control the randomness in the sampling process. Compared with the deterministic sampling method, it introduces randomness to improve the sampling quality. Compared with the existing random sampling method, it makes the randomness in the sampling process controllable.

[0256] The corresponding value (i.e., analytical variance) can be calculated for the first image of each historical step according to the target mapping method. For example, the analytical variance can be calculated using the following formula:

[0257] The above formula can be used to express the analytical variance from time step t i+1 To time step t i The amount of randomness required in the process.

[0258] The first weight can be determined by calculating the corresponding value of the first image of each historical step according to the target mapping method. For example, the first weight can be calculated by using the random Adams method to calculate the corresponding value of the first image of each historical step according to the target mapping method. For example, the first weight can be calculated according to the following formula:

[0259] In one possible implementation, a second weight corresponding to the random noise can also be determined, and the second weight is related to the numerical value obtained by mapping the historical step through a target mapping method. The target mapping method is used to determine the size of the randomness of each step, and according to the second weight, the multiple first images and the random noise are fused.

[0260] For example, the second weight may be obtained by using the calculation method of the analytical variance in the above formula.

[0261] In a possible implementation, in addition to fusing the multiple first images and the random noise, a denoised image obtained with the most recent step size may also be fused.

[0262] Referring to the above fusion formula, It can be the denoised image obtained by the most recent step length. When calculating the denoised image obtained by the most recent step length, it can be determined similarly by the fusion result of images obtained by multiple historical step lengths and random noise, which is not limited in this application.

[0263] In a possible implementation, a third weight corresponding to the denoised image obtained by the most recent step can also be determined, where the third weight is related to a value obtained by mapping the most recent step through a target mapping method, and the target mapping method is used to determine the magnitude of the randomness of each step; based on the third weight, the denoised image obtained by the most recent step, the multiple first images and the random noise are fused.

[0264] For example, the third weight can be determined by the following formula:

[0265] In an embodiment of the present application, a linear combination of the model outputs of the previous steps, a linear scaling of the previous state and a Gaussian noise with analytic variance are used to obtain the next state (that is, the denoised image of the current step).

[0266] In one possible implementation, the result obtained by fusing the multiple first images and the random noise can be used as the initial value of the denoised image of the current step length, the initial value is processed by the denoising module in the diffusion model to obtain a processing result, and the processing result, the multiple first images and the random noise are fused to obtain the denoised image of the current step length.

[0267] This is equivalent to correcting the result obtained by fusing the multiple first images with the random noise, thereby improving the prediction accuracy and reducing the number of sampling times. By introducing the prediction correction method, the sampling error is reduced while maintaining the same computational cost.

[0268] When performing correction, a fourth weight corresponding to the processing result can be determined. The fourth weight is related to the numerical value obtained by mapping the current step length through the target mapping method. The target mapping method is used to determine the size of the randomness of each step length, and according to the fourth weight, the processing result, the multiple first images and the random noise are fused.

[0269] It should be understood that, when performing fusion, the weights corresponding to the plurality of first images may be different from the above-mentioned first weights (because the number of steps has changed at this time).

[0270] For example, the result obtained by fusing the multiple first images and the random noise can be As the initial value of the denoised image for the current step size And calculate the model x θ exist The output of the predicted value Calculate the coefficient of SA-Corrector:

[0271] Then calculate Correction value:

[0272] In this embodiment of the present application, the above steps can be repeated until the The algorithm ends and outputs

[0273] 9A , the SA-Solver architecture of the present embodiment may include two modules, namely SA-predictor and SA-Corrector. This embodiment demonstrates sampling using the present embodiment from a pre-trained diffusion model, with the core process shown in FIG9A .

[0274] Next, the beneficial effects of the embodiments of the present application are described in conjunction with experiments:

[0275] 9B and Table 1, which show the technical effects of the SA-Solver architecture of an embodiment of the present application on sampling on Latent LDM ImageNet 256x256.

[0276] Table 1

[0277] FID is an important metric for measuring generative model performance; lower FID indicates higher quality of the generated images. As shown in Figure 9B and Table 1, the FID of the present embodiment outperforms the baseline method at various synchronization levels on the ImageNet 256x256 dataset, demonstrating the beneficial technical effects of the present embodiment.

[0278] Refer to Table 2, which shows a comparison between the application of the embodiment of the present application to the currently optimal pre-training model and the baseline method.

[0279] Table 2

[0280] As shown in Table 2, when applied to a state-of-the-art pre-trained model, the present embodiment achieved lower FID values ​​while accelerating the sampling time by 2.5x-4x. The state-of-the-art FID results for the diffusion model were achieved on ImageNet 512x512. This demonstrates the beneficial technical effects of the present embodiment.

[0281] 10 , which is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. As shown in FIG10 , a data processing device provided in an embodiment of the present application, the device 1000 includes:

[0282] An acquisition module 1001 is configured to acquire a plurality of first images and random noises; the different first images are denoised images predicted by the denoising module in the diffusion model at different historical step lengths;

[0283] For a detailed description of the acquisition module 1001 , reference may be made to the description of step 501 in the above embodiment, which will not be repeated here.

[0284] The processing module 1002 is used to fuse the multiple first images and the random noise to obtain a denoised image of a current step size.

[0285] For a detailed description of the processing module 1002 , reference may be made to the description of step 502 in the above embodiment, which will not be repeated here.

[0286] In a possible implementation, the processing module 1002 is further configured to:

[0287] Determining a first weight corresponding to each of the historical steps, each of the first weights is related to a value obtained by mapping the historical steps using a target mapping method, wherein the target mapping method is used to determine the magnitude of randomness of each step;

[0288] The multiple first images and the random noise are fused according to the first weight.

[0289] In a possible implementation, the processing module 1002 is further configured to:

[0290] Determining a first weight corresponding to each of the historical steps, each of the first weights is related to a value obtained by mapping the historical steps using a target mapping method, wherein the target mapping method is used to determine the magnitude of randomness of each step;

[0291] The processing module 1002 is specifically configured to:

[0292] The multiple first images and the random noise are fused according to the multiple first weights.

[0293] In a possible implementation, each of the first weights is specifically obtained by performing a random Adams method on a value obtained by mapping the historical step length using the target mapping method.

[0294] In a possible implementation, the processing module 1002 is further configured to:

[0295] Determining a second weight corresponding to the random noise, the second weight being related to a value obtained by mapping the historical step lengths using a target mapping method, the target mapping method being used to determine a magnitude of randomness of each step length;

[0296] The processing module 1002 is specifically configured to:

[0297] The multiple first images and the random noise are fused according to the second weight.

[0298] In a possible implementation, the processing module 1002 is specifically configured to:

[0299] The denoised image obtained by the most recent step size, the multiple first images and the random noise are fused.

[0300] In a possible implementation, the processing module 1002 is further configured to:

[0301] Determining a third weight corresponding to the denoised image obtained by the most recent step, the third weight being related to a value obtained by mapping the most recent step using a target mapping method, the target mapping method being used to determine a magnitude of randomness of each step;

[0302] The processing module 1002 is specifically configured to:

[0303] The denoised image obtained by the most recent step size, the multiple first images and the random noise are fused according to the third weight.

[0304] In a possible implementation, the target mapping method is a constant piecewise function.

[0305] In a possible implementation, the random noise is Gaussian random noise.

[0306] In a possible implementation, the processing module 1002 is specifically configured to:

[0307] Fusing the multiple first images with the random noise to obtain an initial value of a denoised image of a current step size;

[0308] Processing the initial value by a denoising module in the diffusion model to obtain a processing result;

[0309] The processing result, the multiple first images and the random noise are fused to obtain a denoised image of the current step size.

[0310] In a possible implementation, the processing module 1002 is further configured to:

[0311] determining a fourth weight corresponding to the processing result, the fourth weight being related to a value obtained by mapping the current step length through a target mapping method, the target mapping method being used to determine a magnitude of randomness of each step length;

[0312] The processing module 1002 is specifically configured to:

[0313] The processing result, the multiple first images and the random noise are fused according to the fourth weight.

[0314] Next, a terminal device provided in an embodiment of the present application is introduced. Please refer to Figure 11. Figure 11 is a structural diagram of a terminal device provided in an embodiment of the present application. The terminal device 1100 can be specifically manifested as a virtual reality VR device, a mobile phone, a tablet, a laptop computer, a smart wearable device, etc., which is not limited here. Specifically, the terminal device 1100 includes: a receiver 1101, a transmitter 1102, a processor 1103 and a memory 1104 (wherein the number of processors 1103 in the terminal device 1100 can be one or more, and Figure 11 takes one processor as an example), wherein the processor 1103 may include an application processor 11031 and a communication processor 11032. In some embodiments of the present application, the receiver 1101, the transmitter 1102, the processor 1103 and the memory 1104 may be connected via a bus or other means.

[0315] The memory 1104 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1103. A portion of the memory 1104 may also include non-volatile random access memory (NVRAM). The memory 1104 stores processor and operation instructions, executable modules, or data structures, or subsets or extended sets thereof. The operation instructions may include various operation instructions for implementing various operations.

[0316] Processor 1103 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together via a bus system. In addition to a data bus, the bus system may also include a power bus, a control bus, and a status signal bus. However, for clarity, all bus systems are referred to as a bus system in the figure.

[0317] The methods disclosed in the above embodiments of the present application can be applied to or implemented by processor 1103. Processor 1103 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in processor 1103. The above processor 1103 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and can further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 1103 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present application can be directly implemented as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 1104. Processor 1103 reads information from memory 1104 and, in conjunction with its hardware, completes the steps involved in the model training or model inference process in the above method.

[0318] Receiver 1101 can be used to receive input digital or character information and generate signal input related to executing device-related settings and function control. Transmitter 1102 can be used to output digital or character information through the first interface. Transmitter 1102 can also be used to send instructions to the disk pack through the first interface to modify data in the disk pack. Transmitter 1102 can also include a display device such as a display screen.

[0319] The embodiment of the present application also provides a server. Please refer to Figure 12. Figure 12 is a schematic diagram of the structure of the server provided in the embodiment of the present application. The server 1200 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 1212 (for example, one or more processors) and a memory 1232, and one or more storage media 1230 (for example, one or more mass storage devices) for storing application programs 1242 or data 1244. Among them, the memory 1232 and the storage medium 1230 can be temporary storage or permanent storage. The program stored in the storage medium 1230 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 1212 can be configured to communicate with the storage medium 1230 to execute a series of instruction operations in the storage medium 1230 on the server 1200.

[0320] The server 1200 may also include one or more power supplies 1226, one or more wired or wireless network interfaces 1250, one or more input and output interfaces 1258; or one or more operating systems 1241, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0321] In an embodiment of the present application, the central processing unit 1212 is used to execute actions related to model training or model reasoning in the above embodiments.

[0322] An embodiment of the present application also provides a computer program product, which, when running on a computer, enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.

[0323] A computer-readable storage medium is also provided in an embodiment of the present application, which stores a program for signal processing. When the computer-readable storage medium is run on a computer, it enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.

[0324] The execution device, training device or terminal device provided in the embodiments of the present application can specifically be a chip, and the chip includes: a processing unit and a communication unit, the processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, a pin or a circuit, etc. The processing unit can execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.

[0325] Specifically, see Figure 13 , which is a schematic diagram of the structure of a chip provided in an embodiment of the present application. The chip may be a neural network processor (NPU) 1300. NPU 1300 is mounted on a host CPU (host CPU) as a coprocessor, with tasks assigned by the host CPU. The core of the NPU is arithmetic circuit 1303, which is controlled by controller 1304 to extract matrix data from memory and perform multiplication operations.

[0326] In some implementations, the arithmetic circuit 1303 includes multiple processing units (PEs). In some implementations, the arithmetic circuit 1303 is a two-dimensional systolic array. The arithmetic circuit 1303 can also be a one-dimensional systolic array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1303 is a general-purpose matrix processor.

[0327] For example, assume there are input matrix A, weight matrix B, and output matrix C. The computation circuit retrieves the corresponding data of matrix B from weight memory 1302 and caches it on each PE in the computation circuit. The computation circuit then retrieves the data of matrix A from input memory 1301 and performs a matrix operation on it with matrix B. The partial or final matrix result is stored in accumulator 1308.

[0328] Unified memory 1306 is used to store input and output data. Weight data is directly transferred to weight memory 1302 through the Direct Memory Access Controller (DMAC) 1305. Input data is also transferred to unified memory 1306 through the DMAC.

[0329] BIU stands for Bus Interface Unit 1310 , which is used for interaction between the AXI bus, DMAC, and instruction fetch buffer (IFB) 1309 .

[0330] The bus interface unit 1310 (BIU) is used for the instruction fetch memory 1309 to obtain instructions from the external memory, and is also used for the storage unit access controller 1305 to obtain the original data of the input matrix A or the weight matrix B from the external memory.

[0331] DMAC is mainly used to move input data in the external memory DDR to the unified memory 1306 or to move weight data to the weight memory 1302 or to move input data to the input memory 1301.

[0332] The vector calculation unit 1307 includes multiple operation processing units. When necessary, it further processes the output of the operation circuit 1303, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.

[0333] In some implementations, the vector calculation unit 1307 can store the processed output vector in the unified memory 1306. For example, the vector calculation unit 1307 can apply a linear function or a nonlinear function to the output of the operation circuit 1303, such as linear interpolation of the feature plane extracted by the convolution layer, or accumulate a vector of values ​​to generate an activation value. In some implementations, the vector calculation unit 1307 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1303, for example, for use in subsequent layers in a neural network.

[0334] An instruction fetch buffer 1309 connected to the controller 1304 is used to store instructions used by the controller 1304;

[0335] Unified memory 1306, input memory 1301, weight memory 1302, and instruction fetch memory 1309 are all on-chip memories. External memories are private to the NPU hardware architecture.

[0336] The processor mentioned in any of the above places can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above program.

[0337] It should also be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.

[0338] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.

[0339] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0340] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a training device or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

Claims

1. A data processing method, characterized in that: The method comprises: Acquire multiple first images and random noise; different first images are denoised images predicted by the denoising module in the diffusion model at different historical steps; The multiple first images and the random noise are fused to obtain a denoised image of the current step length.

2. The method according to claim 1, characterized in that The method further comprises: Determine a first weight corresponding to each of the historical steps, each of the first weights being related to a value obtained by mapping the historical steps through a target mapping method, wherein the target mapping method is used to determine the magnitude of randomness of each step; The fusing the plurality of first images and the random noise comprises: The multiple first images and the random noise are fused according to the multiple first weights.

3. The method according to claim 2, characterized in that Each of the first weights is specifically obtained by applying the random Adams method to the numerical value obtained by mapping the historical step length through the target mapping method.

4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Determining a second weight corresponding to the random noise, the second weight being related to a value obtained by mapping the historical step lengths through a target mapping method, the target mapping method being used to determine the magnitude of randomness of each step length; The fusing the plurality of first images and the random noise comprises: The multiple first images and the random noise are fused according to the second weight.

5. The method according to any one of claims 1 to 4, characterized in that: The fusing the plurality of first images and the random noise comprises: The denoised image obtained by the most recent step length, the multiple first images and the random noise are fused.

6. The method according to claim 5, characterized in that The method further comprises: Determine a third weight corresponding to the denoised image obtained by the most recent step, wherein the third weight is related to a value obtained by mapping the most recent step by a target mapping method, wherein the target mapping method is used to determine the magnitude of randomness of each step; The fusing the denoised image obtained by the most recent step length, the plurality of first images and the random noise comprises: The denoised image obtained by the most recent step length, the multiple first images and the random noise are fused according to the third weight.

7. The method according to any one of claims 2 to 6, characterized in that: The target mapping method is a constant piecewise function.

8. The method according to any one of claims 1 to 7, characterized in that: The random noise is Gaussian random noise.

9. The method according to any one of claims 1 to 8, characterized in that: The fusing the multiple first images and the random noise to obtain a denoised image of the current step length includes: Fusing the multiple first images and the random noise to obtain an initial value of a denoised image of a current step length; Processing the initial value by a denoising module in the diffusion model to obtain a processing result; The processing result, the multiple first images and the random noise are fused to obtain a denoised image of the current step length.

10. The method according to claim 9, characterized in that The method further comprises: Determining a fourth weight corresponding to the processing result, the fourth weight being related to a value obtained by mapping the current step length through a target mapping method, the target mapping method being used to determine a magnitude of randomness of each step length; The fusing the processing result, the plurality of first images and the random noise comprises: The processing result, the multiple first images and the random noise are fused according to the fourth weight.

11. A data processing device, characterized in that: The device comprises: An acquisition module, used for acquiring a plurality of first images and random noises; different first images are denoised images predicted by the denoising module in the diffusion model at different historical steps; The processing module is used to fuse the multiple first images and the random noise to obtain a denoised image of the current step length.

12. The device according to claim 11, characterized in that The processing module is further used for: Determine a first weight corresponding to each of the historical steps, each of the first weights being related to a value obtained by mapping the historical steps through a target mapping method, wherein the target mapping method is used to determine the magnitude of randomness of each step; The processing module is specifically used for: The multiple first images and the random noise are fused according to the multiple first weights.

13. The device according to claim 12, characterized in that Each of the first weights is specifically obtained by applying the random Adams method to the numerical value obtained by mapping the historical step length through the target mapping method.

14. The device according to any one of claims 11 to 13, characterized in that: The processing module is further used for: Determining a second weight corresponding to the random noise, the second weight being related to a value obtained by mapping the historical step lengths through a target mapping method, the target mapping method being used to determine the magnitude of randomness of each step length; The processing module is specifically used for: The multiple first images and the random noise are fused according to the second weight.

15. The device according to any one of claims 11 to 14, characterized in that: The processing module is specifically used for: The denoised image obtained by the most recent step length, the multiple first images and the random noise are fused.

16. The device according to claim 15, characterized in that The processing module is further used for: Determine a third weight corresponding to the denoised image obtained by the most recent step, wherein the third weight is related to a value obtained by mapping the most recent step by a target mapping method, wherein the target mapping method is used to determine the magnitude of randomness of each step; The processing module is specifically used for: The denoised image obtained by the most recent step length, the multiple first images and the random noise are fused according to the third weight.

17. The device according to any one of claims 12 to 16, characterized in that The target mapping method is a constant piecewise function.

18. The device according to any one of claims 11 to 17, characterized in that The random noise is Gaussian random noise.

19. The device according to any one of claims 11 to 18, characterized in that The processing module is specifically used for: Fusing the multiple first images and the random noise to obtain an initial value of a denoised image of a current step length; Processing the initial value by a denoising module in the diffusion model to obtain a processing result; The processing result, the multiple first images and the random noise are fused to obtain a denoised image of the current step length.

20. The device according to claim 19, characterized in that The processing module is further used for: Determining a fourth weight corresponding to the processing result, the fourth weight being related to a value obtained by mapping the current step length through a target mapping method, the target mapping method being used to determine a magnitude of randomness of each step length; The processing module is specifically used for: The processing result, the multiple first images and the random noise are fused according to the fourth weight.

21. A computer storage medium, characterized in that The computer storage medium stores one or more instructions which, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 10.

22. A computer program product, characterized in that The method comprises computer-readable instructions, and when the computer-readable instructions are executed on a computer device, the computer device is caused to execute the method according to any one of claims 1 to 10.

23. A system comprising at least one processor and at least one memory; the processor and the memory are connected via a communication bus and communicate with each other; The at least one memory is used to store code; The at least one processor is configured to execute the code to perform the method according to any one of claims 1 to 10.

24. A chip, comprising a processor, characterized in that: The processor is used to support a data processing device to implement the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Data processing method and device

    CN117173035A

  • IMU data denoising method based on recurrent neural network

    CN110728357A

  • Signal processing method and device and electronic equipment

    CN114997233A

  • Image processing method and related device

    CN116258651A

  • Image denoising method and apparatus

    US20210398252A1

Cited By

  • Video deblurring method based on memory diffusion network

    CN120147182A

  • Gradient noise-based dynamic condition diffusion model time series data anomaly detection method and device

    CN120632740A

  • Image generation method and apparatus, medium, electronic device, and program product

    WO2026194456A1