Methods for Visualizing and Analyzing the Image Generation Process of a Latent Diffusion Model, Computing Device, and Computer-Readable Medium thereof
The method of generating and visualizing attention maps from LDMs addresses the lack of analysis in image-to-image LDMs, enhancing model interpretability and performance, particularly in computer vision and medical imaging.
Patent Information
- Application Number
- KR1020240127170
- Authority / Receiving Office
- KR · KR
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2026-11-11
- Estimated Expiration
- 2044-09-20
AI Technical Summary
Existing technologies lack effective methods to analyze and visualize the image-to-image latent diffusion model (LDM) generation process, which is crucial for understanding the model's internal operations and improving its performance and explainability.
A method involving generating a generated image from a reference image using LDM, extracting pre-attention outputs, calculating attention scores, integrating them to create attention maps, applying thresholds, and visualizing the maps as heatmaps to understand the model's focus during image generation.
Enhances the interpretability of LDM, enabling clearer understanding of its internal operations and improving its performance, applicable in fields like computer vision, robotics, and medical imaging.
Smart Images

Figure 112024102561735-PAT00013_ABST
Abstract
Description
Technology Field
[0001] The present invention relates to a technology for visualizing and analyzing the image generation process of an image-to-image latent diffusion model (LDM). Background Technology
[0003] The prior art related to the present invention mainly concerns the development of generative models and the interpretation of image generation processes. Specifically, the following technologies exist.
[0004] Generative Adversarial Networks (GANs) and Variational Autoencoders (VAEs) have been used as representative generative models. These models have achieved significant success in generating various types of data, such as images, speech, and text. However, GANs have limitations, as they can exhibit instability during the training process, while VAEs have limitations, such as the relatively low quality of the generated data.
[0005] Recently, new generative models called diffusion models (e.g., DDPM, DDIM) have emerged to alleviate these limitations. Diffusion models learn high-dimensional data distributions by progressively transforming data, enabling the generation of more stable and high-quality images.
[0006] Building upon the advancements in diffusion models, the Latent Diffusion Model (LDM) emerged as a diffusion model operating in latent space. The Stable Diffusion Model is a representative example of this model. By performing transformations within the data's latent space, LDM enabled more efficient and effective data generation. This allowed for the generation of high-quality results while reducing data complexity and computational costs.
[0007] Since the advent of LDM, notable progress has been made, particularly in text-to-image generation tasks that take text as input and generate images. In this regard, techniques (e.g., prompt-to-prompt, DAAM, etc.) have been introduced to analyze LDM and enable more fine-tuning. These techniques have made it possible to handle the model's output with greater precision, such as controlling specific parts of the generation process or emphasizing desired features.
[0008] Technologies have been developed to analyze the text-to-image LDM generation process and verify how specific text influenced the generated image. This has made it possible to obtain results that reflect more detailed requirements through model debugging.
[0009] However, these conventional technologies have primarily focused on text-to-image generation models, and research on image-to-image LDM has been relatively lacking. Unlike text-to-image LDM, image-to-image LDM takes images as input, resulting in different model characteristics. For example, image-to-image LDM contains spatial information, offering the potential to clearly visualize the bidirectional interaction between the generated image and the input image. Furthermore, because images allow for more explicit information transmission compared to text, they enable more precise control.
[0010] Therefore, there is a need to develop new methods to analyze and visualize the image-to-image LDM generation process. This is expected to further expand the potential of image-to-image LDM and provide practical application possibilities. The problem to be solved
[0012] The technical objective of the present invention is to provide a new algorithm and system for analyzing and visualizing the generation process of an image-to-image latent diffusion model (LDM), thereby enabling a clear understanding of the model's internal operating mechanism, bidirectional visualization of the interaction between the generated image and the input image, and improvement of the model's explainability, ultimately contributing to the performance evaluation and improvement of AI models and the development of AI solutions applicable to real-world scenarios. means of solving the problem
[0014] To solve the above technical problem, the method for visualizing and analyzing the image generation process of an LDM according to the present invention comprises: (a) generating a generated image from a reference image using a Latent Diffusion Model (LDM), which is a diffusion model operating in latent space; (b) extracting a pre-attention output, which is the basis of an attention operation in a cross-attention module within the U-Net structure of the LDM, for each time step, layer, and head; (c) calculating an attention score, which indicates which part of the image the model is focusing on, for each time step, layer, and head using the extracted pre-attention output; (d) selectively integrating the calculated attention scores for each time step, layer, and head to generate an attention map for each of the generated image and the reference image; (e) applying a threshold to the generated attention map and adjusting its size; and (f) visualizing the adjusted attention map in the form of a heatmap.
[0015] Step (d) above generates a time-and-head integrated attention map by integrating attention scores for all time steps and all heads.
[0016] Step (d) above generates a time-integrated attention map by integrating attention scores for all time steps but separating them by head.
[0017] Step (d) above generates a head-integrated attention map by integrating attention scores for all heads but separating them by time step.
[0018] The attention score calculation in step (c) above is, It is calculated using the formula, where Q is the query, K is the key, V is the value, and dk represents the dimension of the key.
[0019] The threshold of step (e) above is, It is calculated based on the formula.
[0020] The present invention further includes the step of generating a specific-reference attention map that visualizes a region of a reference image corresponding to a specific region of a generated image.
[0021] In addition, another embodiment of the present invention discloses a computing device and a recording medium storing a program that implements the method for visualizing and analyzing the image generation process of the LDM of the present invention described above. Effects of the invention
[0023] The present invention visualizes the image generation process of a latent diffusion model (LDM) to enable a clear understanding of the model's internal operations, thereby increasing the interpretability of the model and laying the foundation for performance improvement. Through this, it expands the potential applications of LDM in various fields such as computer vision, robotics, medical imaging, and art, and further enhances the transparency and reliability of artificial intelligence models, thereby contributing to the practical and responsible development of AI technology. Brief explanation of the drawing
[0025] Figure 1 is a flowchart of the image generation process visualization and analysis method of the LDM of the present invention. Figure 2 schematically shows the process of calculating a specific-reference attention map. FIGS. 3 to 6 are results of visualizing an image according to the present invention. FIG. 7 is a block diagram of a computing device implementing the image generation process visualization and analysis method of the LDM of the present invention. Specific details for implementing the invention
[0026] Embodiments of the present invention will be described in detail below with reference to the drawings. However, detailed descriptions of known functions or configurations that may obscure the essence of the present invention in the following description and the attached drawings are omitted. Additionally, throughout the specification, the term 'comprising' a component means that, unless specifically stated otherwise, it does not exclude other components but may include additional components.
[0027] Additionally, terms such as first, second, etc. may be used to describe various components, but said components should not be limited by said terms. said terms may be used for the purpose of distinguishing one component from another component. For example, without departing from the scope of the present invention, the first component may be named the second component, and similarly, the second component may be named the first component.
[0028] The terms used in this invention are used merely to describe specific embodiments and are not intended to limit the invention. The singular expression includes the plural expression unless the context clearly indicates otherwise. In this application, terms such as "comprising" or "comprising" are intended to specify the existence of the described features, numbers, steps, actions, components, parts, or combinations thereof, and should be understood as not precluding the existence or addition of one or more other features, numbers, steps, actions, components, parts, or combinations thereof.
[0029] Unless specifically defined otherwise, all terms used herein, including technical or scientific terms, have the same meaning as generally understood by those skilled in the art to which the present invention pertains. Terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant technology, and should not be interpreted in an ideal or overly formal sense unless explicitly defined in this application.
[0030] The present invention relates to a technology for visualizing and analyzing the image generation process of an image-to-image latent diffusion model (LDM). In particular, the present invention utilizes a cross-attention module within U-Net; specifically, since the LDM generation process is analyzed by visualizing a cross-attention map, LDM and U-Net are described prior to explaining the present invention in detail.
[0031] First, the basic configuration and operating principles of the LDM (Latent Diffusion Model) are as follows.
[0032] LDM consists of three main components: the Variational Autoencoder (VAE), U-Net, and the Scheduler.
[0033] A VAE encodes an input image into a compressed latent space and decodes the generated latent representation back into image space. The VAE's encoder converts high-dimensional image data into a low-dimensional latent representation, while the decoder restores this latent representation to the original image space.
[0034] Second, U-Net performs a noise removal process in the latent space. U-Net has an encoder-decoder structure and includes skip connections between layers to effectively utilize features of various scales. U-Net contains a cross-attention module, enabling it to learn the relationship between input conditions (e.g., text embeddings) and image features in conditional generation tasks.
[0035] Third, the Scheduler controls the noise addition and removal processes. During the training phase, it manages the forward process that gradually adds noise, and during the inference phase, it manages the reverse process that removes noise.
[0036] Next, the operating principle of this LDM is explained as follows.
[0037] 1. Training Phase:
[0038] (a) Map the input image to the latent space using a VAE encoder.
[0039] (b) Perform a forward process that gradually adds noise to the latent representation.
[0040] (c) Train U-Net to predict noise at each noise level.
[0042] 2. Inference Phase:
[0043] (a) Start with random noise and remove noise in the order defined by the Scheduler.
[0044] (b) At each step, U-Net predicts noise and removes it from the current latent representation.
[0045] (c) The finally obtained latent representation is converted into image space through a VAE decoder.
[0046] Through this configuration and operating principle, LDM can efficiently generate high-quality images and, in particular, significantly reduce computational costs due to operations in the latent space.
[0048] The present invention primarily visualizes the following parts of the operation process of the LDM as described above.
[0049] 1. U-Net’s cross-attention module:
[0050] This invention focuses on the cross-attention module within U-Net. In particular, it extracts the pre-attention output and calculates the attention score and attention map based on it.
[0052] 2. Noise Removal Process:
[0053] We visualize the gradual noise removal process that occurs during the inference phase of LDM. This is implemented by generating and integrating attention maps at each time step.
[0055] 3. Relationship between generated image and reference image:
[0056] It visualizes which region of the reference image a specific part of the generated image refers to. This is implemented through a specific-reference attention map.
[0058] 4. Attention Analysis from Various Perspectives:
[0059] - Time-Integrated Map: Visualizes by integrating attention for all time steps.
[0060] - Head-Integrated Map: Visualizes the attention for all attention heads by integrating them.
[0061] - Time-and-Head Integrated Map: Visualizes overall attention by integrating all time and head.
[0063] 5. Inpainting Process:
[0064] In the inpainting task of filling a portion of an image, the attention distribution inside and outside the mask area is visualized, and the IMACS (Inpainting Mask Attention Consistency Score) is calculated based on this.
[0065] Through such visualizations, it is possible to analyze what information LDM prioritizes during the image generation process, which areas it focuses on, and how attention changes over time. This helps to gain a deeper understanding of the model's behavior and improve performance.
[0067] The configuration of U-net is explained below, divided into modules.
[0068] The configuration of U-Net includes an Encoder module, a Decoder module, a Skip connection module, a Bottleneck module, a Cross-attention module, and an Output module, and each module is described as follows.
[0069] The Encoder module is responsible for extracting features from input data and compressing it. This module consists of a series of downsampling blocks.
[0070] The Decoder module is responsible for restoring compressed features to their original spatial dimensions. This module consists of a series of upsampling blocks.
[0071] The Skip connection module connects the output of a specific layer of the encoder to the input of the corresponding decoder layer.
[0072] The Bottleneck module is located between the encoder and the decoder and processes the most compressed feature representation.
[0073] The cross-attention module can be inserted into multiple layers of U-Net and performs the following functions:
[0074] a) Query, key, value transformation: Transforms input features into their respective representations.
[0075] b) Attention score calculation: Calculates the similarity between the query and the key.
[0076] c) Value weighted sum: Weights the values based on the attention score.
[0077] d) Output projection: Transforms the output of the attention mechanism into the desired dimension.
[0078] The Output module converts the decoder's final output into the desired format.
[0079] These modules are organically combined to form the overall structure of U-Net, enabling effective feature extraction and image generation.
[0081] Hereinafter, the method for visualizing and analyzing the image generation process of the LDM of the present invention will be described with reference to FIG. 1. The method for visualizing and analyzing the image generation process of an LDM according to the present invention comprises: (a) generating a generated image from a reference image using a Latent Diffusion Model (LDM), which is a diffusion model operating in latent space (S10); (b) extracting a pre-attention output, which is the basis for attention operations in a cross-attention module within the U-Net structure of the LDM, for each time step, layer, and head (S20); (c) calculating an attention score, which indicates which part of the image the model is focusing on, for each time step, layer, and head using the extracted pre-attention output (S30); (d) selectively integrating the calculated attention scores for each time step, layer, and head to generate an attention map for each of the generated image and the reference image (S40); (e) applying a threshold to the generated attention map and adjusting its size (S50); and (f) visualizing the adjusted attention map in the form of a heatmap. Includes step (S60).
[0082] The following is a detailed explanation of each step.
[0084] (a) Step S10:
[0085] This step (S10) is the process in which the Latent Diffusion Model (LDM) generates a new image based on a reference image, serving as the foundation for subsequent analysis and visualization steps. The generated image and the generation process are analyzed in subsequent steps and used to understand and interpret the model's behavior.
[0086] The operation of this stage is explained as follows.
[0087] LDM encodes a reference image into latent space through a VAE (Variational Autoencoder) encoder and adds random noise to the encoded latent representation.
[0088] Furthermore, LDM performs a denoising process that gradually removes noise from the noise-added latent representation using U-Net and a scheduler; at each time step, it predicts the noise through U-Net, removes the predicted noise from the current latent representation, and proceeds to the next time step according to the scheduler.
[0089] After this denoising process is completed, the LDM can obtain the generated image by decoding the final latent representation into image space through a VAE decoder.
[0091] (b) S20 Step:
[0092] Step (b) is the step of extracting the pre-attention output, which forms the basis of the attention operation in the cross-attention module within the U-Net structure of LDM, for each time step, layer, and head.
[0093] Specifically, LDM is based on the U-Net structure, which includes multiple cross-attention modules. Each cross-attention module processes input data to generate a pre-attention output, which is an intermediate result before performing the attention operation.
[0094] In the present invention, this pre-attention output is extracted in the following three dimensions:
[0095] 1. Time step: LDM gradually generates images over several time steps. At each time step, it extracts a pre-attention output.
[0096] 2. Layer: The U-Net structure consists of multiple layers, and a cross-attention module may exist in each layer. Therefore, pre-attention outputs are extracted from each layer.
[0097] 3. Head: A single cross-attention module can be composed of multiple attention heads. Since each head can focus on different features of the input data, a pre-attention output is extracted for each head.
[0098] The pre-attention output extracted in this way is used to calculate the attention score in the subsequent step, which is utilized to analyze which parts the model is focusing on during the image generation process.
[0100] (c) S30 Step:
[0101] (c) is the step of calculating an attention score for each time step, layer, and head, which indicates which part of the image the model is focusing on, using the extracted pre-attention output.
[0102] Specifically, in this step, the attention score is calculated for each time step t, cross-attention layer l, and attention head n. At this time, the attention score is calculated using the following mathematical formula 1.
[0103]
[0104] Here, Q represents the query, K represents the key, V represents the value, and d k represents the dimension of the key. In the above mathematical formula 1, the softmax function serves to normalize each attention score to a value between 0 and 1.
[0105] The attention score calculated in this step quantifies how much the model pays attention to each part of the image, and this is used to generate an attention map in subsequent steps. By calculating the attention score individually for each time step, layer, and head, it is possible to analyze in detail how the model's attention changes during the image generation process and how the model's various components interact.
[0107] (d) S40 Step:
[0108] (d) Step (d) is a step of generating an attention map for each of the generated image and reference image by optionally integrating the calculated attention scores for the time step, layer, and head, which is performed as follows.
[0109] First, an attention map is generated by applying various integration methods based on the attention scores At,l,n calculated for each time step (t), layer (l), and head (n).
[0110] In the case of time integration, the attention scores are summed over the entire time step (T) as in Equation 2.
[0111]
[0112] In the case of layer integration, the average is calculated for all layers (L) as in Equation 3.
[0113]
[0114] In the case of head integration, the average is calculated for all heads (N) as in mathematical formula 4.
[0115]
[0116] By selectively combining these integration methods, various attention maps can be generated depending on the purpose. For example, the entire attention map integrating all time steps, layers, and heads is calculated as shown in Equation 5.
[0117]
[0118] By generating attention maps for the generated image and the reference image, respectively, in this way, it becomes possible to analyze the areas the model focuses on during the image generation process from various angles.
[0119] In addition, the attention score calculated in this step is applied not only to the generated image but also to the reference image, enabling the model to identify which parts of the reference image it considers important when generating a new image.
[0121] (e) S50 Step:
[0122] Step (e) involves applying a threshold and resizing the generated attention map, a process designed to improve the visualization quality of the attention map and highlight important information.
[0123] First, during the threshold application process, attention scores lower than a predefined threshold are removed. This can be expressed by the following mathematical equation 6.
[0124]
[0125] Here, A_final is the final attention map, and threshold is a predefined threshold value. Through this process, the attention score of areas of relatively low importance is set to 0, allowing for greater focus on important areas.
[0126] Next, during the resizing process, the size of the generated attention map is adjusted to match the size of the original image. This is generally performed using interpolation, and methods such as linear interpolation or bilinear interpolation may be used.
[0127] Through this threshold application and scaling process, the attention map is transformed into a sharper and easier-to-interpret form. This enables a clearer representation of the model's focus area in subsequent visualization steps, ultimately allowing for a more accurate understanding and analysis of the model's behavior.
[0129] (f) S60 Step:
[0130] Step (f) is the step of visualizing the adjusted attention map in the form of a heatmap, and is performed as follows.
[0131] First, the attention map, to which the threshold has been applied and scaled in step (e) above, is received as input. This attention map is in the form of a 2D matrix, where each element represents the attention score at the corresponding location.
[0132] Next, each element of the aforementioned attention map is mapped to a color value. At this time, the intensity of the color is determined according to the magnitude of the attention score. Generally, high attention scores are represented in shades of red, and low attention scores in shades of blue. This color mapping can be performed linearly or non-linearly using a logarithmic scale, etc.
[0133] Next, a 2D heatmap image is generated using the mapped color values. This heatmap has the same size as the original image, and the color of each pixel represents the attention score of that location.
[0134] Finally, the generated heatmap is semi-transparently overlaid on the original image to produce the final visualization result. This allows users to intuitively understand which part of the image the model is focusing on.
[0135] The visualization results generated through this step can contribute to improving model performance and expanding its scope of application by intuitively demonstrating which image features the model focuses on, how attention levels change over time, and how it identifies the relationship between the reference image and the generated image.
[0137] In addition, the present invention may be configured to include a step of additionally generating a specific-reference attention map. This visualizes an area of a reference image corresponding to a specific area of a generated image, thereby further expanding and refining the visualization capabilities of the present invention.
[0138] This is explained in detail with reference to Fig. 2 as follows.
[0139] Specifically, the process of generating a specific-reference attention map is performed as follows.
[0140] First, a specific region within the generated image (e.g., a patch centered at specific coordinates (a, b)) is received from the user. This region is of interest to the user and serves the purpose of determining which part of the reference image the region was generated by referencing it.
[0141] Next, among the attention scores calculated in step (c), only the scores corresponding to the selected specific region are extracted. At this time, the extracted scores represent the attention for each location in the reference image.
[0142] Next, the extracted attention scores are reconstructed to fit the size of the reference image. During this process, normalization or scaling of the scores may be performed as needed.
[0143] Finally, a heatmap is generated over the reference image using the reconstructed attention score. This heatmap visually shows which parts of the reference image the selected area of the generated image primarily referenced.
[0144] This specific-reference attention map enables a more detailed understanding of the model's image generation process. In particular, by clearly showing how the model recognizes and utilizes specific features or structures of a reference image and where in the generated image it applies them, it can be used as an important indicator for evaluating the model's training process and the quality of the output.
[0145] Furthermore, such detailed analysis can directly contribute to improving model performance. For example, if the model references inappropriate parts of a reference image, it can be immediately identified and corrected; conversely, if it accurately captures important features, the model can be optimized to reinforce them.
[0147] Meanwhile, FIG. 3-6 shows the visualization result according to the present invention described above, which is the result of visualization using a publicly available AI model and dataset.
[0148] The dataset used for this, VITON-HD (train: 11,647, test: 2,032), is a dataset of people wearing clothing with a resolution of 1024*768. When used as input to the model, it was downsampled to a size of 512*384.
[0149] The model utilized the latent diffusion models StableVITON and DCI-VTON. It was trained on the VITON-HD dataset described above, and the input and output sizes of the model are 512*384*3. Since the noise addition and removal processes take place in the latent space, the inputs were mapped to the encoders and decoders of the VAE (512*384*3 <-> 64*48*4).
[0150] First, Figure 3 shows the result of the head-integrated attention map according to the present invention, visualizing the generation process by inputting images into StableVITON and DCI-VTON, respectively. The first column shows the result generated by the model and the clothes to be worn on the target person. The second column shows the time-and-head attention map for the generated image, which integrates time and attention head, as well as the image preserving the region to be generated by the model and the remaining region. As the model generates images over time, looking at the head-integrated attention map on the right, it can be seen that the model always pays attention to important areas (e.g., the logo on the clothes). This means that the model analyzed the features of the input data and distinguished whether or not it was an important region.
[0151] Figure 4 shows the result of the time-integrated attention map according to the present invention, visualizing the generation process by inputting images into StableVITON and DCI-VTON, respectively, just like in Figure 3. Unlike before, because time is integrated, it is possible to examine the regions that each attention head considers important. The regions viewed by each attention head are different, and scores are even distributed outside the inpainting mask area. Nevertheless, the region that each head focuses on the most (assigned high attention scores) is consistently the clothing logo. This is interpreted as the model identifying the factors that determine the quality of the image.
[0152] Figures 5 and 6 show the results of visualizing the attention maps for the reference image. As discussed above, Figure 5 displays the time-and-head and time-head integrated attention maps. They largely exhibit the same trends as the generated image. One point to note is the result in the head integrated attention map. High attention scores are consistently assigned to the clothing logo regardless of time. This difference occurs because the generated image is injected with a significant amount of noise in the initial stages, making it difficult for the model to identify important features, whereas the reference image provides consistent information to the model without noise.
[0153] Figure 6 visualizes the specific-reference attention map. When the model generates a patch corresponding to the red box, the red arrow indicates which region of the reference image it is referencing. This visualization method allows one to verify whether the model is effectively extracting information both positionally and semantically. In Figure 6, it can be seen that appropriate information about the clothing is being used when generating each red box.
[0155] FIG. 7 shows a functional block of a computing device that implements the method for visualizing and analyzing the image generation process of the LDM described above. The method described above is implemented as a program for executing commands and mounted on the computing device. When reconfigured into a functional block, the computing device (800) may be configured to include a memory (801) for storing the program and at least one processor (803) configured to perform operations on commands defined in the program, and the commands are programmed as computer-readable code for the method for visualizing and analyzing the image generation process of the LDM.
[0156] For example, the above command includes: (a) generating a generated image from a reference image using a Latent Diffusion Model (LDM), which is a diffusion model operating in latent space; (b) extracting a pre-attention output, which is the basis of an attention operation in a cross-attention module within the U-Net structure of the LDM, for each time step, layer, and head; (c) calculating an attention score for each time step, layer, and head, which indicates which part of the image the model is paying attention to, using the extracted pre-attention output; (d) optionally integrating the calculated attention scores for each time step, layer, and head to generate an attention map for each of the generated image and the reference image; (e) applying a threshold to the generated attention map and adjusting its size; and (f) visualizing the adjusted attention map in the form of a heatmap.
[0158] Meanwhile, the method for displaying an object of interest according to the present invention described above can be implemented as computer-readable code on a computer-readable recording medium. A computer-readable recording medium includes all types of recording devices in which data that can be read by a computer system is stored.
[0159] Examples of computer-readable recording media include ROM, RAM, CD-ROM, magnetic tape, floppy disk, optical data storage device, etc. Additionally, computer-readable recording media may be distributed across networked computer systems, allowing computer-readable code to be stored and executed in a distributed manner. Furthermore, functional programs, codes, and code segments for implementing the present invention can be easily inferred by programmers in the art to which the present invention belongs.
[0160] The present invention has been described above with reference to various embodiments. Those skilled in the art will understand that the present invention may be implemented in modified forms without departing from the essential characteristics of the invention. Therefore, the disclosed embodiments should be considered in an illustrative rather than a restrictive sense. The scope of the invention is defined by the claims, not by the foregoing description, and all variations within the scope of the claims should be interpreted as being included in the invention.
Claims
Claim 1 (a) generating a generated image from a reference image using a Latent Diffusion Model (LDM), which is a diffusion model operating in latent space; (b) extracting a pre-attention output, which is the basis of an attention operation in a cross-attention module within the U-Net structure of the LDM, for each time step, layer, and head; (c) calculating an attention score for each time step, layer, and head, which indicates which part of the image the model is paying attention to, using the extracted pre-attention output; (d) optionally integrating the calculated attention scores for each time step, layer, and head to generate an attention map for each of the generated image and the reference image; (e) applying a threshold to the generated attention map and adjusting its size; and (f) visualizing the adjusted attention map in the form of a heatmap; comprising a method for visualizing and analyzing the image generation process of an LDM. Claim 2 A method for visualizing and analyzing the image generation process of LDM, wherein step (d) generates a time-and-head integrated attention map by integrating attention scores for all time steps and all heads. Claim 3 A method for visualizing and analyzing the image generation process of LDM, wherein step (d) integrates attention scores for all time steps but separates them by head to generate a time-integrated attention map. Claim 4 A method for visualizing and analyzing the image generation process of LDM, wherein step (d) integrates attention scores for all heads but separates them by time step to generate a head-integrated attention map. Claim 5 In claim 1, the attention score calculation of step (c) above is, A method for visualizing and analyzing the image generation process of LDM, calculated using the formula, where Q is query, K is key, V is value, and dk represents the dimension of key. Claim 6 In paragraph 5, the threshold of step (e) above is, A method for visualizing and analyzing the image generation process of LDM calculated based on the formula. Claim 7 A method for visualizing and analyzing the image generation process of an LDM, comprising, in claim 1, the additional step of generating a specific-reference attention map that visualizes a region of a reference image corresponding to a specific region of a generated image. Claim 8 A computing device comprising: a memory for storing a program; and at least one processor configured to compute instructions defined in the program, wherein the instructions include: (a) generating a generated image from a reference image using a Latent Diffusion Model (LDM), which is a diffusion model operating in a latent space; (b) extracting a pre-attention output that serves as the basis for attention computation in a cross-attention module within the U-Net structure of the LDM for each time step, layer, and head; (c) calculating an attention score for each time step, layer, and head that indicates which part of the image the model is paying attention to using the extracted pre-attention output; (d) optionally integrating the calculated attention scores for each time step, layer, and head to generate an attention map for each of the generated image and the reference image; (e) applying a threshold to the generated attention map and adjusting its size; and (f) visualizing the adjusted attention map in the form of a heatmap. Claim 9 In claim 8, the above step (d) is a computing device that generates a time-and-head integrated attention map by integrating attention scores for all time steps and all heads. Claim 10 In claim 8, the above step (d) is a computing device that generates a time-integrated attention map by integrating attention scores for all time steps and separating them by each head. Claim 11 In claim 8, the above step (d) is a computing device that integrates attention scores for all heads, but separates them by time step to generate a head-integrated attention map. Claim 12 In paragraph 8, the attention score calculation of step (c) above is, It is calculated using the formula, where Q is the query, K is the key, V is the value, and dk represents the dimension of the key, arithmetic unit. Claim 13 In Clause 12, the threshold of step (e) above is, A computational unit calculated based on the formula. Claim 14 In claim 8, the above command further comprises the step of generating a specific-reference attention map that visualizes a region of a reference image corresponding to a specific region of a generated image, a computing device. Claim 15 A recording medium storing a computer-readable program coded for the method of visualizing and analyzing the image generation process of an LDM as described in any one of claims 1 to 7 above.
Citation Information
Patent Citations
Model training method, semantic segmentation method, and model training method
JP2024116098A
Pruning method and system for efficient compression of generative artificial intelligence model
KR102663160B1
