But how do AI images and videos actually work? | Guest video by Welch Labs
Overview
Stephen Welsh explains diffusion models for AI image and video generation, detailing how they work by reversing a process of adding noise to data, akin to running Brownian motion backward. He covers OpenAI's CLIP for creating a shared text-image embedding space, the DDPM algorithm's surprising need for noise during generation, and the development of DDIM and classifier-free guidance to improve generation speed and prompt adherence, culminating in models like DALL-E 2 and Stable Diffusion.
Key takeaways
- Diffusion models generate images/videos by reversing a process of adding noise, akin to running Brownian motion backward in high-dimensional space.
- OpenAI's CLIP creates a shared embedding space where text and image concepts are geometrically aligned, enabling semantic manipulation.
- Adding random noise during the generation phase of DDPM is crucial for producing sharp, diverse images, preventing collapse to the dataset's average.
- DDIM offers a deterministic, faster alternative to DDPM for image generation by solving an equivalent ordinary differential equation.
- Classifier-free guidance, by leveraging the difference between conditioned and unconditioned diffusion model outputs, dramatically improves prompt adherence and detail in generated content.
- Modern AI image/video generation relies on combining text encoders (like CLIP) with diffusion models, guided by techniques like classifier-free guidance, to translate language prompts into visual media.
Chapters
- AI image/video generation relies on diffusion, a process analogous to reversed Brownian motion in high dimensions.
- WAN 2.1, an open-source model, generates videos from text prompts, starting with random noise.
- The generation process involves a transformer iteratively refining noise into structured video over multiple steps.
- OpenAI's CLIP (2021) uses two models (text and vision) trained on 400 million image-caption pairs.
- It learns a shared high-dimensional embedding space where similar concepts (e.g., an image of a cat and its caption) are represented by vectors pointing in similar directions.
- Cosine similarity measures the angle between vectors, enabling CLIP to understand relationships like 'hat' by subtracting image vectors.
- Denoising Diffusion Probabilistic Models (DDPM) generate images by reversing a noise-addition process.
- A key finding is that adding random noise *during* generation, not just training, is crucial for high-quality results.
- DDPM models are trained to predict the total noise added to an image, effectively learning a score function pointing towards the data distribution.
- Diffusion models learn a time-varying vector field, where each point (image) is guided back to the data distribution.
- Simplifying images to 2D points on a spiral illustrates how adding noise is a random walk, and reversing it means learning to navigate back.
- Conditioning the model on time (t) allows it to learn coarse fields for high noise levels and fine structures for low noise levels.
- Adding random noise during DDPM generation prevents generated points from collapsing to the mean of the distribution, avoiding blurry results.
- The noise ensures the model samples from a distribution that approximates the true data manifold, preserving diversity.
- Without noise, generated images converge to the average, resulting in a blurry mess rather than distinct images.
- DDIM (Denoising Diffusion Implicit Models) uses an ordinary differential equation derived from DDPM's stochastic process.
- This allows high-quality image generation deterministically, without adding random noise at each step, and in fewer steps.
- DDIM requires no changes to model training but significantly speeds up generation, producing the same final distribution as DDPM.
Transcript excerpt
0:03 Over the last few years, AI systems have become astonishingly good at turning text props into videos. At the core of how these models operate is a deep connection to physics. This generation of image and video models works using a process known as diffusion, which is remarkably equivalent to the Brownian motion we see as particles diffuse, but with time run backwards, and in high-dimensional space. As we'll see, this connection to physics is much more than a curiosity. We get real algorithms out of the physics that we can use to generate images and videos. And this perspective will also give us some really nice intuitions for how these models work in practice. But before we dive into this connection, let's get hands-on with a real diffusion model. While the best models are closed source, there are some compelling open source models. This video of an astronaut was generated by an open source model called WAN 2.1.
0:57 We can add to our prompt and have our astronaut hold a flag, hold a laptop, or hold a meeting. If we cut down our prompt to just an astronaut, we get this. And if we cut down our prompt to nothing, we interestingly still get this video of a woman. If we dig into our WAN model's source code, we'll find that the video generation process begins with this call to a random number generator. Creating a video where the pixel intensity values are chosen randomly. Here's what it looks like. From here, this pure noise video is passed into a transformer. This is the same type of AI model used by large language models, like ChatGPT. But instead of outputting text, this transformer outputs another video that now looks like this. Still mostly noise, but with some hints of structure.
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, 3Blue1Brown.