Diffusion Explainer: Visual Explanation for Text-to-image Stable Diffusion

Seongmin Lee, Benjamin Hoover, Hendrik Strobelt, Zijie J. Wang, ShengYun Peng, Austin Wright, Kevin Li, Haekyu Park, Haoyang Yang, Duen Horng Chau

TL;DR

Diffusion Explainer is the first interactive visualization tool designed to demystify how Stable Diffusion transforms text prompts into high-resolution images. By bridging high-level architecture with low-level operations through fluid animations, it allows non-experts to intuitively grasp complex concepts like iterative denoising, guidance scales, and the impact of prompt variations.

What Problem Does This Paper Address?

While diffusion-based models like Stable Diffusion have taken the world by storm, they remain "black boxes" to most people. Existing explanations generally fall into two camps: high-level overviews that skip the "how," or math-heavy technical papers that are inaccessible to non-experts.

As these models begin to impact policy, copyright law, and the creative arts, there is an urgent need for a "middle ground" explanation. The authors identify a major challenge: the complex interplay between subcomponents (like the CLIP text encoder and the UNet) and the iterative nature of the refinement process are incredibly difficult to visualize and understand simultaneously.

Methods

The researchers developed a web-based tool that uses a "multi-level abstraction" approach. Instead of static diagrams, the tool uses interactive elements to let users peel back layers of the model:

  • Architecture View: Provides a top-down look at the data flow from prompt to final image. Users can click on components like the "Text Representation Generator" to see how a prompt is tokenized and converted into vectors.
  • Iterative Refinement Visualization: The tool allows users to scrub through timesteps (typically 0 to 50) to see how random noise gradually coalesces into a recognizable image.
  • Refinement Comparison View: To explain the impact of specific keywords, the tool visualizes "Evolution Trajectories." It uses UMAP (Uniform Manifold Approximation and Projection) to project high-dimensional image representations into a 2D space, showing how adding a single word like "Pixar" physically diverts the model's path during the generation process.
  • Interactive Guidance Scale: A dedicated module lets users experiment with the "guidance scale" hyperparameter, showing how it forces the image to adhere more strictly to the prompt, sometimes at the cost of visual quality.
Figure 1: With Diffusion Explainer, users can visually examine how (A) text prompt, e.g., “a cute and adorable bunny... pixar character”, is encoded by (B) the Text Representation Generator into vectors to guide (C) the Image Representation Refiner to iteratively refine the vector representation of the image being generated. (D) The Timestep Controller enables users to review the incremental improvements in image quality and adherence to the prompt over timesteps. (E) The final image representation is upscaled to a high-resolution image. Diffusion Explainer tightly integrates a visual overview of Stable Diffusion’s complex components with detailed explanations of their underlying operations, enabling users to fluidly transition between multiple levels of abstraction through animations and interactive elements (Fig. 2, Fig. 3).

Datasets

Because the tool is designed for real-time web use without requiring a GPU, the authors did not use a live model. Instead, they pre-computed data for 13 diverse prompt templates containing popular keywords (e.g., "trending on artstation," "detailed").

For evaluation, they conducted a user study with 56 non-experts recruited via Prolific. These participants were screened to ensure they had little to no prior knowledge of AI but were interested in the technology.

Key Insights and Ideas

  • Fluidity is Key to Learning: The "aha moment" for many users came from the animated transitions. By clicking a component to expand it into a detailed view, users maintained their mental map of the overall system while learning about specific operations like noise prediction.
  • Visualizing the "Path": The use of UMAP to show evolution trajectories (Figure 4 in the paper) proved highly effective. It transformed the abstract concept of "latent space" into a literal path that users could see diverging when the prompt changed.
  • Interactive Hyperparameters: Participants found the tool significantly more effective than static blog posts at explaining abstract settings like "random seed" and "guidance scale" because they could see the immediate visual consequences of changing them.
Figure 4: The Refinement Comparison View enables users to discover the impacts of prompts on image generation by comparing how image representations evolve differently over refinement timesteps, using UMAP, when guided by two related text prompts. Adding “pixar” phrase changes the generated bunny’s style to be more cartoony and vibrant in colors and textures while preserving its pose.

Key Results

The researchers compared Diffusion Explainer against a top-ranked, highly-regarded technical blog post. The results were decisive:

  • Preference: 44 out of 56 participants preferred the interactive tool over the blog post.
  • Understanding: The tool received significantly higher ratings for improving understanding of prompt modification (4.16 vs 2.86 on a 5-point scale) and guidance scales (4.29 vs 2.91).
  • Engagement: Users described the tool as "like a cool game," noting that the ability to experiment rapidly helped them grasp the intricate interaction between prompts and hyperparameters.

Limitations and Future Work

The primary limitation is the pre-computed nature of the prompts. Currently, users cannot enter their own arbitrary text because running Stable Diffusion locally in a standard browser is still too slow for a fluid educational experience.

The authors suggest that as technologies like WebGPU mature, future versions of the tool could support real-time generation. Additionally, they noted that while they simplified certain aspects (like the internal layers of the UNet) to avoid overwhelming users, future iterations could offer even deeper "zoom levels" for more advanced students.

You can explore the tool yourself at https://poloclub.github.io/diffusion-explainer/.

Summary updated

Abstract

Diffusion-based generative models' impressive ability to create convincing images has garnered global attention. However, their complex structures and operations often pose challenges for non-experts to grasp. We present Diffusion Explainer, the first interactive visualization tool that explains how Stable Diffusion transforms text prompts into images. Diffusion Explainer tightly integrates a visual overview of Stable Diffusion's complex structure with explanations of the underlying operations. By comparing image generation of prompt variants, users can discover the impact of keyword changes on image generation. A 56-participant user study demonstrates that Diffusion Explainer offers substantial learning benefits to non-experts. Our tool has been used by over 10,300 users from 124 countries at https://poloclub.github.io/diffusion-explainer/.
BibTeX
@inproceedings{lee2024diffusion,
  author = {Seongmin Lee and Benjamin Hoover and Hendrik Strobelt and Zijie J. Wang and ShengYun Peng and Austin Wright and Kevin Li and Haekyu Park and Haoyang Yang and Duen Horng Chau},
  title = {{Diffusion Explainer: Visual Explanation for Text-to-image Stable Diffusion}},
  booktitle = {IEEE VIS},
  year = {2024},
  doi = {10.1109/vis55277.2024.00027},
}
Figure