{
  "source_file": "0930",
  "source_platform": "技术平台",
  "author": "Satya Mallick / LearnOpenCV",
  "title_listed": "Stable Diffusion: Text-to-Image",
  "keywords": "Stable Diffusion,文生图,生成",
  "domain": "图像处理",
  "content_type": "教程",
  "is_paid_flag": "否",
  "url": "https://learnopencv.com/stable-diffusion/",
  "publish_date": "2022-10",
  "corpus_stage": "预训练/SFT",
  "notes": "Stable Diffusion文生图",
  "id": "15a979e6487d",
  "collected_at": "2026-10-02T17:38:04",
  "title": "Stable Diffusion 3.5: Architecture and Inference",
  "body_markdown": "We use essential cookies to make our site work. With your consent, we may also use non-essential cookies to improve user experience and analyze website traffic. By clicking “Accept,” you agree to our website's cookie use as described in our Cookie Policy. You can change your cookie settings at any time by clicking “Preferences.” \nAccept\n[ ![](../images/000.png) ](https://learnopencv.com)\n  * [Getting Started](https://learnopencv.com/category/install/)\n    * [Subscribe](https://learnopencv.com/)\n    * [Installation](https://learnopencv.com/category/install/)\n    * [Getting Started with OpenCV](https://learnopencv.com/getting-started-with-opencv/)\n    * [PyTorch](https://learnopencv.com/getting-started-with-pytorch/)\n    * [Tensorflow & Keras](https://learnopencv.com/getting-started-with-tensorflow-keras/)\n  * [Free Courses](https://opencv.org/university/free-courses/?utm_source=lopcv&utm_medium=menu&utm_campaign=fcpage)\n    * [VLM Bootcamp](https://opencv.org/university/vision-language-model-bootcamp/?utm_source=lopcv&utm_medium=menu&utm_campaign=vlm)\n    * [PyTorch Bootcamp](https://opencv.org/university/free-pytorch-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=ptbc)\n    * [TensorFlow Keras Course](https://opencv.org/university/free-tensorflow-keras-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=tbc)\n    * [OpenCV Course](https://opencv.org/university/free-opencv-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=obc)\n    * [Python for Beginners](https://opencv.org/university/python-for-beginners/?utm_source=lopcv&utm_medium=menu&utm_campaign=pbc)\n  * [AI Consulting](https://bigvision.ai/expert-ai-solution-builders/#talk?utm_source=locv&utm_medium=menu)\n  * [About](https://learnopencv.com/about/)\n\n\n  * [Getting Started](https://learnopencv.com/category/install/)\n    * [Subscribe](https://learnopencv.com/)\n    * [Installation](https://learnopencv.com/category/install/)\n    * [Getting Started with OpenCV](https://learnopencv.com/getting-started-with-opencv/)\n    * [PyTorch](https://learnopencv.com/getting-started-with-pytorch/)\n    * [Tensorflow & Keras](https://learnopencv.com/getting-started-with-tensorflow-keras/)\n  * [Free Courses](https://opencv.org/university/free-courses/?utm_source=lopcv&utm_medium=menu&utm_campaign=fcpage)\n    * [VLM Bootcamp](https://opencv.org/university/vision-language-model-bootcamp/?utm_source=lopcv&utm_medium=menu&utm_campaign=vlm)\n    * [PyTorch Bootcamp](https://opencv.org/university/free-pytorch-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=ptbc)\n    * [TensorFlow Keras Course](https://opencv.org/university/free-tensorflow-keras-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=tbc)\n    * [OpenCV Course](https://opencv.org/university/free-opencv-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=obc)\n    * [Python for Beginners](https://opencv.org/university/python-for-beginners/?utm_source=lopcv&utm_medium=menu&utm_campaign=pbc)\n  * [AI Consulting](https://bigvision.ai/expert-ai-solution-builders/#talk?utm_source=locv&utm_medium=menu)\n  * [About](https://learnopencv.com/about/)\n\n\nSearch ...\nResults\nSee all results\n  * [Home](https://learnopencv.com \"Home\")\n  * >\n  * [AI Art Generation](https://learnopencv.com/category/ai-art-generation/ \"AI Art Generation\")\n  * >\n  * Stable Diffusion 3.5: Paper Explanation and Inference\n\n\n[Bhomik Sharma](https://learnopencv.com/author/bhomik/)\n  * on  November 19, 2024\n\n\n# Stable Diffusion 3.5: Paper Explanation and Inference\nStable Diffusion 3.5, released on June 2024 by Stability AI, is the third iteration in the Stable Diffusion family. The Turbo-Large and Large variants of the SD3.5 family are Stability AI’s most advanced text-to-image open-source models yet. Stability AI has recently collaborated with ARM to produce on-device generative audio in\n  * [AI Art Generation](https://learnopencv.com/category/ai-art-generation/), [Diffusion Models](https://learnopencv.com/category/diffusion-models/), [Generative AI](https://learnopencv.com/category/generative-ai/), [Hugging Face Transformers](https://learnopencv.com/category/hugging-face-transformers/)\n\n\n![](../images/007.gif)\n  *   *   * [ ](https://bigvision.ai/expert-ai-solution-builders?utm_source=lopcv&utm_medium=post-icon)\n\n\n**Stable Diffusion 3.5** , released on June 2024 by Stability AI, is the third iteration in the Stable Diffusion family. The **Turbo-Large** and**Large** variants of the SD3.5 family are Stability AI’s most advanced text-to-image open-source models yet. [Stability AI ](https://stability.ai/news/stability-ai-and-arm-bring-on-device-generative-audio-to-smartphones \"Stability AI \")has recently collaborated with ARM to produce on-device generative audio in smartphones.\nThese models are based on the fundamental concept of latent diffusion(even used in [text-to-video diffusion](https://learnopencv.com/video-generation-models/ \"text-to-video diffusion\") models), which we will cover later in this article before getting acquainted with the concepts of SD3.5.\n![](../images/007.gif)\nThis article provides an intuitive understanding of how Stable Diffusion 3.5 works. We have provided an Inference script of the Stable Diffusion 3.5 Large Turbo model at the end of this article. Before proceeding any further, let’s take a moment to understand Diffusion Models.\n  1. [Defining Diffusion (and Variants) and the Reason for this Nomenclature](https://learnopencv.com/stable-diffusion-3/#aioseo-defining-diffusion-and-variants-and-the-reason-for-this-nomenclature \"Defining Diffusion \\(and Variants\\) and the Reason for this Nomenclature\")\n    1. [Latent Diffusion](https://learnopencv.com/stable-diffusion-3/#aioseo-latent-diffusion \"Latent Diffusion\")\n  2. [Stable Diffusion](https://learnopencv.com/stable-diffusion-3/#aioseo-stable-diffusion \"Stable Diffusion\")\n    1. [Flow Matching for Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-flow-matching \"Flow Matching for Stable Diffusion 3.5\")\n    2. [Timestamp Sampling used in Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-timestamp-sampling \"Timestamp Sampling used in Stable Diffusion 3.5\")\n    3. [The Architecture of Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-architecture \"The Architecture of Stable Diffusion 3.5\")\n      1. [Textual Embedding](https://learnopencv.com/stable-diffusion-3/#aioseo-textual-embedding \"Textual Embedding\")\n      2. [Patchify](https://learnopencv.com/stable-diffusion-3/#aioseo-patchify \"Patchify\")\n      3. [DiT Backbone](https://learnopencv.com/stable-diffusion-3/#aioseo-dit-backbone \"DiT Backbone\")\n  3. [Inference with Stable Diffusion 3.5 Large Turbo, Large and Medium](https://learnopencv.com/stable-diffusion-3/#aioseo-inference-with-sd-3-5-large-turbo-large-medium \"Inference with SD3.5 Large Turbo, Large and Medium\")\n  4. [Comparison of Stable Diffusion 3.5 Large Turbo and Flux Schnell](https://learnopencv.com/stable-diffusion-3/#aioseo-comparison-of-sd3-5-large-turbo-with-flux-schnell \"Comparison of SD3.5 Large Turbo with Flux Schnell\")\n  5. [Conclusion](https://learnopencv.com/stable-diffusion-3/#aioseo-conclusion \"Conclusion\")\n  6. [References](https://learnopencv.com/stable-diffusion-3/#aioseo-references \"References\")\n\n\n# What is diffusion, and how does it work?\n[![Diffusion Space, Image Manifold Space and Denoised Interpolation](../images/008.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/diffusion_variablesample_space.png)_Fig 1: Diffusion Process Space_\nDiffusion in classical mechanics refers to the transfer of particles—or any tangible quantity—from an area of high concentration to an area of low concentration. Inspired by this concept, the authors of [Denoising Diffusion Probabilistic Models (DDPM)](https://learnopencv.com/denoising-diffusion-probabilistic-models/ \"Denoising Diffusion Probabilistic Models \\(DDPM\\)\") introduce noise into a target image (which has very low noise) to align it with the noise data distribution. This process is known as **Forward Diffusion** , as described by the original authors of the diffusion paper. Conversely, the process is called Reverse Diffusion when the target data distribution is derived from this noisy image.\n[![Diffusion Process describing Forward and Reverse Process](../images/013.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/simple_diffusion_process.png)_Fig 2: Simple Diffusion Process_\nThe image above shows how the forward and reverse [diffusion](https://learnopencv.com/ai-art-generation-tools/ \"diffusion\") process works by representing it in probabilistic notations. However, these notations represent the data distributions at each timestamp. As we observe, the image becomes progressively noisier when we follow the path of ![q\\(X_t \\\\mid X_{t-1}\\)](../images/019.png). This indicates that noise is gradually diffusing into the target distribution. Essentially, our neural network will learn the noise distribution between two timestamps during the reverse diffusion process by regressing the mean and variance of the latter.\nIt is not always necessary to regress both central tendencies; we can instead focus solely on regressing the noise by simplifying the diffusion loss function.\nLet’s take a look at how the authors have defined the **algorithm for Denoising Diffusion Probabilistic Models (DDPM)** :\n[![Denoising Diffusion Probabilitic Model Algorithm for Training and Sampling](../images/020.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083624/simple_diffusion_algorithm.png)_Fig 3: Simple Diffusion Algorithm_\nWhere,\n![\\\\\\[\\\\begin{aligned}\\\\\\\\epsilon \\\\rightarrow \\\\text{Actual Noise} \\\\\\\\\\\\epsilon_{\\\\theta} \\\\rightarrow \\\\text{Predicted Noise} \\\\\\\\\\\\mathcal{N}\\(0, \\\\mathbf{I}\\) \\\\rightarrow \\\\text{Standard Normal Distribution} \\\\\\\\\\\\alpha_t \\\\rightarrow 1 - \\\\beta_t \\\\quad \\\\text{\\(Variance Schedule or Scaling Factor\\)} \\\\\\\\\\\\mathbf{z} \\\\rightarrow \\\\text{Vector from } \\\\mathcal{N}\\(0, \\\\mathbf{I}\\) \\\\\\\\\\\\nabla_{\\\\theta} \\\\rightarrow \\\\text{Divergence} \\\\\\\\\\\\mathbf{x}_0, \\\\mathbf{x}_T \\\\rightarrow \\\\text{Samples at time } t = 0 \\\\text{ and } t = 1\\\\end{aligned}\\]](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-609cc13a94fc1c151bf9c87b93fa0117_l3.png)\nAs mentioned, we can see that the model is trying to regress epsilon (parameterized by ![\\\\theta](../images/028.png)) by getting as close to the original noise as possible.\nNow that we know the algorithm guiding the diffusion process, we can move to understanding **Latent Diffusion Models(LDM).**\n## Latent Diffusion\nCompared to Vanilla Diffusion, Latent Diffusion incorporates one key change that makes it more applicable to real-life scenarios. This idea is derived from the models used in Variational Autoencoders (VAEs).\nThe latent variable ‘Z’ is a low-dimensional representation of the original data. This representation is beneficial for generation, as it captures the essential attributes of the data without any extraneous information. This vector encapsulates everything needed to reconstruct the original distribution using VAEs.\nWhen generating our target distribution from noise, we utilize a significant amount of resources; in fact, diffusion (considering both forward and reverse diffusion processes) is **resource-intensive**. To address this issue, we can apply the **concept of latent spaces** from Variational Autoencoders (VAEs).\nFirstly, a VAE encodes the target data into a latent space, resulting in a less complex, lower-dimensional representation than the original target distribution. Consequently, applying a diffusion framework or model to this latent vector makes the reverse process more efficient and faster.\nNow, let’s take a look at the architecture of latent diffusion models:\n[![Latent Diffusion Model Architecture](../images/029.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083623/ldm_architecture-1.png)_Fig 4: LDM Architecture_\nThe authors of the DDPM paper employed a **U-Net architecture as a neural network** for the diffusion process, which has since become a standard for diffusion neural networks. This architecture offers several advantages for our purposes, including multi-scale feature extraction, versatility with conditional inputs, and efficient memory and computational usage.\nAs we can see in the image, a section named Conditioning. It refers to the process in which the generation of sample images adheres to the instructions provided in the condition itself, or you can say the **prompt provided by the user** , rather than just being a random prediction from the diffusion model. This conditioning can take various forms, such as semantic maps, text, or images.\nWith a foundational understanding of diffusion and latent diffusion models, it’s time to introduce Stable Diffusion.\n# Stable Diffusion 3.5\nBefore understanding [Stable Diffusion](https://learnopencv.com/stable-diffusion-generative-ai/ \"Stable Diffusion\"), we must know what flow matching means.\n[![Ordinary Differential Equation Solver for Stable Diffusion 3. Flow of ODE.](../images/034.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_image_ode_traversal.png)_Fig 5: ODE paths for SD3_\n## Flow Matching for Stable Diffusion 3.5\nThe dotted lines shown in the figure above represent what is known as _“flow_.” This concept describes how a sample point from the latent space distribution transforms into a component of the target distribution. This may seem a bit ambiguous and difficult to grasp at first, but by the end of this section, a clear understanding of how flow matching works and its relation to Stable Diffusion will be established.\nSpecifically, the paper’s authors introduced flow matching as a simple and intuitive training objective aimed at regressing onto a target vector field that produces a desired probability path. A probability path refers to the route that a particular distribution (in our case, the noise distribution) takes to achieve the state of another distribution. Assuming intermediate knowledge of matrices and determinants, this process resembles the row-wise(or column-wise) matrix transformation.\n[![Simulation of ODE. Path Traversal simulation for SD3.](../images/body-9d8029dbc31666cc8355.gif)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_simulation-1.gif)_Fig 6: ODE path traversal simulation in SD3_\nAll in all, we can say that flow matching or normalizing flow transforms a simple distribution ( gaussian distribution ) into a complex one by applying a series of invertible transformation functions. \n**Let’s go further into this concept by introducing some mathematical details.**\n_FM Objective_ :\n[![Simplified MSE Loss Function Objective for Flow Matching problem](../images/body-6b4e41bad0d5f1c090c3.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/initial_flow_matching_-equation.png)_Fig 7:_ ![Vt](../images/body-df7daea6df18239e7c66.png) _and_ ![Ut](../images/body-f5d2a4159fe41231f8fe.png) _are vector fields of a single point pointing towards a particular direction to move_\nThe above expression is a simple mean square error formula between two vector fields. This equation regresses the vector field ![V_t ](../images/body-131b52c7238654ffff8a.png), which is parameterized by ![\\\\theta](../images/028.png), and ultimately aims to reach a known vector field ![U_t](../images/body-4251324c076692f725ef.png). However, the challenge we face is that we do not have any information about what the final vector field ![V_t](../images/body-0c02990ef4ad8351f34f.png) looks like. Additionally, the objective presented is impractical to use because we lack prior knowledge of what appropriate distributions![P_t](../images/body-1d57387ea7c0af64e9ce.png), and ![U_t](../images/body-4251324c076692f725ef.png), should be.\nTo address this, we need to get acquainted with mathematics to make it more intuitive to understand how to arrive at the final probability distribution or target image. This is where **Conditional Flow Matching (CFM)** comes into play.\n[![Conditional Flow Matching Objective given the target sample \\(x1\\).](../images/body-028d5240491ceab2df4e.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/CFM_loss-1.png)_Fig 8: CFM Objective_\n  1. The authors have demonstrated that optimizing the Conditional Flow Matching (CFM) objective is analogous to optimizing the Flow Matching (FM) objective. This effectively indicates that the divergence of the loss function for flow matching is nearly equal to the divergence of the loss function for conditional flow matching.\n\n\n  1. Since we do not have a straightforward method for obtaining ![U_t](../images/body-4251324c076692f725ef.png),, we will transform it into another representation. \n\n\n  1. Before proceeding, let’s define a few concepts: a**probability path and a vector field are distinct entities.** A vector field assigns a vector to every point in space, while a path specifies a vector for only a subset of points that follow a particular curve (in our case, this will be a Gaussian curve). Assuming each path takes the form of a Gaussian, we can express it according to the equation shown below:\n\n[![Assumption on Probability Path for Conditional Flow Matching ](../images/body-10f52616730f18deed8a.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083620/assumed_prob_path_flow_matching.png)_Fig 9: Assumed Probability path for Conditional Flow Matching_\n  1. Now, let’s move on these paths. Mathematically, it means shifting the mean of our data point to a new position and then scaling it with a standard deviation.\n  2. Mathematically showing how this point moves over time, we can use the push-forward equation and substitute these values in our original CFM loss; we get something like this:\n\n[![Re parameterized equation of flow matching for tractability using Push Forward Method. ](../images/body-79ef303e4601ac4ff011.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/parameterised_loss_CFM_equation.png)_Fig 10: Re parameterized Conditional Flow Matching_\nIn the equations above, ![\\\\psi](../images/body-ef3f57f42be8a16e0dc2.png) represents a function that defines the transformation of each point.\nAs the authors explore the optimal mean and standard deviation over time for transforming a point towards the target point, they deduced (through induction alone) that the **Optimal Transport method** —characterized by a linear or straight flow—is the most effective approach to achieving the ultimate goal of reaching the final target distribution.\nThe **final loss function** for the Optimal Transport method is formulated as follows:  \n\n[![Final Conditioned Flow Matching Objective or Loss Function](../images/body-ae8aae9b4b02de306226.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/flow_matching_final_loss-2.png)Fig 11: Final CFM loss Equation[![Comparison between flow of simple diffusion and optimal transport optimized flow diffusion in SD3](../images/body-642d29829397bfe95d69.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/simple_diffusion_and_optimal_transport_diffusion.png) _Fig 12: Simple Diffusion flow v/s SD3 Flow_\nAs visible in the image shown above, the way a diffusion model travels towards the target distribution and flow matching approaches are quite different. The paper’s authors showed that the Optimal Transport function for flow matching is the best practice for producing the most accurate samples in optimal time complexity. \n## Timestamp Sampling used in Stable Diffusion 3.5\nFinally, we have arrived at the last concept to understand the Stable Diffusion 3.5 model. A Stable Diffusion 3 model is essentially a refinement of the diffusion model, enhanced by adding flow matching and timestamp sampling techniques. The previous discussion outlined how flow matching integrates into the diffusion process to ensure the shortest and most optimal path.\nUntil now, all our timestamps have been equally weighted and derived from a uniform distribution. However, as noted by the authors of the Stable Diffusion 3 paper, the differences between intermediate timestamps tend to be more significant than those at the beginning or end. Thus, it is essential to incorporate a weighted loss function that assigns greater importance to the intermediate timestamps.\nIn their research on timestamp sampling techniques, the authors concluded that **Logit-Normal Sampling** would yield the most optimal results.\nIn summary, we can say that:\n**Diffusion + Rectified Flow (Flow Matching) + Logit-Normal Sampling leads us to Stable Diffusion 3.5.**\n### From idea to working model to real-time deployment\nBig Vision takes computer vision projects through the full journey, not just the easy parts.\n![Satya Mallick](../images/body-fe65e1f717d94c873fd9.jpg)\n**Satya Mallick** Founder - Big Vision & LearnOpenCV\n[ Talk to our Team ](https://bigvision.ai/expert-ai-solution-builders/)\n## The architecture of Stable Diffusion 3.5\nThe architecture is based on the Diffusion Transformers model, utilizing an Encoder (VAE) to generate noise latent variables, similar to the **MMDiT** architecture. It also includes a decoder(VAE) to upscale the output of our model. \nLet’s begin with the first layer, where captions (textual [prompts](https://learnopencv.com/instructpix2pix/ \"prompts\")) are processed and transformed into embeddings within an embedding space.\n### Textual Embedding\nBased on [Stable Diffusion](https://learnopencv.com/sdxl-inpainting/ \"Stable Diffusion\") 3, **MMDiT** employs three textual encoders: **CLIP-G/14** , **CLIP-L/14** , and a **T5 XXL** encoder with approximately **5 billion parameters**. The rationale behind using these three textual encoders is to enhance performance. This configuration offers flexibility during inference, allowing us to balance model performance and memory efficiency by removing the T5 XXL encoder if desired.\nWe have the option to include the T5 XXL encoder during inference. Removing this encoder helps reduce memory consumption with only a minimal loss in accuracy. When the T5 XXL encoder is removed, its output becomes a tensor of zeros.\nThe simplified code appears as follows:\n[![Code Snippet of defining text_encoders of SD3, particularly T5 XXL.](../images/body-bf39bffdb1a71ad6966f.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/t5_xxl_encoder_function_sd35.png)_Fig 13: T5 XXL inclusion/removal code snippet_\n### Patchify\nAs the pooled text representations retain only coarse-grained information about the textual input, the network also needs insights from the sequence representation. To achieve this, we create patch encodings by **flattening 2×2 patches** and adding **positional encodings**. We then **concatenate** this with text encodings, ensuring both have the same dimensionality.\nThe factor by which we scale down our image (referred to as patch_number) depends on the **scale factor** , as shown in the image below:\n[![Code Snippet of Patch Generation function on latent image space ](../images/body-d332412bf9184d405938.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/patchify_function_sd35.png)_Fig 14: Patchification of latent image code snippet_\n### DiT backbone used in Stable Diffusion 3.5\nAfter the above two procedures, the MM-DiT model follows the DiT backbone and applies a sequence of **Modulated Attention** and MLP layers.\nTo best understand the upgrade MM-DiT brought against vanilla DiT, we can summarize it in one sentence: **DiT is the special case of MM-DiT** with only one set of shared weights for all modalities.\n[![Stable Diffusion 3.5 Architecture](../images/body-fcf354653451890f9517.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/SD35_arch.png)_Fig 15: SD 3.0 Architecture_[![Simplified Stable Diffusion 3.5 Architecture. Modulated Attention Mechanism](../images/body-dbabbbde13be7fdf406e.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/simplified_architecture_sd35.png) _Fig 16: Simplified SD3.0 Architecture_\nOne question you might ask after seeing the architecture is **what alpha, beta, and gamma represent**.\nThe answer lies in the way diffusion transformers implement [attention](https://learnopencv.com/attention-mechanism-in-transformer-neural-networks/ \"attention\") mechanisms. The attention mechanism they use is modulated attention, as seen in the simplified architecture image. \n[![Code Snippet of Modulation function used in Stable Diffusion 3/3.5 for attention mechanism ](../images/body-90b23fd7c03cd9861f4a.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/modulated_attention_function_sd35.png)_Fig 17: Modulated Attention Mechanism as shown in the image above_\nThe input vector, which includes the skip connection input, can be expressed as input vector + (input * scale) + shift. Scales and shifts refer to alpha, beta, and gamma parameters visible in the model architecture.\nLike DiT, MMDiT employs adaptive layer normalization (adaLN) instead of traditional layer normalization (LN). The authors of the DiT paper explain that adaLN is the most compute-friendly option. Additionally, it is the only conditioning mechanism that applies the same function uniformly across all tokens.\n[![Adaptive Layer Normalization or adaLN function used in Stable Diffusion 3.5 source code.](../images/body-200af0f59921ef5635f4.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083615/sd3_adaLN_function_script.png)_Fig 18: Layer Normalization used in SD3.5 and DiT is adaptive Layer Normalization or adaLN_\nLastly, the authors discussed the separate sets of weights they used to understand the complexity of each modality individually. This approach is equivalent to having two transformers, one for each modality. While it might seem that this would lead to no correlation between the two modalities, combining both sequences for the joint attention operation addresses this issue.\nAdditionally, the architecture presented differs from the original MMDiT architecture by incorporating more self-attention blocks. This modification pertains to the **Stable Diffusion 3.5 medium** (**MM-DiTx**), a **2.5 billion parameter model**. Because of this lower parameter count, it is less accurate; thus, the authors introduced **additional layers of attention** to enhance its ability to understand the relationships and semantic meanings within the sequences.\n[![MM-DiTx \\(Stable Diffusion 3.5 medium ~2.5 B parameter\\) architecture](../images/body-83db8249fe6e68fdd068.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/mmdit-x_architecture.png)_Fig 19: MMDiTx Architecture or SD3.5 medium_\nTo better understand a model’s way of calculating noise and outputting a sample, we should look at a snippet of the model’s pipeline where it regresses noise.\n[![Reverse Diffusion Process or Denoising Algorithm Implementation as described in source code of Stable Diffusion 3.5](../images/body-2c8d6ded9d23a7ae278a.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/denoising_algo_sd3.png)_Fig 20: Denoising Algorithm(Reverse Diffusion Process) of SD3.5 code snippet_\nHere, we can see that inside the denoising loop, the transformer model gives predicted noise as output, which is then chunked to generate two noises: predicted unconditional noise and predicted textual noise. Finally, latent(t-1) is generated using the scheduler and latent from the previous (t) timestamp.\n# Inference with Stable Diffusion 3.5 Large Turbo, Large, Medium\n[![Hardware or GPU requirements for each Stable Diffusion 3.5 model along with GPU requirements for FLUX models also.](../images/body-2bde47d67f301a3adb47.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083613/hardware_requirements_sd3.png)_Fig 21: Hardware Requirements for various SD models_\n**Download Code** To easily follow along this tutorial, please download code by clicking on the button below. It's FREE!\n[Download Code](javascript:void\\(0\\))\nIn the image above, **Stability AI** has outlined the compatibility of various models with different GPU architectures.\nNext, let’s explore the inference process and closely examine the inference script.\nBefore we proceed, let’s look at GPU consumption and usage during the inference process. We have set up an instance with one A6000 GPU with a maximum memory capacity of **48GB.**\n[![Nvidia A6000 GPU usage and Consumption in inferencing Stable Diffusion 3.5 Large Turbo](../images/body-8afcf5c78f83ddbfb7b8.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083612/watch_nvidia-smi.png)_Fig 22: Single Nvidia GPU A6000 Consumption and Usage_\nFollowing are the dependencies(like [diffusers](https://learnopencv.com/ai-art-generation-tools/ \"diffusers\")) that we need to install for the Stable Diffusion 3.5 Large Turbo module.  \n|  1 2 3 4 5  |  `!pip install ``-``U diffusers` `!pip install transformers` `!pip install accelerate` `!pip install sentencepiece` `!pip install protobuf`  |  \n| --- | --- |  \nNext, we import the necessary functions and create a pipeline for our Stable Diffusion 3.5 Large Turbo Model, which only requires the Model ID and Torch Dtype as arguments.  \n|  1 2  |  `import` `torch` `from` `diffusers ``import` `StableDiffusion3Pipeline`  |  \n| --- | --- |  \nNow, let’s create an instance of Pipeline and call Stable Diffusion 3.5 Large Turbo Model.  \n|  1 2 3  |  `pipe ``=` `StableDiffusion3Pipeline.from_pretrained(``\"stabilityai/stable-diffusion-3.5-large-turbo\"``, torch_dtype ``=` `torch.bfloat16)` `pipe ``=` `pipe.to(``\"cuda\"``)`  |  \n| --- | --- |  \nA manual seed is defined to ensure that every time we run the sample.\n  1. The Number of Inference Steps: Intermediate Latents are generated before reaching the final output.\n  2. The Guidance Scale: The degree to which we want our model to adhere to the [prompt](https://learnopencv.com/instructpix2pix/ \"prompt\"). A value of 0 means the model will generate a sample based on the prompt but will be flexible in its generation, thereby not strictly adhering to it.\n\n\nFinally, let us use the pipeline instance to create our synthesized image of a Capybara.  \n|  1 2 3 4  |  `torch.manual_seed(``1``)` `image ``=` `pipe(``\"cute capybara holding a card on which 'HELLO WORLD' is written\"``, num_inference_steps ``=` `30``, guidance_scale ``=` `0.0``).images[``0``]` `image.save(``\"capybara.png\"``)`  |  \n| --- | --- |  \n[![Sample Image of a Capybara generated from Stable Diffusion 3.5 Large Turbo ](../images/body-4784192e7a992eb62067.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083558/capybara.png)_Fig 23: Capybara sample image_\n# Comparison of Stable Diffusion 3.5 Large Turbo and Flux Schnell\n**Model similarities and differences overview**\n  * The **Flux Schnell** model is a **12B parameter** model, whereas the **SD3.5 large-turbo** model is an **8.1B parameter** model.\n  * Typically, the number of inference steps for Flux Schnell ranges between 3-6; for SD3.5 large-turbo, it’s fixed to 20.\n  * The Guidance Scale for both models is set to 0. However, the Flux Schnell model does not explicitly require a guidance scale parameter in its pipeline.\n  * When a pipeline is instantiated, we can define another parameter called ‘negative prompt.’ This tells an AI diffusion model to avoid generating specific elements or characteristics in its output. The vital thing to notice is that the Flux Schnell model is not designed to provide negative prompts in its pipeline. At the same time, in Stable Diffusion 3.5, users can pass this parameter if they want the model to avoid certain practices while generating a sample.\n  * If you are interested to know more about Flux models, do visit our another article [Flux Image Generation.](https://learnopencv.com/flux-ai-image-generator/ \"Flux Image Generation.\")\n\n[![vincent van gogh's starry night painting artistic style generation with Batman modification](../images/body-72defab99b9565c130b1.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083551/batman_image_comparison.png)_Fig 24: Batman in Starry Night art by**Van Gogh**_\n* * *\n[![Red-Green color dragon set in a cloudy and mountainous place style generation ](../images/body-e5b50e7896d7666586ee.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083549/dragon_image_comparison.png)_Fig 25 Dragon with green wings in a cloudy and mountainous place_\n* * *\n[![Portrait of a woman giving talk and working at Google tech style generation ](../images/body-e6cebdbda4381d5e14b3.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083548/portrait_image_comparison.png)_Fig 26: Portrait of a woman at Google tech conference_\n* * *\n[![mona lisa original portrait style generation ](../images/body-4425cbaf7c5dfcba80af.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083546/mona_lisa_image_comparison-1.png)_Fig 27:**Mona Lisa** by Da Vinci_\n# Conclusion \nThis article takes a walk through a wide variety of concepts like latent diffusion, flow matching, etc., in a very informative manner, covering final loss mathematical equations, elaborative explanations of code blocks, etc.\nTo summarize this article, we covered:\n  1. Diffusion and its Training and Sampling Algorithm.\n  2. Latent Diffusion Models and their Architecture.\n  3. Probability Path and Flow Matching.\n  4. The most efficient path for diffusion models to follow.\n  5. Stable Diffusion models and their architecture.\n  6. Inference code blocks.\n  7. Sample comparison between Flux Schnell and SD3.5 Large Turbo.\n\n\nGenerative AI has opened up many research opportunities, especially diffusion models, as their practical applications keep increasing daily, ranging from commercial content creation to artistic innovation.\nHappy Learning 🙂\n# References\n  * [Stability AI](https://stability.ai/news/introducing-stable-diffusion-3-5 \"Stability AI\")\n  * [DDPM: Theory to Implementation](https://learnopencv.com/denoising-diffusion-probabilistic-models/ \"DDPM: Theory to Implementation\")\n  * [SD3.5 source code](https://github.com/Stability-AI/sd3.5/blob/main/sd3_impls.py#L53 \"SD3.5 source code\")\n  * [Scaling Rectified Flow Transformers](https://arxiv.org/pdf/2403.03206 \"Scaling Rectified Flow Transformers\")\n  * [Flow Matching Paper Explanation](https://www.youtube.com/watch?v=7NNxK3CqaDk&t=2819s \"Flow Matching Paper Explanation\")\n  * [Flow-Based Deep Generative Models](https://lilianweng.github.io/posts/2018-10-13-flow-models/ \"Flow Based Deep Generative Models\")\n  * [Introduction to Flow Matching](https://mlg.eng.cam.ac.uk/blog/2024/01/20/flow-matching.html \"Introduction to Flow Matching \")\n  * [Review: Adaptive Layer Normalization](https://sh-tsang.medium.com/review-adanorm-adaptive-normalization-73865be8d522 \"Review: Adaptive Layer Normalization\")\n  * [Model Quantization](https://medium.com/@rakeshrajpurohit/model-quantization-with-hugging-face-transformers-and-bitsandbytes-integration-b4c9983e8996 \"Model Quantization\")\n  * [Hugging Face Documentation: Pipeline](https://huggingface.co/docs/diffusers/en/using-diffusers/loading \"Hugging Face Documentation: Pipeline\")\n  * [Flow Matching in Latent Space](https://vinairesearch.github.io/LFM/ \"Flow Mactching in Latent Space\")\n  * [The Latent: Code The Math](https://magic-with-latents.github.io/latent/ddpms-series.html \"The Latent: Code The Maths\")\n\n\nWas This Article Helpful?\nPost Views: 145\n## Subscribe & Download Code\nIf you liked this article and would like to download code (C++ and Python) and example images used in this post, please [click here](javascript:void\\(0\\)). In our newsletter, we share Computer Vision and AI tutorials and examples written in C++/Python, and Computer Vision and Machine Learning algorithms and news.  \n  \n\n[ Download Example Code](javascript:void\\(0\\))\n  \n  \n\n[PrevPreviousLightRAG: Simple and Fast Alternative to GraphRAG for Legal Doc Analysis](https://learnopencv.com/lightrag/)\n[NextThe Annotated NeRF – Training on Custom Dataset from Scratch in PytorchNext](https://learnopencv.com/annotated-nerf-pytorch/)\n###  [ Train RF-DETR for Instance Segmentation with GPT-6 Astra ](https://learnopencv.com/astra-rf-detr-microduck-segmentation/)\nBefore a flight, I left Astra a short prompt and a signed-in Roboflow account. It\n###  [ How 10x AI Engineers Train Models for Production: Lessons from PINTO’s Face Alignment Project ](https://learnopencv.com/how-10x-ai-engineers-train-models-for-production/)\nLearn a production model training playbook from PINTO’s face alignment project: reframe the task, engineer\n###  [ VGGT vs. VGGT-Ω (VGGT-Omega): A Complete Guide to Feed-Forward 3D Reconstruction ](https://learnopencv.com/vggt-vs-vggt-%cf%89-vggt-omega-a-complete-guide-to-feed-forward-3d-reconstruction/)\nHow VGGT and VGGT-Ω work, what changed, and real benchmark numbers, speed, GPU memory, depth,\n![Satya Mallick](../images/body-fe65e1f717d94c873fd9.jpg)\n#### Satya Mallick, Ph.D.\nFounder - Big Vision & LearnOpenCV\n#####  Are you struggling with your Computer Vision Product Development?\nHelping startups and enterprises build and deploy scalable solutions that work in the real world.\n[ Schedule a Call ](https://bigvision.ai/expert-ai-solution-builders?utm_source=lopcv&utm_medium=post)\n####  Table of Contents\n  1. [What is diffusion, and how does it work?](https://learnopencv.com/stable-diffusion-3/#aioseo-defining-diffusion-and-variants-and-the-reason-for-this-nomenclature)\n  2. [Latent Diffusion](https://learnopencv.com/stable-diffusion-3/#aioseo-latent-diffusion)\n  3. [Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-stable-diffusion)\n  4. [Flow Matching for Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-flow-matchingaioseo-flow-matching)\n  5. [Timestamp Sampling used in Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-timestamp-sampling)\n  6. [The architecture of Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-architecture)\n  7. [Inference with Stable Diffusion 3.5 Large Turbo, Large, Medium](https://learnopencv.com/stable-diffusion-3/#aioseo-inference-with-sd-3-5-large-turbo-large-medium)\n  8. [Comparison of Stable Diffusion 3.5 Large Turbo and Flux Schnell](https://learnopencv.com/stable-diffusion-3/#aioseo-comparison-of-sd3-5-large-turbo-with-flux-schnell)\n  9. [Conclusion ](https://learnopencv.com/stable-diffusion-3/#aioseo-conclusion)\n  10. [References](https://learnopencv.com/stable-diffusion-3/#aioseo-references)\n\n\nWas This Article Helpful?\n  * [attention mechanism](https://learnopencv.com/tag/attention-mechanism/), [conditional ddpm](https://learnopencv.com/tag/conditional-ddpm/), [Conditional Flow Matching](https://learnopencv.com/tag/conditional-flow-matching/), [cross attention mechanism](https://learnopencv.com/tag/cross-attention-mechanism/), [denoising diffusion probabilistic models](https://learnopencv.com/tag/denoising-diffusion-probabilistic-models/), [denoising diffusion probabilistic models tutorial](https://learnopencv.com/tag/denoising-diffusion-probabilistic-models-tutorial/), [diffusion generative model](https://learnopencv.com/tag/diffusion-generative-model/), [diffusion model](https://learnopencv.com/tag/diffusion-model/), [diffusion models explained](https://learnopencv.com/tag/diffusion-models-explained/), [Diffusion Transformers](https://learnopencv.com/tag/diffusion-transformers/), [flow matching](https://learnopencv.com/tag/flow-matching/), [generative ai](https://learnopencv.com/tag/generative-ai/), [image sample generation](https://learnopencv.com/tag/image-sample-generation/), [joint attention](https://learnopencv.com/tag/joint-attention/), [modulated attention](https://learnopencv.com/tag/modulated-attention/), [Optimal Transport](https://learnopencv.com/tag/optimal-transport/), [stable diffusion models](https://learnopencv.com/tag/stable-diffusion-models/), [Transformers](https://learnopencv.com/tag/transformers/)\n\n\n## Read Next\n[ ![Decoding Virat Kohli’s Flick Shot: AI-Based 3D Motion Reconstruction](../images/body-f3950ee9e907f51f83d3.png) ](https://learnopencv.com/decoding-virat-kohlis-flick-shot-ai-based-3d-motion-reconstruction/)\n[3D Computer Vision](https://learnopencv.com/category/3d-computer-vision/)[3D Reconstruction](https://learnopencv.com/category/3d-computer-vision/3d-reconstruction/)[Segmentation](https://learnopencv.com/category/segmentation/)[SpatialAI-Depth](https://learnopencv.com/category/3d-computer-vision/spatialai-depth/)[Video Analysis](https://learnopencv.com/category/video-analysis/)\n[Adnan Shaikh](https://learnopencv.com/author/adnan/) July 18, 2026 \n##  [ Decoding Virat Kohli’s Flick Shot: AI-Based 3D Motion Reconstruction ](https://learnopencv.com/decoding-virat-kohlis-flick-shot-ai-based-3d-motion-reconstruction/)\nReconstruct the 3D swing plane of Virat Kohli's flick shot from a single 2D video with off-the-shelf vision models. No…\n[ ![How to Run Object Detection with OpenCV 5](../images/body-6f304990249f37d13c7f.jpg) ](https://learnopencv.com/how-to-run-object-detection-with-opencv-5/)\n[Object Detection](https://learnopencv.com/category/object-detection/)[OpenCV 5](https://learnopencv.com/category/opencv/opencv-5/)[OpenCV DNN](https://learnopencv.com/category/opencv-dnn/)[YOLO](https://learnopencv.com/category/yolo/)\n[Sudip Chakrabarty](https://learnopencv.com/author/sudip/) July 9, 2026 \n##  [ How to Run Object Detection with OpenCV 5 ](https://learnopencv.com/how-to-run-object-detection-with-opencv-5/)\nLearn about the new OpenCV 5 and how to use its DNN engine to run object detection models on the…\n[ ![How to Fine-Tune YOLO26 for Safety Gear and Sign Language Detection](../images/body-6b014d4d46a21419f999.jpg) ](https://learnopencv.com/how-to-fine-tune-yolo26-for-safety-gear-and-sign-language-detection/)\n[Computer Vision](https://learnopencv.com/category/computer-vision/)[Object Detection](https://learnopencv.com/category/object-detection/)[YOLO](https://learnopencv.com/category/yolo/)\n[Sudip Chakrabarty](https://learnopencv.com/author/sudip/) June 18, 2026 \n##  [ How to Fine-Tune YOLO26 for Safety Gear and Sign Language Detection ](https://learnopencv.com/how-to-fine-tune-yolo26-for-safety-gear-and-sign-language-detection/)\nLearn how to fine-tune YOLO26 on your own data. We build a construction PPE safety detector and a sign-language reader…\n##  Subscribe to our Newsletter\nSubscribe to our email newsletter to get the latest posts delivered right to your email.\nName \nEmail \nSend\n![](../images/body-2dd5ce664c5fca7d56f8.png)\nEmpowering innovation through education, LearnOpenCV provides in-depth tutorials, code, and guides in AI, Computer Vision, and Deep Learning. Led by Dr. Satya Mallick, we're dedicated to nurturing a community keen on technology breakthroughs.\n[ Read More ](https://learnopencv.com/about/)\nCategories\n  * [Deep Learning](https://learnopencv.com/category/deep-learning/)\n  * [Object Detection](https://learnopencv.com/category/object-detection/)\n  * [Image Classification](https://learnopencv.com/category/image-classification)\n  * [YOLO](https://learnopencv.com/category/yolo/)\n  * [Image Processing](https://learnopencv.com/category/image-processing/)\n  * [Image Segmentation](https://learnopencv.com/category/image-segmentation/)\n\n\n  * [Deep Learning](https://learnopencv.com/category/deep-learning/)\n  * [Object Detection](https://learnopencv.com/category/object-detection/)\n  * [Image Classification](https://learnopencv.com/category/image-classification)\n  * [YOLO](https://learnopencv.com/category/yolo/)\n  * [Image Processing](https://learnopencv.com/category/image-processing/)\n  * [Image Segmentation](https://learnopencv.com/category/image-segmentation/)\n\n\nGetting Started\n  * [Installation](https://learnopencv.com/category/install/)\n  * [PyTorch](https://learnopencv.com/learn-pytorch/)\n  * [Getting Started with OpenCV](https://learnopencv.com/getting-started-with-opencv/)\n  * [Keras & Tensorflow](https://learnopencv.com/learn-keras-and-tensorflow/)\n\n\n  * [Installation](https://learnopencv.com/category/install/)\n  * [PyTorch](https://learnopencv.com/learn-pytorch/)\n  * [Getting Started with OpenCV](https://learnopencv.com/getting-started-with-opencv/)\n  * [Keras & Tensorflow](https://learnopencv.com/learn-keras-and-tensorflow/)\n\n\nBig Vision\n  * [AI Consulting](https://bigvision.ai/expert-ai-solution-builders/#talk?utm_source=locv&utm_medium=footer)\n  * [Case Studies](https://bigvision.ai/case-studies/?utm_source=locv&utm_medium=footer)\n  * [Get in Touch](https://bigvision.ai/contact-us/?utm_source=locv&utm_medium=footer)\n\n\n  * [AI Consulting](https://bigvision.ai/expert-ai-solution-builders/#talk?utm_source=locv&utm_medium=footer)\n  * [Case Studies](https://bigvision.ai/case-studies/?utm_source=locv&utm_medium=footer)\n  * [Get in Touch](https://bigvision.ai/contact-us/?utm_source=locv&utm_medium=footer)\n\n\nCopyright © 2026 – BIG VISION LLC [Privacy Policy](https://learnopencv.com/privacy-policy/) [Terms and Conditions](https://learnopencv.com/terms-and-conditions/)\n  * [ ](https://bit.ly/Facebook_LearnOpenCV)\n  * [ ](https://www.instagram.com/learnopencv/)\n  * [ ](https://www.linkedin.com/in/satyamallick/)\n  * [ ](https://x.com/LearnOpenCV)\n  * [ ](https://www.youtube.com/c/LearnOpenCV?utm_source=lopcv&utm_medium=footer&utm_campaign=yt)\n\n\n[ ![](../images/body-ab5d272e3cb213d5eb46.png) Click here to download the source code to this post ](javascript:void\\(0\\))\n",
  "metadata": {
    "title": "Stable Diffusion 3.5: Architecture and Inference",
    "description": "Stable Diffusion 3.5 in-depth explanation and Inference with an intuitive approach for topics like Latent Diffusion and Flow Matching.",
    "keywords": "attention mechanism,conditional ddpm,conditional flow matching,cross attention mechanism,denoising diffusion probabilistic models,denoising diffusion probabilistic models tutorial,diffusion generative model,diffusion model,diffusion models explained,diffusion transformers,flow matching,generative ai,image sample generation,joint attention,modulated attention,optimal transport,stable diffusion models,transformers",
    "author": "Bhomik Sharma",
    "og:locale": "en_US",
    "og:site_name": "LearnOpenCV – Learn OpenCV, PyTorch, Keras, Tensorflow with code, & tutorials",
    "og:type": "article",
    "og:title": "Stable Diffusion 3.5: Architecture and Inference",
    "og:description": "Stable Diffusion 3.5 in-depth explanation and Inference with an intuitive approach for topics like Latent Diffusion and Flow Matching.",
    "og:url": "https://learnopencv.com/stable-diffusion-3/",
    "og:image": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083632/768x432-1.gif",
    "og:image:secure_url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083632/768x432-1.gif",
    "og:image:width": "768",
    "og:image:height": "432",
    "twitter:card": "summary",
    "twitter:site": "@AiOpencv",
    "twitter:title": "Stable Diffusion 3.5: Architecture and Inference",
    "twitter:description": "Stable Diffusion 3.5 in-depth explanation and Inference with an intuitive approach for topics like Latent Diffusion and Flow Matching.",
    "twitter:creator": "@AiOpencv",
    "twitter:image": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083632/768x432-1.gif",
    "article:published_time": "2024-11-19T14:00:00+00:00",
    "article:modified_time": "2025-03-04T14:23:42+00:00",
    "article:publisher": "https://www.facebook.com/Learnopencv-277284889389059"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 301,
    "error": ""
  },
  "code_blocks": [],
  "images": [
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/02/04103923/learnOpenCV_by_bigvision1.png",
      "bytes": 6527,
      "reused": true,
      "local_path": "attachments/15a979e6487d/images/000.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/02/04103923/learnOpenCV_by_bigvision1.png",
      "alt": "",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083632/768x432-1.gif",
      "bytes": 2712898,
      "reused": true,
      "local_path": "attachments/15a979e6487d/images/007.gif",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083632/768x432-1.gif",
      "alt": "",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/diffusion_variablesample_space.png",
      "bytes": 41124,
      "reused": true,
      "local_path": "attachments/15a979e6487d/images/008.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/diffusion_variablesample_space.png",
      "alt": "Diffusion Space, Image Manifold Space and Denoised Interpolation",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/simple_diffusion_process.png",
      "bytes": 13299,
      "reused": true,
      "local_path": "attachments/15a979e6487d/images/013.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/simple_diffusion_process.png",
      "alt": "Diffusion Process describing Forward and Reverse Process",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-6e5c9526ff7f090ad4707f72d71e6041_l3.png",
      "bytes": 959,
      "reused": true,
      "local_path": "attachments/15a979e6487d/images/019.png",
      "src": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-6e5c9526ff7f090ad4707f72d71e6041_l3.png",
      "alt": "q\\(X_t \\\\mid X_{t-1}\\)",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083624/simple_diffusion_algorithm-1024x241.png",
      "bytes": 32398,
      "reused": true,
      "local_path": "attachments/15a979e6487d/images/020.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083624/simple_diffusion_algorithm-1024x241.png",
      "alt": "Denoising Diffusion Probabilitic Model Algorithm for Training and Sampling",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-d568696754056bac72429f6fc9bded70_l3.png",
      "bytes": 472,
      "reused": true,
      "local_path": "attachments/15a979e6487d/images/028.png",
      "src": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-d568696754056bac72429f6fc9bded70_l3.png",
      "alt": "\\\\theta",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083623/ldm_architecture-1.png",
      "bytes": 20191,
      "reused": true,
      "local_path": "attachments/15a979e6487d/images/029.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083623/ldm_architecture-1.png",
      "alt": "Latent Diffusion Model Architecture",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_image_ode_traversal-1024x387.png",
      "bytes": 40904,
      "reused": true,
      "local_path": "attachments/15a979e6487d/images/034.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_image_ode_traversal-1024x387.png",
      "alt": "Ordinary Differential Equation Solver for Stable Diffusion 3. Flow of ODE.",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_simulation-1.gif",
      "bytes": 362342,
      "reused": false,
      "content_type": "image/gif",
      "local_path": "attachments/15a979e6487d/images/body-9d8029dbc31666cc8355.gif",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_simulation-1.gif",
      "alt": "Simulation of ODE. Path Traversal simulation for SD3.",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/initial_flow_matching_-equation.png",
      "bytes": 3389,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-6b4e41bad0d5f1c090c3.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/initial_flow_matching_-equation.png",
      "alt": "Simplified MSE Loss Function Objective for Flow Matching problem",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-b6b53d2f65f010f8c96d58f42a47505a_l3.png",
      "bytes": 548,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-df7daea6df18239e7c66.png",
      "src": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-b6b53d2f65f010f8c96d58f42a47505a_l3.png",
      "alt": "Vt",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-edb5a4204a49e4d61c5497173f94be42_l3.png",
      "bytes": 538,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-f5d2a4159fe41231f8fe.png",
      "src": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-edb5a4204a49e4d61c5497173f94be42_l3.png",
      "alt": "Ut",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-83fbf70abf96b832d0f7cc1707dfb5db_l3.png",
      "bytes": 536,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-131b52c7238654ffff8a.png",
      "src": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-83fbf70abf96b832d0f7cc1707dfb5db_l3.png",
      "alt": "V_t ",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-dca6e42af9c894cb53bf8be78e990ec7_l3.png",
      "bytes": 535,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-4251324c076692f725ef.png",
      "src": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-dca6e42af9c894cb53bf8be78e990ec7_l3.png",
      "alt": "U_t",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-742fdc3542b8b862497e59d233489a49_l3.png",
      "bytes": 536,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-0c02990ef4ad8351f34f.png",
      "src": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-742fdc3542b8b862497e59d233489a49_l3.png",
      "alt": "V_t",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-7baa850c806c166d6b09a673ec826ee2_l3.png",
      "bytes": 533,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-1d57387ea7c0af64e9ce.png",
      "src": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-7baa850c806c166d6b09a673ec826ee2_l3.png",
      "alt": "P_t",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/CFM_loss-1.png",
      "bytes": 4411,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-028d5240491ceab2df4e.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/CFM_loss-1.png",
      "alt": "Conditional Flow Matching Objective given the target sample \\(x1\\).",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083620/assumed_prob_path_flow_matching.png",
      "bytes": 3355,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-10f52616730f18deed8a.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083620/assumed_prob_path_flow_matching.png",
      "alt": "Assumption on Probability Path for Conditional Flow Matching ",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/parameterised_loss_CFM_equation-1024x237.png",
      "bytes": 33655,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-79ef303e4601ac4ff011.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/parameterised_loss_CFM_equation-1024x237.png",
      "alt": "Re parameterized equation of flow matching for tractability using Push Forward Method. ",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-0cbe13586455fed24cb5718e40d2cb02_l3.png",
      "bytes": 504,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-ef3f57f42be8a16e0dc2.png",
      "src": "https://learnopencv.com/wp-content/ql-cache/quicklatex.com-0cbe13586455fed24cb5718e40d2cb02_l3.png",
      "alt": "\\\\psi",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/flow_matching_final_loss-2.png",
      "bytes": 5417,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-ae8aae9b4b02de306226.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/flow_matching_final_loss-2.png",
      "alt": "Final Conditioned Flow Matching Objective or Loss Function",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/simple_diffusion_and_optimal_transport_diffusion.png",
      "bytes": 6425,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-642d29829397bfe95d69.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/simple_diffusion_and_optimal_transport_diffusion.png",
      "alt": "Comparison between flow of simple diffusion and optimal transport optimized flow diffusion in SD3",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://opencv.org/university/wp-content/uploads/sites/4/2023/04/Dr-Satya.jpg",
      "bytes": 17778,
      "reused": false,
      "content_type": "image/jpeg",
      "local_path": "attachments/15a979e6487d/images/body-fe65e1f717d94c873fd9.jpg",
      "src": "https://opencv.org/university/wp-content/uploads/sites/4/2023/04/Dr-Satya.jpg",
      "alt": "Satya Mallick",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/t5_xxl_encoder_function_sd35.png",
      "bytes": 11024,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-bf39bffdb1a71ad6966f.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/t5_xxl_encoder_function_sd35.png",
      "alt": "Code Snippet of defining text_encoders of SD3, particularly T5 XXL.",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/patchify_function_sd35.png",
      "bytes": 19242,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-d332412bf9184d405938.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/patchify_function_sd35.png",
      "alt": "Code Snippet of Patch Generation function on latent image space ",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/SD35_arch-1024x701.png",
      "bytes": 50194,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-fcf354653451890f9517.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/SD35_arch-1024x701.png",
      "alt": "Stable Diffusion 3.5 Architecture",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/simplified_architecture_sd35.png",
      "bytes": 10335,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-dbabbbde13be7fdf406e.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/simplified_architecture_sd35.png",
      "alt": "Simplified Stable Diffusion 3.5 Architecture. Modulated Attention Mechanism",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/modulated_attention_function_sd35.png",
      "bytes": 3004,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-90b23fd7c03cd9861f4a.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/modulated_attention_function_sd35.png",
      "alt": "Code Snippet of Modulation function used in Stable Diffusion 3/3.5 for attention mechanism ",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083615/sd3_adaLN_function_script.png",
      "bytes": 2991,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-200af0f59921ef5635f4.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083615/sd3_adaLN_function_script.png",
      "alt": "Adaptive Layer Normalization or adaLN function used in Stable Diffusion 3.5 source code.",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/mmdit-x_architecture-1024x429.png",
      "bytes": 40986,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-83db8249fe6e68fdd068.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/mmdit-x_architecture-1024x429.png",
      "alt": "MM-DiTx \\(Stable Diffusion 3.5 medium ~2.5 B parameter\\) architecture",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/denoising_algo_sd3.png",
      "bytes": 29322,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-2c8d6ded9d23a7ae278a.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/denoising_algo_sd3.png",
      "alt": "Reverse Diffusion Process or Denoising Algorithm Implementation as described in source code of Stable Diffusion 3.5",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083613/hardware_requirements_sd3-1024x603.png",
      "bytes": 49219,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-2bde47d67f301a3adb47.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083613/hardware_requirements_sd3-1024x603.png",
      "alt": "Hardware or GPU requirements for each Stable Diffusion 3.5 model along with GPU requirements for FLUX models also.",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083612/watch_nvidia-smi.png",
      "bytes": 7161,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-8afcf5c78f83ddbfb7b8.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083612/watch_nvidia-smi.png",
      "alt": "Nvidia A6000 GPU usage and Consumption in inferencing Stable Diffusion 3.5 Large Turbo",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083558/capybara.png",
      "bytes": 420659,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-4784192e7a992eb62067.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083558/capybara.png",
      "alt": "Sample Image of a Capybara generated from Stable Diffusion 3.5 Large Turbo ",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083551/batman_image_comparison-1024x705.png",
      "bytes": 298786,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-72defab99b9565c130b1.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083551/batman_image_comparison-1024x705.png",
      "alt": "vincent van gogh's starry night painting artistic style generation with Batman modification",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083549/dragon_image_comparison-1024x702.png",
      "bytes": 251774,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-e5b50e7896d7666586ee.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083549/dragon_image_comparison-1024x702.png",
      "alt": "Red-Green color dragon set in a cloudy and mountainous place style generation ",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083548/portrait_image_comparison-1024x706.png",
      "bytes": 174124,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-e6cebdbda4381d5e14b3.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083548/portrait_image_comparison-1024x706.png",
      "alt": "Portrait of a woman giving talk and working at Google tech style generation ",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083546/mona_lisa_image_comparison-1-1024x598.png",
      "bytes": 232845,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-4425cbaf7c5dfcba80af.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083546/mona_lisa_image_comparison-1-1024x598.png",
      "alt": "mona lisa original portrait style generation ",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2026/07/16015539/decoding-virat-kohli-flick-shot-3d-motion-reconstruction.png",
      "bytes": 1911733,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-f3950ee9e907f51f83d3.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2026/07/16015539/decoding-virat-kohli-flick-shot-3d-motion-reconstruction.png",
      "alt": "Decoding Virat Kohli’s Flick Shot: AI-Based 3D Motion Reconstruction",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2026/07/11002616/OpenCV_5_Blog_Thumbnail_final-scaled.jpg",
      "bytes": 516266,
      "reused": false,
      "content_type": "image/jpeg",
      "local_path": "attachments/15a979e6487d/images/body-6f304990249f37d13c7f.jpg",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2026/07/11002616/OpenCV_5_Blog_Thumbnail_final-scaled.jpg",
      "alt": "How to Run Object Detection with OpenCV 5",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2026/06/17235330/YOLO26_Finetuning_Thumbnail_image-768x512.jpg",
      "bytes": 85542,
      "reused": false,
      "content_type": "image/jpeg",
      "local_path": "attachments/15a979e6487d/images/body-6b014d4d46a21419f999.jpg",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2026/06/17235330/YOLO26_Finetuning_Thumbnail_image-768x512.jpg",
      "alt": "How to Fine-Tune YOLO26 for Safety Gear and Sign Language Detection",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://cdn.learnopencv.com/wp-content/uploads/2025/12/04080755/learnOpenCV_by_bigvision1.png",
      "bytes": 6316,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-2dd5ce664c5fca7d56f8.png",
      "src": "https://cdn.learnopencv.com/wp-content/uploads/2025/12/04080755/learnOpenCV_by_bigvision1.png",
      "alt": "",
      "downloaded": true,
      "discovery": "saved_markdown"
    },
    {
      "status": "ok",
      "url": "https://learnopencv.com/wp-content/uploads/2021/10/cropped-favicon-512x512-1.png",
      "bytes": 22729,
      "reused": false,
      "content_type": "image/png",
      "local_path": "attachments/15a979e6487d/images/body-ab5d272e3cb213d5eb46.png",
      "src": "https://learnopencv.com/wp-content/uploads/2021/10/cropped-favicon-512x512-1.png",
      "alt": "",
      "downloaded": true,
      "discovery": "saved_markdown"
    }
  ],
  "audio": [],
  "videos": [
    {
      "url": "https://www.youtube.com/watch?v=7NNxK3CqaDk",
      "status": "ok",
      "local_path": "attachments/15a979e6487d/videos/7NNxK3CqaDk.mp4",
      "bytes": 429978058,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "3375.001000"
    },
    {
      "url": "https://www.youtube.com/c/LearnOpenCV?utm_source=lopcv&utm_medium=footer&utm_campaign=yt",
      "kind": "channel_reference",
      "status": "reference_only"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://learnopencv.com"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/category/install/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/getting-started-with-opencv/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/getting-started-with-pytorch/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/getting-started-with-tensorflow-keras/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/about/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/category/ai-art-generation/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/author/bhomik/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/category/diffusion-models/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/category/generative-ai/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/category/hugging-face-transformers/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/video-generation-models/"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/stable-diffusion-3/"
    },
    {
      "type": "internal",
      "href": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/diffusion_variablesample_space.png"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/denoising-diffusion-probabilistic-models/"
    },
    {
      "type": "internal",
      "href": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/simple_diffusion_process.png"
    },
    {
      "type": "internal",
      "href": "https://learnopencv.com/ai-art-generation-tools/"
    },
    {
      "type": "internal",
      "href": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083624/simple_diffusion_algorithm.png"
    },
    {
      "type": "internal",
      "href": "https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083623/ldm_architecture-1.png"
    },
    {
      "type": "external",
      "href": "https://opencv.org/university/free-courses/"
    },
    {
      "type": "external",
      "href": "https://opencv.org/university/vision-language-model-bootcamp/"
    },
    {
      "type": "external",
      "href": "https://opencv.org/university/free-pytorch-course/"
    },
    {
      "type": "external",
      "href": "https://opencv.org/university/free-tensorflow-keras-course/"
    },
    {
      "type": "external",
      "href": "https://opencv.org/university/free-opencv-course/"
    },
    {
      "type": "external",
      "href": "https://opencv.org/university/python-for-beginners/"
    },
    {
      "type": "external",
      "href": "https://bigvision.ai/expert-ai-solution-builders/"
    },
    {
      "type": "external",
      "href": "https://bigvision.ai/expert-ai-solution-builders"
    },
    {
      "type": "external",
      "href": "https://stability.ai/news/stability-ai-and-arm-bring-on-device-generative-audio-to-smartphones"
    },
    {
      "type": "external",
      "href": "javascript:void(0)"
    },
    {
      "type": "external",
      "href": "https://stability.ai/news/introducing-stable-diffusion-3-5"
    },
    {
      "type": "external",
      "href": "https://github.com/Stability-AI/sd3.5/blob/main/sd3_impls.py"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/2403.03206"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/watch?t=2819s&v=7NNxK3CqaDk"
    },
    {
      "type": "external",
      "href": "https://lilianweng.github.io/posts/2018-10-13-flow-models/"
    },
    {
      "type": "external",
      "href": "https://mlg.eng.cam.ac.uk/blog/2024/01/20/flow-matching.html"
    },
    {
      "type": "external",
      "href": "https://sh-tsang.medium.com/review-adanorm-adaptive-normalization-73865be8d522"
    },
    {
      "type": "external",
      "href": "https://medium.com/@rakeshrajpurohit/model-quantization-with-hugging-face-transformers-and-bitsandbytes-integration-b4c9983e8996"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/docs/diffusers/en/using-diffusers/loading"
    },
    {
      "type": "external",
      "href": "https://vinairesearch.github.io/LFM/"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:25:32Z",
  "source_url": "https://learnopencv.com/stable-diffusion/",
  "delivery_status": "unverified",
  "discovery_status": "http_403",
  "missing_reason": "http_403",
  "repair_error": "",
  "actual_video_files": [
    {
      "local_path": "attachments/15a979e6487d/videos/7NNxK3CqaDk.mp4",
      "bytes": 429978058,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "3375.001000",
      "status": "ok"
    }
  ],
  "expected_saved_body_images": 44,
  "image_discovery": "saved_markdown",
  "source_body_markdown": "We use essential cookies to make our site work. With your consent, we may also use non-essential cookies to improve user experience and analyze website traffic. By clicking “Accept,” you agree to our website's cookie use as described in our Cookie Policy. You can change your cookie settings at any time by clicking “Preferences.” \nAccept\n[ ![](https://cdn.learnopencv.com/wp-content/uploads/2024/02/04103923/learnOpenCV_by_bigvision1.png) ](https://learnopencv.com)\n  * [Getting Started](https://learnopencv.com/category/install/)\n    * [Subscribe](https://learnopencv.com/)\n    * [Installation](https://learnopencv.com/category/install/)\n    * [Getting Started with OpenCV](https://learnopencv.com/getting-started-with-opencv/)\n    * [PyTorch](https://learnopencv.com/getting-started-with-pytorch/)\n    * [Tensorflow & Keras](https://learnopencv.com/getting-started-with-tensorflow-keras/)\n  * [Free Courses](https://opencv.org/university/free-courses/?utm_source=lopcv&utm_medium=menu&utm_campaign=fcpage)\n    * [VLM Bootcamp](https://opencv.org/university/vision-language-model-bootcamp/?utm_source=lopcv&utm_medium=menu&utm_campaign=vlm)\n    * [PyTorch Bootcamp](https://opencv.org/university/free-pytorch-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=ptbc)\n    * [TensorFlow Keras Course](https://opencv.org/university/free-tensorflow-keras-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=tbc)\n    * [OpenCV Course](https://opencv.org/university/free-opencv-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=obc)\n    * [Python for Beginners](https://opencv.org/university/python-for-beginners/?utm_source=lopcv&utm_medium=menu&utm_campaign=pbc)\n  * [AI Consulting](https://bigvision.ai/expert-ai-solution-builders/#talk?utm_source=locv&utm_medium=menu)\n  * [About](https://learnopencv.com/about/)\n\n\n  * [Getting Started](https://learnopencv.com/category/install/)\n    * [Subscribe](https://learnopencv.com/)\n    * [Installation](https://learnopencv.com/category/install/)\n    * [Getting Started with OpenCV](https://learnopencv.com/getting-started-with-opencv/)\n    * [PyTorch](https://learnopencv.com/getting-started-with-pytorch/)\n    * [Tensorflow & Keras](https://learnopencv.com/getting-started-with-tensorflow-keras/)\n  * [Free Courses](https://opencv.org/university/free-courses/?utm_source=lopcv&utm_medium=menu&utm_campaign=fcpage)\n    * [VLM Bootcamp](https://opencv.org/university/vision-language-model-bootcamp/?utm_source=lopcv&utm_medium=menu&utm_campaign=vlm)\n    * [PyTorch Bootcamp](https://opencv.org/university/free-pytorch-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=ptbc)\n    * [TensorFlow Keras Course](https://opencv.org/university/free-tensorflow-keras-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=tbc)\n    * [OpenCV Course](https://opencv.org/university/free-opencv-course/?utm_source=lopcv&utm_medium=menu&utm_campaign=obc)\n    * [Python for Beginners](https://opencv.org/university/python-for-beginners/?utm_source=lopcv&utm_medium=menu&utm_campaign=pbc)\n  * [AI Consulting](https://bigvision.ai/expert-ai-solution-builders/#talk?utm_source=locv&utm_medium=menu)\n  * [About](https://learnopencv.com/about/)\n\n\nSearch ...\nResults\nSee all results\n  * [Home](https://learnopencv.com \"Home\")\n  * >\n  * [AI Art Generation](https://learnopencv.com/category/ai-art-generation/ \"AI Art Generation\")\n  * >\n  * Stable Diffusion 3.5: Paper Explanation and Inference\n\n\n[Bhomik Sharma](https://learnopencv.com/author/bhomik/)\n  * on  November 19, 2024\n\n\n# Stable Diffusion 3.5: Paper Explanation and Inference\nStable Diffusion 3.5, released on June 2024 by Stability AI, is the third iteration in the Stable Diffusion family. The Turbo-Large and Large variants of the SD3.5 family are Stability AI’s most advanced text-to-image open-source models yet. Stability AI has recently collaborated with ARM to produce on-device generative audio in\n  * [AI Art Generation](https://learnopencv.com/category/ai-art-generation/), [Diffusion Models](https://learnopencv.com/category/diffusion-models/), [Generative AI](https://learnopencv.com/category/generative-ai/), [Hugging Face Transformers](https://learnopencv.com/category/hugging-face-transformers/)\n\n\n![](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083632/768x432-1.gif)\n  *   *   * [ ](https://bigvision.ai/expert-ai-solution-builders?utm_source=lopcv&utm_medium=post-icon)\n\n\n**Stable Diffusion 3.5** , released on June 2024 by Stability AI, is the third iteration in the Stable Diffusion family. The **Turbo-Large** and**Large** variants of the SD3.5 family are Stability AI’s most advanced text-to-image open-source models yet. [Stability AI ](https://stability.ai/news/stability-ai-and-arm-bring-on-device-generative-audio-to-smartphones \"Stability AI \")has recently collaborated with ARM to produce on-device generative audio in smartphones.\nThese models are based on the fundamental concept of latent diffusion(even used in [text-to-video diffusion](https://learnopencv.com/video-generation-models/ \"text-to-video diffusion\") models), which we will cover later in this article before getting acquainted with the concepts of SD3.5.\n![](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083632/768x432-1.gif)\nThis article provides an intuitive understanding of how Stable Diffusion 3.5 works. We have provided an Inference script of the Stable Diffusion 3.5 Large Turbo model at the end of this article. Before proceeding any further, let’s take a moment to understand Diffusion Models.\n  1. [Defining Diffusion (and Variants) and the Reason for this Nomenclature](https://learnopencv.com/stable-diffusion-3/#aioseo-defining-diffusion-and-variants-and-the-reason-for-this-nomenclature \"Defining Diffusion \\(and Variants\\) and the Reason for this Nomenclature\")\n    1. [Latent Diffusion](https://learnopencv.com/stable-diffusion-3/#aioseo-latent-diffusion \"Latent Diffusion\")\n  2. [Stable Diffusion](https://learnopencv.com/stable-diffusion-3/#aioseo-stable-diffusion \"Stable Diffusion\")\n    1. [Flow Matching for Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-flow-matching \"Flow Matching for Stable Diffusion 3.5\")\n    2. [Timestamp Sampling used in Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-timestamp-sampling \"Timestamp Sampling used in Stable Diffusion 3.5\")\n    3. [The Architecture of Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-architecture \"The Architecture of Stable Diffusion 3.5\")\n      1. [Textual Embedding](https://learnopencv.com/stable-diffusion-3/#aioseo-textual-embedding \"Textual Embedding\")\n      2. [Patchify](https://learnopencv.com/stable-diffusion-3/#aioseo-patchify \"Patchify\")\n      3. [DiT Backbone](https://learnopencv.com/stable-diffusion-3/#aioseo-dit-backbone \"DiT Backbone\")\n  3. [Inference with Stable Diffusion 3.5 Large Turbo, Large and Medium](https://learnopencv.com/stable-diffusion-3/#aioseo-inference-with-sd-3-5-large-turbo-large-medium \"Inference with SD3.5 Large Turbo, Large and Medium\")\n  4. [Comparison of Stable Diffusion 3.5 Large Turbo and Flux Schnell](https://learnopencv.com/stable-diffusion-3/#aioseo-comparison-of-sd3-5-large-turbo-with-flux-schnell \"Comparison of SD3.5 Large Turbo with Flux Schnell\")\n  5. [Conclusion](https://learnopencv.com/stable-diffusion-3/#aioseo-conclusion \"Conclusion\")\n  6. [References](https://learnopencv.com/stable-diffusion-3/#aioseo-references \"References\")\n\n\n# What is diffusion, and how does it work?\n[![Diffusion Space, Image Manifold Space and Denoised Interpolation](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/diffusion_variablesample_space.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/diffusion_variablesample_space.png)_Fig 1: Diffusion Process Space_\nDiffusion in classical mechanics refers to the transfer of particles—or any tangible quantity—from an area of high concentration to an area of low concentration. Inspired by this concept, the authors of [Denoising Diffusion Probabilistic Models (DDPM)](https://learnopencv.com/denoising-diffusion-probabilistic-models/ \"Denoising Diffusion Probabilistic Models \\(DDPM\\)\") introduce noise into a target image (which has very low noise) to align it with the noise data distribution. This process is known as **Forward Diffusion** , as described by the original authors of the diffusion paper. Conversely, the process is called Reverse Diffusion when the target data distribution is derived from this noisy image.\n[![Diffusion Process describing Forward and Reverse Process](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/simple_diffusion_process.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083625/simple_diffusion_process.png)_Fig 2: Simple Diffusion Process_\nThe image above shows how the forward and reverse [diffusion](https://learnopencv.com/ai-art-generation-tools/ \"diffusion\") process works by representing it in probabilistic notations. However, these notations represent the data distributions at each timestamp. As we observe, the image becomes progressively noisier when we follow the path of ![q\\(X_t \\\\mid X_{t-1}\\)](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-6e5c9526ff7f090ad4707f72d71e6041_l3.png). This indicates that noise is gradually diffusing into the target distribution. Essentially, our neural network will learn the noise distribution between two timestamps during the reverse diffusion process by regressing the mean and variance of the latter.\nIt is not always necessary to regress both central tendencies; we can instead focus solely on regressing the noise by simplifying the diffusion loss function.\nLet’s take a look at how the authors have defined the **algorithm for Denoising Diffusion Probabilistic Models (DDPM)** :\n[![Denoising Diffusion Probabilitic Model Algorithm for Training and Sampling](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083624/simple_diffusion_algorithm-1024x241.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083624/simple_diffusion_algorithm.png)_Fig 3: Simple Diffusion Algorithm_\nWhere,\n![\\\\\\[\\\\begin{aligned}\\\\\\\\epsilon \\\\rightarrow \\\\text{Actual Noise} \\\\\\\\\\\\epsilon_{\\\\theta} \\\\rightarrow \\\\text{Predicted Noise} \\\\\\\\\\\\mathcal{N}\\(0, \\\\mathbf{I}\\) \\\\rightarrow \\\\text{Standard Normal Distribution} \\\\\\\\\\\\alpha_t \\\\rightarrow 1 - \\\\beta_t \\\\quad \\\\text{\\(Variance Schedule or Scaling Factor\\)} \\\\\\\\\\\\mathbf{z} \\\\rightarrow \\\\text{Vector from } \\\\mathcal{N}\\(0, \\\\mathbf{I}\\) \\\\\\\\\\\\nabla_{\\\\theta} \\\\rightarrow \\\\text{Divergence} \\\\\\\\\\\\mathbf{x}_0, \\\\mathbf{x}_T \\\\rightarrow \\\\text{Samples at time } t = 0 \\\\text{ and } t = 1\\\\end{aligned}\\]](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-609cc13a94fc1c151bf9c87b93fa0117_l3.png)\nAs mentioned, we can see that the model is trying to regress epsilon (parameterized by ![\\\\theta](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-d568696754056bac72429f6fc9bded70_l3.png)) by getting as close to the original noise as possible.\nNow that we know the algorithm guiding the diffusion process, we can move to understanding **Latent Diffusion Models(LDM).**\n## Latent Diffusion\nCompared to Vanilla Diffusion, Latent Diffusion incorporates one key change that makes it more applicable to real-life scenarios. This idea is derived from the models used in Variational Autoencoders (VAEs).\nThe latent variable ‘Z’ is a low-dimensional representation of the original data. This representation is beneficial for generation, as it captures the essential attributes of the data without any extraneous information. This vector encapsulates everything needed to reconstruct the original distribution using VAEs.\nWhen generating our target distribution from noise, we utilize a significant amount of resources; in fact, diffusion (considering both forward and reverse diffusion processes) is **resource-intensive**. To address this issue, we can apply the **concept of latent spaces** from Variational Autoencoders (VAEs).\nFirstly, a VAE encodes the target data into a latent space, resulting in a less complex, lower-dimensional representation than the original target distribution. Consequently, applying a diffusion framework or model to this latent vector makes the reverse process more efficient and faster.\nNow, let’s take a look at the architecture of latent diffusion models:\n[![Latent Diffusion Model Architecture](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083623/ldm_architecture-1.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083623/ldm_architecture-1.png)_Fig 4: LDM Architecture_\nThe authors of the DDPM paper employed a **U-Net architecture as a neural network** for the diffusion process, which has since become a standard for diffusion neural networks. This architecture offers several advantages for our purposes, including multi-scale feature extraction, versatility with conditional inputs, and efficient memory and computational usage.\nAs we can see in the image, a section named Conditioning. It refers to the process in which the generation of sample images adheres to the instructions provided in the condition itself, or you can say the **prompt provided by the user** , rather than just being a random prediction from the diffusion model. This conditioning can take various forms, such as semantic maps, text, or images.\nWith a foundational understanding of diffusion and latent diffusion models, it’s time to introduce Stable Diffusion.\n# Stable Diffusion 3.5\nBefore understanding [Stable Diffusion](https://learnopencv.com/stable-diffusion-generative-ai/ \"Stable Diffusion\"), we must know what flow matching means.\n[![Ordinary Differential Equation Solver for Stable Diffusion 3. Flow of ODE.](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_image_ode_traversal-1024x387.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_image_ode_traversal.png)_Fig 5: ODE paths for SD3_\n## Flow Matching for Stable Diffusion 3.5\nThe dotted lines shown in the figure above represent what is known as _“flow_.” This concept describes how a sample point from the latent space distribution transforms into a component of the target distribution. This may seem a bit ambiguous and difficult to grasp at first, but by the end of this section, a clear understanding of how flow matching works and its relation to Stable Diffusion will be established.\nSpecifically, the paper’s authors introduced flow matching as a simple and intuitive training objective aimed at regressing onto a target vector field that produces a desired probability path. A probability path refers to the route that a particular distribution (in our case, the noise distribution) takes to achieve the state of another distribution. Assuming intermediate knowledge of matrices and determinants, this process resembles the row-wise(or column-wise) matrix transformation.\n[![Simulation of ODE. Path Traversal simulation for SD3.](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_simulation-1.gif)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083622/flow_matching_simulation-1.gif)_Fig 6: ODE path traversal simulation in SD3_\nAll in all, we can say that flow matching or normalizing flow transforms a simple distribution ( gaussian distribution ) into a complex one by applying a series of invertible transformation functions. \n**Let’s go further into this concept by introducing some mathematical details.**\n_FM Objective_ :\n[![Simplified MSE Loss Function Objective for Flow Matching problem](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/initial_flow_matching_-equation.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/initial_flow_matching_-equation.png)_Fig 7:_ ![Vt](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-b6b53d2f65f010f8c96d58f42a47505a_l3.png) _and_ ![Ut](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-edb5a4204a49e4d61c5497173f94be42_l3.png) _are vector fields of a single point pointing towards a particular direction to move_\nThe above expression is a simple mean square error formula between two vector fields. This equation regresses the vector field ![V_t ](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-83fbf70abf96b832d0f7cc1707dfb5db_l3.png), which is parameterized by ![\\\\theta](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-d568696754056bac72429f6fc9bded70_l3.png), and ultimately aims to reach a known vector field ![U_t](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-dca6e42af9c894cb53bf8be78e990ec7_l3.png). However, the challenge we face is that we do not have any information about what the final vector field ![V_t](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-742fdc3542b8b862497e59d233489a49_l3.png) looks like. Additionally, the objective presented is impractical to use because we lack prior knowledge of what appropriate distributions![P_t](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-7baa850c806c166d6b09a673ec826ee2_l3.png), and ![U_t](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-dca6e42af9c894cb53bf8be78e990ec7_l3.png), should be.\nTo address this, we need to get acquainted with mathematics to make it more intuitive to understand how to arrive at the final probability distribution or target image. This is where **Conditional Flow Matching (CFM)** comes into play.\n[![Conditional Flow Matching Objective given the target sample \\(x1\\).](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/CFM_loss-1.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083621/CFM_loss-1.png)_Fig 8: CFM Objective_\n  1. The authors have demonstrated that optimizing the Conditional Flow Matching (CFM) objective is analogous to optimizing the Flow Matching (FM) objective. This effectively indicates that the divergence of the loss function for flow matching is nearly equal to the divergence of the loss function for conditional flow matching.\n\n\n  1. Since we do not have a straightforward method for obtaining ![U_t](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-dca6e42af9c894cb53bf8be78e990ec7_l3.png),, we will transform it into another representation. \n\n\n  1. Before proceeding, let’s define a few concepts: a**probability path and a vector field are distinct entities.** A vector field assigns a vector to every point in space, while a path specifies a vector for only a subset of points that follow a particular curve (in our case, this will be a Gaussian curve). Assuming each path takes the form of a Gaussian, we can express it according to the equation shown below:\n\n[![Assumption on Probability Path for Conditional Flow Matching ](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083620/assumed_prob_path_flow_matching.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083620/assumed_prob_path_flow_matching.png)_Fig 9: Assumed Probability path for Conditional Flow Matching_\n  1. Now, let’s move on these paths. Mathematically, it means shifting the mean of our data point to a new position and then scaling it with a standard deviation.\n  2. Mathematically showing how this point moves over time, we can use the push-forward equation and substitute these values in our original CFM loss; we get something like this:\n\n[![Re parameterized equation of flow matching for tractability using Push Forward Method. ](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/parameterised_loss_CFM_equation-1024x237.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/parameterised_loss_CFM_equation.png)_Fig 10: Re parameterized Conditional Flow Matching_\nIn the equations above, ![\\\\psi](https://learnopencv.com/wp-content/ql-cache/quicklatex.com-0cbe13586455fed24cb5718e40d2cb02_l3.png) represents a function that defines the transformation of each point.\nAs the authors explore the optimal mean and standard deviation over time for transforming a point towards the target point, they deduced (through induction alone) that the **Optimal Transport method** —characterized by a linear or straight flow—is the most effective approach to achieving the ultimate goal of reaching the final target distribution.\nThe **final loss function** for the Optimal Transport method is formulated as follows:  \n\n[![Final Conditioned Flow Matching Objective or Loss Function](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/flow_matching_final_loss-2.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083619/flow_matching_final_loss-2.png)Fig 11: Final CFM loss Equation[![Comparison between flow of simple diffusion and optimal transport optimized flow diffusion in SD3](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/simple_diffusion_and_optimal_transport_diffusion.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/simple_diffusion_and_optimal_transport_diffusion.png) _Fig 12: Simple Diffusion flow v/s SD3 Flow_\nAs visible in the image shown above, the way a diffusion model travels towards the target distribution and flow matching approaches are quite different. The paper’s authors showed that the Optimal Transport function for flow matching is the best practice for producing the most accurate samples in optimal time complexity. \n## Timestamp Sampling used in Stable Diffusion 3.5\nFinally, we have arrived at the last concept to understand the Stable Diffusion 3.5 model. A Stable Diffusion 3 model is essentially a refinement of the diffusion model, enhanced by adding flow matching and timestamp sampling techniques. The previous discussion outlined how flow matching integrates into the diffusion process to ensure the shortest and most optimal path.\nUntil now, all our timestamps have been equally weighted and derived from a uniform distribution. However, as noted by the authors of the Stable Diffusion 3 paper, the differences between intermediate timestamps tend to be more significant than those at the beginning or end. Thus, it is essential to incorporate a weighted loss function that assigns greater importance to the intermediate timestamps.\nIn their research on timestamp sampling techniques, the authors concluded that **Logit-Normal Sampling** would yield the most optimal results.\nIn summary, we can say that:\n**Diffusion + Rectified Flow (Flow Matching) + Logit-Normal Sampling leads us to Stable Diffusion 3.5.**\n### From idea to working model to real-time deployment\nBig Vision takes computer vision projects through the full journey, not just the easy parts.\n![Satya Mallick](https://opencv.org/university/wp-content/uploads/sites/4/2023/04/Dr-Satya.jpg)\n**Satya Mallick** Founder - Big Vision & LearnOpenCV\n[ Talk to our Team ](https://bigvision.ai/expert-ai-solution-builders/)\n## The architecture of Stable Diffusion 3.5\nThe architecture is based on the Diffusion Transformers model, utilizing an Encoder (VAE) to generate noise latent variables, similar to the **MMDiT** architecture. It also includes a decoder(VAE) to upscale the output of our model. \nLet’s begin with the first layer, where captions (textual [prompts](https://learnopencv.com/instructpix2pix/ \"prompts\")) are processed and transformed into embeddings within an embedding space.\n### Textual Embedding\nBased on [Stable Diffusion](https://learnopencv.com/sdxl-inpainting/ \"Stable Diffusion\") 3, **MMDiT** employs three textual encoders: **CLIP-G/14** , **CLIP-L/14** , and a **T5 XXL** encoder with approximately **5 billion parameters**. The rationale behind using these three textual encoders is to enhance performance. This configuration offers flexibility during inference, allowing us to balance model performance and memory efficiency by removing the T5 XXL encoder if desired.\nWe have the option to include the T5 XXL encoder during inference. Removing this encoder helps reduce memory consumption with only a minimal loss in accuracy. When the T5 XXL encoder is removed, its output becomes a tensor of zeros.\nThe simplified code appears as follows:\n[![Code Snippet of defining text_encoders of SD3, particularly T5 XXL.](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/t5_xxl_encoder_function_sd35.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083618/t5_xxl_encoder_function_sd35.png)_Fig 13: T5 XXL inclusion/removal code snippet_\n### Patchify\nAs the pooled text representations retain only coarse-grained information about the textual input, the network also needs insights from the sequence representation. To achieve this, we create patch encodings by **flattening 2×2 patches** and adding **positional encodings**. We then **concatenate** this with text encodings, ensuring both have the same dimensionality.\nThe factor by which we scale down our image (referred to as patch_number) depends on the **scale factor** , as shown in the image below:\n[![Code Snippet of Patch Generation function on latent image space ](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/patchify_function_sd35.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/patchify_function_sd35.png)_Fig 14: Patchification of latent image code snippet_\n### DiT backbone used in Stable Diffusion 3.5\nAfter the above two procedures, the MM-DiT model follows the DiT backbone and applies a sequence of **Modulated Attention** and MLP layers.\nTo best understand the upgrade MM-DiT brought against vanilla DiT, we can summarize it in one sentence: **DiT is the special case of MM-DiT** with only one set of shared weights for all modalities.\n[![Stable Diffusion 3.5 Architecture](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/SD35_arch-1024x701.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083617/SD35_arch.png)_Fig 15: SD 3.0 Architecture_[![Simplified Stable Diffusion 3.5 Architecture. Modulated Attention Mechanism](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/simplified_architecture_sd35.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/simplified_architecture_sd35.png) _Fig 16: Simplified SD3.0 Architecture_\nOne question you might ask after seeing the architecture is **what alpha, beta, and gamma represent**.\nThe answer lies in the way diffusion transformers implement [attention](https://learnopencv.com/attention-mechanism-in-transformer-neural-networks/ \"attention\") mechanisms. The attention mechanism they use is modulated attention, as seen in the simplified architecture image. \n[![Code Snippet of Modulation function used in Stable Diffusion 3/3.5 for attention mechanism ](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/modulated_attention_function_sd35.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083616/modulated_attention_function_sd35.png)_Fig 17: Modulated Attention Mechanism as shown in the image above_\nThe input vector, which includes the skip connection input, can be expressed as input vector + (input * scale) + shift. Scales and shifts refer to alpha, beta, and gamma parameters visible in the model architecture.\nLike DiT, MMDiT employs adaptive layer normalization (adaLN) instead of traditional layer normalization (LN). The authors of the DiT paper explain that adaLN is the most compute-friendly option. Additionally, it is the only conditioning mechanism that applies the same function uniformly across all tokens.\n[![Adaptive Layer Normalization or adaLN function used in Stable Diffusion 3.5 source code.](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083615/sd3_adaLN_function_script.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083615/sd3_adaLN_function_script.png)_Fig 18: Layer Normalization used in SD3.5 and DiT is adaptive Layer Normalization or adaLN_\nLastly, the authors discussed the separate sets of weights they used to understand the complexity of each modality individually. This approach is equivalent to having two transformers, one for each modality. While it might seem that this would lead to no correlation between the two modalities, combining both sequences for the joint attention operation addresses this issue.\nAdditionally, the architecture presented differs from the original MMDiT architecture by incorporating more self-attention blocks. This modification pertains to the **Stable Diffusion 3.5 medium** (**MM-DiTx**), a **2.5 billion parameter model**. Because of this lower parameter count, it is less accurate; thus, the authors introduced **additional layers of attention** to enhance its ability to understand the relationships and semantic meanings within the sequences.\n[![MM-DiTx \\(Stable Diffusion 3.5 medium ~2.5 B parameter\\) architecture](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/mmdit-x_architecture-1024x429.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/mmdit-x_architecture.png)_Fig 19: MMDiTx Architecture or SD3.5 medium_\nTo better understand a model’s way of calculating noise and outputting a sample, we should look at a snippet of the model’s pipeline where it regresses noise.\n[![Reverse Diffusion Process or Denoising Algorithm Implementation as described in source code of Stable Diffusion 3.5](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/denoising_algo_sd3.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083614/denoising_algo_sd3.png)_Fig 20: Denoising Algorithm(Reverse Diffusion Process) of SD3.5 code snippet_\nHere, we can see that inside the denoising loop, the transformer model gives predicted noise as output, which is then chunked to generate two noises: predicted unconditional noise and predicted textual noise. Finally, latent(t-1) is generated using the scheduler and latent from the previous (t) timestamp.\n# Inference with Stable Diffusion 3.5 Large Turbo, Large, Medium\n[![Hardware or GPU requirements for each Stable Diffusion 3.5 model along with GPU requirements for FLUX models also.](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083613/hardware_requirements_sd3-1024x603.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083613/hardware_requirements_sd3.png)_Fig 21: Hardware Requirements for various SD models_\n**Download Code** To easily follow along this tutorial, please download code by clicking on the button below. It's FREE!\n[Download Code](javascript:void\\(0\\))\nIn the image above, **Stability AI** has outlined the compatibility of various models with different GPU architectures.\nNext, let’s explore the inference process and closely examine the inference script.\nBefore we proceed, let’s look at GPU consumption and usage during the inference process. We have set up an instance with one A6000 GPU with a maximum memory capacity of **48GB.**\n[![Nvidia A6000 GPU usage and Consumption in inferencing Stable Diffusion 3.5 Large Turbo](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083612/watch_nvidia-smi.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083612/watch_nvidia-smi.png)_Fig 22: Single Nvidia GPU A6000 Consumption and Usage_\nFollowing are the dependencies(like [diffusers](https://learnopencv.com/ai-art-generation-tools/ \"diffusers\")) that we need to install for the Stable Diffusion 3.5 Large Turbo module.  \n|  1 2 3 4 5  |  `!pip install ``-``U diffusers` `!pip install transformers` `!pip install accelerate` `!pip install sentencepiece` `!pip install protobuf`  |  \n| --- | --- |  \nNext, we import the necessary functions and create a pipeline for our Stable Diffusion 3.5 Large Turbo Model, which only requires the Model ID and Torch Dtype as arguments.  \n|  1 2  |  `import` `torch` `from` `diffusers ``import` `StableDiffusion3Pipeline`  |  \n| --- | --- |  \nNow, let’s create an instance of Pipeline and call Stable Diffusion 3.5 Large Turbo Model.  \n|  1 2 3  |  `pipe ``=` `StableDiffusion3Pipeline.from_pretrained(``\"stabilityai/stable-diffusion-3.5-large-turbo\"``, torch_dtype ``=` `torch.bfloat16)` `pipe ``=` `pipe.to(``\"cuda\"``)`  |  \n| --- | --- |  \nA manual seed is defined to ensure that every time we run the sample.\n  1. The Number of Inference Steps: Intermediate Latents are generated before reaching the final output.\n  2. The Guidance Scale: The degree to which we want our model to adhere to the [prompt](https://learnopencv.com/instructpix2pix/ \"prompt\"). A value of 0 means the model will generate a sample based on the prompt but will be flexible in its generation, thereby not strictly adhering to it.\n\n\nFinally, let us use the pipeline instance to create our synthesized image of a Capybara.  \n|  1 2 3 4  |  `torch.manual_seed(``1``)` `image ``=` `pipe(``\"cute capybara holding a card on which 'HELLO WORLD' is written\"``, num_inference_steps ``=` `30``, guidance_scale ``=` `0.0``).images[``0``]` `image.save(``\"capybara.png\"``)`  |  \n| --- | --- |  \n[![Sample Image of a Capybara generated from Stable Diffusion 3.5 Large Turbo ](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083558/capybara.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083558/capybara.png)_Fig 23: Capybara sample image_\n# Comparison of Stable Diffusion 3.5 Large Turbo and Flux Schnell\n**Model similarities and differences overview**\n  * The **Flux Schnell** model is a **12B parameter** model, whereas the **SD3.5 large-turbo** model is an **8.1B parameter** model.\n  * Typically, the number of inference steps for Flux Schnell ranges between 3-6; for SD3.5 large-turbo, it’s fixed to 20.\n  * The Guidance Scale for both models is set to 0. However, the Flux Schnell model does not explicitly require a guidance scale parameter in its pipeline.\n  * When a pipeline is instantiated, we can define another parameter called ‘negative prompt.’ This tells an AI diffusion model to avoid generating specific elements or characteristics in its output. The vital thing to notice is that the Flux Schnell model is not designed to provide negative prompts in its pipeline. At the same time, in Stable Diffusion 3.5, users can pass this parameter if they want the model to avoid certain practices while generating a sample.\n  * If you are interested to know more about Flux models, do visit our another article [Flux Image Generation.](https://learnopencv.com/flux-ai-image-generator/ \"Flux Image Generation.\")\n\n[![vincent van gogh's starry night painting artistic style generation with Batman modification](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083551/batman_image_comparison-1024x705.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083551/batman_image_comparison.png)_Fig 24: Batman in Starry Night art by**Van Gogh**_\n* * *\n[![Red-Green color dragon set in a cloudy and mountainous place style generation ](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083549/dragon_image_comparison-1024x702.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083549/dragon_image_comparison.png)_Fig 25 Dragon with green wings in a cloudy and mountainous place_\n* * *\n[![Portrait of a woman giving talk and working at Google tech style generation ](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083548/portrait_image_comparison-1024x706.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083548/portrait_image_comparison.png)_Fig 26: Portrait of a woman at Google tech conference_\n* * *\n[![mona lisa original portrait style generation ](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083546/mona_lisa_image_comparison-1-1024x598.png)](https://cdn.learnopencv.com/wp-content/uploads/2024/11/04083546/mona_lisa_image_comparison-1.png)_Fig 27:**Mona Lisa** by Da Vinci_\n# Conclusion \nThis article takes a walk through a wide variety of concepts like latent diffusion, flow matching, etc., in a very informative manner, covering final loss mathematical equations, elaborative explanations of code blocks, etc.\nTo summarize this article, we covered:\n  1. Diffusion and its Training and Sampling Algorithm.\n  2. Latent Diffusion Models and their Architecture.\n  3. Probability Path and Flow Matching.\n  4. The most efficient path for diffusion models to follow.\n  5. Stable Diffusion models and their architecture.\n  6. Inference code blocks.\n  7. Sample comparison between Flux Schnell and SD3.5 Large Turbo.\n\n\nGenerative AI has opened up many research opportunities, especially diffusion models, as their practical applications keep increasing daily, ranging from commercial content creation to artistic innovation.\nHappy Learning 🙂\n# References\n  * [Stability AI](https://stability.ai/news/introducing-stable-diffusion-3-5 \"Stability AI\")\n  * [DDPM: Theory to Implementation](https://learnopencv.com/denoising-diffusion-probabilistic-models/ \"DDPM: Theory to Implementation\")\n  * [SD3.5 source code](https://github.com/Stability-AI/sd3.5/blob/main/sd3_impls.py#L53 \"SD3.5 source code\")\n  * [Scaling Rectified Flow Transformers](https://arxiv.org/pdf/2403.03206 \"Scaling Rectified Flow Transformers\")\n  * [Flow Matching Paper Explanation](https://www.youtube.com/watch?v=7NNxK3CqaDk&t=2819s \"Flow Matching Paper Explanation\")\n  * [Flow-Based Deep Generative Models](https://lilianweng.github.io/posts/2018-10-13-flow-models/ \"Flow Based Deep Generative Models\")\n  * [Introduction to Flow Matching](https://mlg.eng.cam.ac.uk/blog/2024/01/20/flow-matching.html \"Introduction to Flow Matching \")\n  * [Review: Adaptive Layer Normalization](https://sh-tsang.medium.com/review-adanorm-adaptive-normalization-73865be8d522 \"Review: Adaptive Layer Normalization\")\n  * [Model Quantization](https://medium.com/@rakeshrajpurohit/model-quantization-with-hugging-face-transformers-and-bitsandbytes-integration-b4c9983e8996 \"Model Quantization\")\n  * [Hugging Face Documentation: Pipeline](https://huggingface.co/docs/diffusers/en/using-diffusers/loading \"Hugging Face Documentation: Pipeline\")\n  * [Flow Matching in Latent Space](https://vinairesearch.github.io/LFM/ \"Flow Mactching in Latent Space\")\n  * [The Latent: Code The Math](https://magic-with-latents.github.io/latent/ddpms-series.html \"The Latent: Code The Maths\")\n\n\nWas This Article Helpful?\nPost Views: 145\n## Subscribe & Download Code\nIf you liked this article and would like to download code (C++ and Python) and example images used in this post, please [click here](javascript:void\\(0\\)). In our newsletter, we share Computer Vision and AI tutorials and examples written in C++/Python, and Computer Vision and Machine Learning algorithms and news.  \n  \n\n[ Download Example Code](javascript:void\\(0\\))\n  \n  \n\n[PrevPreviousLightRAG: Simple and Fast Alternative to GraphRAG for Legal Doc Analysis](https://learnopencv.com/lightrag/)\n[NextThe Annotated NeRF – Training on Custom Dataset from Scratch in PytorchNext](https://learnopencv.com/annotated-nerf-pytorch/)\n###  [ Train RF-DETR for Instance Segmentation with GPT-6 Astra ](https://learnopencv.com/astra-rf-detr-microduck-segmentation/)\nBefore a flight, I left Astra a short prompt and a signed-in Roboflow account. It\n###  [ How 10x AI Engineers Train Models for Production: Lessons from PINTO’s Face Alignment Project ](https://learnopencv.com/how-10x-ai-engineers-train-models-for-production/)\nLearn a production model training playbook from PINTO’s face alignment project: reframe the task, engineer\n###  [ VGGT vs. VGGT-Ω (VGGT-Omega): A Complete Guide to Feed-Forward 3D Reconstruction ](https://learnopencv.com/vggt-vs-vggt-%cf%89-vggt-omega-a-complete-guide-to-feed-forward-3d-reconstruction/)\nHow VGGT and VGGT-Ω work, what changed, and real benchmark numbers, speed, GPU memory, depth,\n![Satya Mallick](https://opencv.org/university/wp-content/uploads/sites/4/2023/04/Dr-Satya.jpg)\n#### Satya Mallick, Ph.D.\nFounder - Big Vision & LearnOpenCV\n#####  Are you struggling with your Computer Vision Product Development?\nHelping startups and enterprises build and deploy scalable solutions that work in the real world.\n[ Schedule a Call ](https://bigvision.ai/expert-ai-solution-builders?utm_source=lopcv&utm_medium=post)\n####  Table of Contents\n  1. [What is diffusion, and how does it work?](https://learnopencv.com/stable-diffusion-3/#aioseo-defining-diffusion-and-variants-and-the-reason-for-this-nomenclature)\n  2. [Latent Diffusion](https://learnopencv.com/stable-diffusion-3/#aioseo-latent-diffusion)\n  3. [Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-stable-diffusion)\n  4. [Flow Matching for Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-flow-matchingaioseo-flow-matching)\n  5. [Timestamp Sampling used in Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-timestamp-sampling)\n  6. [The architecture of Stable Diffusion 3.5](https://learnopencv.com/stable-diffusion-3/#aioseo-architecture)\n  7. [Inference with Stable Diffusion 3.5 Large Turbo, Large, Medium](https://learnopencv.com/stable-diffusion-3/#aioseo-inference-with-sd-3-5-large-turbo-large-medium)\n  8. [Comparison of Stable Diffusion 3.5 Large Turbo and Flux Schnell](https://learnopencv.com/stable-diffusion-3/#aioseo-comparison-of-sd3-5-large-turbo-with-flux-schnell)\n  9. [Conclusion ](https://learnopencv.com/stable-diffusion-3/#aioseo-conclusion)\n  10. [References](https://learnopencv.com/stable-diffusion-3/#aioseo-references)\n\n\nWas This Article Helpful?\n  * [attention mechanism](https://learnopencv.com/tag/attention-mechanism/), [conditional ddpm](https://learnopencv.com/tag/conditional-ddpm/), [Conditional Flow Matching](https://learnopencv.com/tag/conditional-flow-matching/), [cross attention mechanism](https://learnopencv.com/tag/cross-attention-mechanism/), [denoising diffusion probabilistic models](https://learnopencv.com/tag/denoising-diffusion-probabilistic-models/), [denoising diffusion probabilistic models tutorial](https://learnopencv.com/tag/denoising-diffusion-probabilistic-models-tutorial/), [diffusion generative model](https://learnopencv.com/tag/diffusion-generative-model/), [diffusion model](https://learnopencv.com/tag/diffusion-model/), [diffusion models explained](https://learnopencv.com/tag/diffusion-models-explained/), [Diffusion Transformers](https://learnopencv.com/tag/diffusion-transformers/), [flow matching](https://learnopencv.com/tag/flow-matching/), [generative ai](https://learnopencv.com/tag/generative-ai/), [image sample generation](https://learnopencv.com/tag/image-sample-generation/), [joint attention](https://learnopencv.com/tag/joint-attention/), [modulated attention](https://learnopencv.com/tag/modulated-attention/), [Optimal Transport](https://learnopencv.com/tag/optimal-transport/), [stable diffusion models](https://learnopencv.com/tag/stable-diffusion-models/), [Transformers](https://learnopencv.com/tag/transformers/)\n\n\n## Read Next\n[ ![Decoding Virat Kohli’s Flick Shot: AI-Based 3D Motion Reconstruction](https://cdn.learnopencv.com/wp-content/uploads/2026/07/16015539/decoding-virat-kohli-flick-shot-3d-motion-reconstruction.png) ](https://learnopencv.com/decoding-virat-kohlis-flick-shot-ai-based-3d-motion-reconstruction/)\n[3D Computer Vision](https://learnopencv.com/category/3d-computer-vision/)[3D Reconstruction](https://learnopencv.com/category/3d-computer-vision/3d-reconstruction/)[Segmentation](https://learnopencv.com/category/segmentation/)[SpatialAI-Depth](https://learnopencv.com/category/3d-computer-vision/spatialai-depth/)[Video Analysis](https://learnopencv.com/category/video-analysis/)\n[Adnan Shaikh](https://learnopencv.com/author/adnan/) July 18, 2026 \n##  [ Decoding Virat Kohli’s Flick Shot: AI-Based 3D Motion Reconstruction ](https://learnopencv.com/decoding-virat-kohlis-flick-shot-ai-based-3d-motion-reconstruction/)\nReconstruct the 3D swing plane of Virat Kohli's flick shot from a single 2D video with off-the-shelf vision models. No…\n[ ![How to Run Object Detection with OpenCV 5](https://cdn.learnopencv.com/wp-content/uploads/2026/07/11002616/OpenCV_5_Blog_Thumbnail_final-scaled.jpg) ](https://learnopencv.com/how-to-run-object-detection-with-opencv-5/)\n[Object Detection](https://learnopencv.com/category/object-detection/)[OpenCV 5](https://learnopencv.com/category/opencv/opencv-5/)[OpenCV DNN](https://learnopencv.com/category/opencv-dnn/)[YOLO](https://learnopencv.com/category/yolo/)\n[Sudip Chakrabarty](https://learnopencv.com/author/sudip/) July 9, 2026 \n##  [ How to Run Object Detection with OpenCV 5 ](https://learnopencv.com/how-to-run-object-detection-with-opencv-5/)\nLearn about the new OpenCV 5 and how to use its DNN engine to run object detection models on the…\n[ ![How to Fine-Tune YOLO26 for Safety Gear and Sign Language Detection](https://cdn.learnopencv.com/wp-content/uploads/2026/06/17235330/YOLO26_Finetuning_Thumbnail_image-768x512.jpg) ](https://learnopencv.com/how-to-fine-tune-yolo26-for-safety-gear-and-sign-language-detection/)\n[Computer Vision](https://learnopencv.com/category/computer-vision/)[Object Detection](https://learnopencv.com/category/object-detection/)[YOLO](https://learnopencv.com/category/yolo/)\n[Sudip Chakrabarty](https://learnopencv.com/author/sudip/) June 18, 2026 \n##  [ How to Fine-Tune YOLO26 for Safety Gear and Sign Language Detection ](https://learnopencv.com/how-to-fine-tune-yolo26-for-safety-gear-and-sign-language-detection/)\nLearn how to fine-tune YOLO26 on your own data. We build a construction PPE safety detector and a sign-language reader…\n##  Subscribe to our Newsletter\nSubscribe to our email newsletter to get the latest posts delivered right to your email.\nName \nEmail \nSend\n![](https://cdn.learnopencv.com/wp-content/uploads/2025/12/04080755/learnOpenCV_by_bigvision1.png)\nEmpowering innovation through education, LearnOpenCV provides in-depth tutorials, code, and guides in AI, Computer Vision, and Deep Learning. Led by Dr. Satya Mallick, we're dedicated to nurturing a community keen on technology breakthroughs.\n[ Read More ](https://learnopencv.com/about/)\nCategories\n  * [Deep Learning](https://learnopencv.com/category/deep-learning/)\n  * [Object Detection](https://learnopencv.com/category/object-detection/)\n  * [Image Classification](https://learnopencv.com/category/image-classification)\n  * [YOLO](https://learnopencv.com/category/yolo/)\n  * [Image Processing](https://learnopencv.com/category/image-processing/)\n  * [Image Segmentation](https://learnopencv.com/category/image-segmentation/)\n\n\n  * [Deep Learning](https://learnopencv.com/category/deep-learning/)\n  * [Object Detection](https://learnopencv.com/category/object-detection/)\n  * [Image Classification](https://learnopencv.com/category/image-classification)\n  * [YOLO](https://learnopencv.com/category/yolo/)\n  * [Image Processing](https://learnopencv.com/category/image-processing/)\n  * [Image Segmentation](https://learnopencv.com/category/image-segmentation/)\n\n\nGetting Started\n  * [Installation](https://learnopencv.com/category/install/)\n  * [PyTorch](https://learnopencv.com/learn-pytorch/)\n  * [Getting Started with OpenCV](https://learnopencv.com/getting-started-with-opencv/)\n  * [Keras & Tensorflow](https://learnopencv.com/learn-keras-and-tensorflow/)\n\n\n  * [Installation](https://learnopencv.com/category/install/)\n  * [PyTorch](https://learnopencv.com/learn-pytorch/)\n  * [Getting Started with OpenCV](https://learnopencv.com/getting-started-with-opencv/)\n  * [Keras & Tensorflow](https://learnopencv.com/learn-keras-and-tensorflow/)\n\n\nBig Vision\n  * [AI Consulting](https://bigvision.ai/expert-ai-solution-builders/#talk?utm_source=locv&utm_medium=footer)\n  * [Case Studies](https://bigvision.ai/case-studies/?utm_source=locv&utm_medium=footer)\n  * [Get in Touch](https://bigvision.ai/contact-us/?utm_source=locv&utm_medium=footer)\n\n\n  * [AI Consulting](https://bigvision.ai/expert-ai-solution-builders/#talk?utm_source=locv&utm_medium=footer)\n  * [Case Studies](https://bigvision.ai/case-studies/?utm_source=locv&utm_medium=footer)\n  * [Get in Touch](https://bigvision.ai/contact-us/?utm_source=locv&utm_medium=footer)\n\n\nCopyright © 2026 – BIG VISION LLC [Privacy Policy](https://learnopencv.com/privacy-policy/) [Terms and Conditions](https://learnopencv.com/terms-and-conditions/)\n  * [ ](https://bit.ly/Facebook_LearnOpenCV)\n  * [ ](https://www.instagram.com/learnopencv/)\n  * [ ](https://www.linkedin.com/in/satyamallick/)\n  * [ ](https://x.com/LearnOpenCV)\n  * [ ](https://www.youtube.com/c/LearnOpenCV?utm_source=lopcv&utm_medium=footer&utm_campaign=yt)\n\n\n[ ![](https://learnopencv.com/wp-content/uploads/2021/10/cropped-favicon-512x512-1.png) Click here to download the source code to this post ](javascript:void\\(0\\))\n",
  "body_base_path": "attachments/15a979e6487d/pages/",
  "body_markdown_path": "attachments/15a979e6487d/pages/archived-body.md",
  "local_html": "attachments/15a979e6487d/pages/archived-body.html",
  "body_source": "prior_capture"
}