# 简介 本节笔记本将会涵盖一些基础性的内容,介绍如何利用现有的管线(pipeline)借助 Stable Diffusion 模型来创造和修改图片。我们也将简要一览管线内的关键组成部分,把更进一步的探究任务留给更深入介绍的一节笔记本中。特别地,我们将涵盖以下内容: - 利用 `StableDiffusionPipeline` 根据文字描述生成图片,并通过修改各个输入参数来进行探究实验 - 实操了解管线的一些关键组成部分: - 让这个模型成为“隐编码扩散模型(latent diffusion model)”的可变分自编码器(VAE) - 处理文本提示的分词器(tokenizer)和文本编码器 - UNet 模型本身 - 使用的调度器(scheduler),以及其它不同的调度器 - 使用管线的组成部分来复现采样循环 - 用Img2Im管线来编辑现有图片 - 使用inpainting管线和Depth2Img管线 ❓如果你有问题,请在 Hugging Face Discord 的 `#diffusion-models-class` 频道提出。如果你还没有 Hugging Face 的账号,你可以在这里注册:https://huggingface.co/join/discord # 配置 ```python !pip install -Uq diffusers ftfy accelerate ``` ```python # Installing transformers from source for now since we need the latest version for Depth2Img: !pip install -Uq git+https://github.com/huggingface/transformers ``` ```python import torch import requests from PIL import Image from io import BytesIO from matplotlib import pyplot as plt # We'll be exploring a number of pipelines today! from diffusers import ( StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, StableDiffusionInpaintPipeline, StableDiffusionDepth2ImgPipeline ) # We'll use a couple of demo images later in the notebook def download_image(url): response = requests.get(url) return Image.open(BytesIO(response.content)).convert("RGB") # Download images for inpainting example img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png" mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png" init_image = download_image(img_url).resize((512, 512)) mask_image = download_image(mask_url).resize((512, 512)) ``` ```python # Set device device = ( "mps" if torch.backends.mps.is_available() else "cuda" if torch.cuda.is_available() else "cpu" ) ``` # 从文本生成图像 我们先载入 Stable Diffusion 的管线,看看我们能做点什么。现有的 Stable Diffusion 模型有好多不同版本,截至本文书写时的最新版本是第2.1版。如果你想探究更旧的版本,只需要在 `model_id` 处修改即可(比如你可以试试将其改成 `CompVis/stable-diffusion-v1-4` 或从[dreambooth concepts library](https://huggingface.co/sd-dreambooth-library)选一个模型)。 ```python # Load the pipeline model_id = "stabilityai/stable-diffusion-2-1-base" pipe = StableDiffusionPipeline.from_pretrained(model_id).to(device) ``` 如果你的GPU内存不够用,这里有些办法也许可以减少内存使用: - 载入 FP16 精度的版本(但并不是所有的系统上都支持)。与此同时,在你对管线的某个特定部分实验时,你也需要把所有的张量换成 torch.float16 精度: `pipe = StableDiffusionPipeline.from_pretrained(model_id, revision="fp16", torch_dtype=torch.float16).to(device)` - 开启注意力机制切分(attention slicing)。这会牺牲一点点速度来减少GPU内存的使用: `pipe.enable_attention_slicing()` - 降低要生成的图片的尺寸 当管线加载好了以后,我们可以用以下代码去使用文字提示生成图片: ```python # Set up a generator for reproducibility generator = torch.Generator(device=device).manual_seed(42) # Run the pipeline, showing some of the available arguments pipe_output = pipe( prompt="Palette knife painting of an autumn cityscape", # What to generate negative_prompt="Oversaturated, blurry, low quality", # What NOT to generate height=480, width=640, # Specify the image size guidance_scale=8, # How strongly to follow the prompt num_inference_steps=35, # How many steps to take generator=generator # Fixed random seed ) # View the resulting image: pipe_output.images[0] ``` 0%| | 0/35 [00:00 decoded token") for input_id in input_ids[0]: print(f"{input_id} -> {pipe.tokenizer.decode(input_id)}") # Feed through CLIP text encoder input_ids = torch.tensor(input_ids).to(device) with torch.no_grad(): text_embeddings = pipe.text_encoder(input_ids)['last_hidden_state'] print("Text embeddings shape:", text_embeddings.shape) ``` Input ID -> decoded token 49406 -> <|startoftext|> 320 -> a 3086 -> painting 539 -> of 320 -> a 4062 -> floo 1059 -> ble 49407 -> <|endoftext|> Text embeddings shape: torch.Size([1, 8, 1024]) ```python # Get the final text embeddings using the pipeline's _encode_prompt function: text_embeddings = pipe._encode_prompt("A painting of a flooble", device, 1, False, '') text_embeddings.shape ``` torch.Size([1, 77, 1024]) 这些文本嵌入(text embedding),也即文本编码器中最后一个transformer模块的“隐状态(hidden state)”,将会被送入 UNet 中作为 `forward` 函数的一个额外输入,下面部分我们会详细看到。 ### UNet ![unet.png](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjEAAAEFCAYAAAASbLbSAAAAAXNSR0IArs4c6QAABVp0RVh0bXhmaWxlACUzQ214ZmlsZSUyMGhvc3QlM0QlMjJhcHAuZGlhZ3JhbXMubmV0JTIyJTIwbW9kaWZpZWQlM0QlMjIyMDIyLTEyLTE5VDA0JTNBMzMlM0E0Ny44NTVaJTIyJTIwYWdlbnQlM0QlMjI1LjAlMjAoWDExJTNCJTIwTGludXglMjB4ODZfNjQpJTIwQXBwbGVXZWJLaXQlMkY1MzcuMzYlMjAoS0hUTUwlMkMlMjBsaWtlJTIwR2Vja28pJTIwQ2hyb21lJTJGMTA3LjAuMC4wJTIwU2FmYXJpJTJGNTM3LjM2JTIyJTIwdmVyc2lvbiUzRCUyMjIwLjcuMiUyMiUyMGV0YWclM0QlMjJjWFZ5OHhoenR5WUJIc3NFeXZKbiUyMiUyMHR5cGUlM0QlMjJkZXZpY2UlMjIlM0UlM0NkaWFncmFtJTIwaWQlM0QlMjI0WTc4ZDVQQlQ1OTlxOC10cHpIeSUyMiUyMG5hbWUlM0QlMjJQYWdlLTElMjIlM0UzVmZianBzd0VQMmFTTzNEVnR4aEg1dExiMnBYcmJLcjdqNVZEcDZBVzRPUmNSTFNyJTJCOFFUSURDSnEyMDJUUjlzdWVNamNkenp0aG1aRSUyQlM0cTBrV2Z4SlVPQWp5NkRGeUo2T0xNc3lmQWViRXRsV2lPJTJGYkZSQkpSaXZJYklBNSUyQndrYU5EUzZZaFR5emtBbEJGY3M2NEtoU0ZNSVZRY2pVb3BOZDloUzhPNnFHWW1nQjh4RHd2dm9WMFpWckZIVHUyNGM3NEJGc1Y0NnNQektrWkI2c041SkhoTXFOaTNJbm8zc2lSUkNWYjJrbUFBdmsxZm5wW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JS2RpVHG1Qzdm2xI+tNUdYyuNLwXuQAAmQAAlog4DRiphH4RdCJi0zD7eyhIDIR0b23Z/MnNvIys2HEEG5eQXIzRcC5K4YEcKkQBIpdyDEihg5uXeJkR0hbsz//0cIHiF+rCzNYG1pDmsrcwgRYmdtCXsbCzjYWt79sbNEZTsrONlbSQKGFwmQAAmQAAmQgG4ETFbE6Ian9FaSiAEkISMEjBibedgIjaH3Y38SIAESIAESIIGSBChiWBEkQAIkQAIkQAKaJEARo8m00WkSIAESIAESIAGKGNYACZAACZAACZCAJglQxGgybXSaBEiABEiABEiAIoY1QAIkQAIkQAIkoEkCFDGaTBudJgESIAESIAESoIhhDZAACZAACZAACWiSAEWMJtNGp0mABEiABEiABChiWAMkQAIkQAIkQAKaJEARo8m00WkSIAESIAESIAGKGNYACZAACZAACZCAJglQxGgybXSaBEiABEiABEiAIoY1QAIkQAIkQAIkoEkCFDGaTBudJgESIAESIAESoIhhDZAACZAACZAACWiSAEWMJtNGp0mABEiABEiABChiWAMkQAIkQAIkQAKaJEARo8m00WkSIAESIAESIAGKGNYACZAACZAACZCAJgn8H2uWjx1sO5DOAAAAAElFTkSuQmCC) UNet 模型接收一个带噪的输入,并预测噪声,和我们之前单元中看到的 UNet 一样。但与以往例子不同的是,这里的输入并不是图片了,而是图片的隐式表示形式(latent representation)。此外,除了把用于暗示带噪程度的timestep输入进 UNet 作为条件外,这里模型也把文字提示(prompt)的文本嵌入(text embeddings)作为了额外输入。这里我们假数据试着让它预测一下: ```python # Dummy inputs: timestep = pipe.scheduler.timesteps[0] latents = torch.randn(1, 4, 64, 64).to(device) text_embeddings = torch.randn(1, 77, 1024).to(device) # Model prediction: with torch.no_grad(): unet_output = pipe.unet(latents, timestep, text_embeddings).sample print('UNet output shape:', unet_output.shape) # Same shape as the input latents ``` UNet output shape: torch.Size([1, 4, 64, 64]) ### 调度器(Scheduler) 调度器保存了如何加噪的计划安排,管理着如何基于模型的预测更新带噪样本。默认的调度器是 `PNDMScheduler` 调度器,但你也可以用其它的(比如 `LMSDiscreteScheduler` 调度器),只要它们用相同的配置初始化。 我们可以画出图像来观察随着timestep添加噪声的计划安排,看看不同时间的噪声水平(基于$\bar{\alpha}$这个参数)是什么样的: ```python plt.plot(pipe.scheduler.alphas_cumprod, label=r'$\bar{\alpha}$') plt.xlabel('Timestep (high noise to low noise ->)'); plt.title('Noise schedule');plt.legend(); ``` ![png](01_stable_diffusion_introduction_CN_files/01_stable_diffusion_introduction_CN_35_0.png) 如果你想尝试不同的调度器,你可以像下面代码中一样换一个新的: ```python from diffusers import LMSDiscreteScheduler # Replace the scheduler pipe.scheduler = LMSDiscreteScheduler.from_config(pipe.scheduler.config) # Print the config print('Scheduler config:', pipe.scheduler) # Generate an image with this new scheduler pipe(prompt="Palette knife painting of an winter cityscape", height=480, width=480, generator=torch.Generator(device=device).manual_seed(42)).images[0] ``` Scheduler config: LMSDiscreteScheduler { "_class_name": "LMSDiscreteScheduler", "_diffusers_version": "0.11.1", "beta_end": 0.012, "beta_schedule": "scaled_linear", "beta_start": 0.00085, "clip_sample": false, "num_train_timesteps": 1000, "prediction_type": "epsilon", "set_alpha_to_one": false, "skip_prk_steps": true, "steps_offset": 1, "trained_betas": null } 0%| | 0/50 [00:00 x_t-1 latents = pipe.scheduler.step(noise_pred, t, latents).prev_sample # Decode the resulting latents into an image with torch.no_grad(): image = pipe.decode_latents(latents.detach()) # View pipe.numpy_to_pil(image)[0] ``` ![png](01_stable_diffusion_introduction_CN_files/01_stable_diffusion_introduction_CN_40_0.png) 大多数情况下,还是使用现有的管线更方便,但我们这里手动拼装采样循环会更有益于我们理解每个部分如何工作、以及如何根据需要修改这些组件。如果你想看看实际的代码以及深入了解如何修改这些组成部分,你可以参考 Stable Diffusion Deep Dive 这个[笔记本](https://github.com/fastai/diffusion-nbs/blob/master/Stable%20Diffusion%20Deep%20Dive.ipynb)和[视频](https://m.youtube.com/watch?v=0_BBRNYInx8)。这里有对相关内容更全面彻底的探究。 # 其它的一些管线 那我们除了从文字提示生成图片外还能做点什么呢?其实还有很多!这一部分还会向你展示几个很酷的管线,让你了解一些其它的可以应用 Stable Diffusion 的任务。这里面有几个管线需要你下载新的模型,所以你要是着急的话你也可以跳过这一部分,只看看现有的输出展示就行,不必亲自下载和运行模型。 ## Img2Img 直到现在,我们生成的图片还都是完全从随机的隐变量来开始生成的,而且也都使用了完整的扩散模型采样循环。但其实我们不必从头开始。Img2Img 这个管线首先将一张已有的图片进行编码,编码成一系列的隐变量,然后在这些隐变量上随机加噪声,以这些作为起始点。噪声加多大量、去噪需要的步数决定了这个 img2img 过程的“强度”。只加一点点噪声(强度低)只会带来微小改变,而加入最大量的噪声并跑完完整的去噪过程又会生成出几乎完全不像原始图片的结果,即使可能在整体结构上还多少有点相似。 这个管线无需什么特殊模型,只要模型的 ID 和我们的文字到图像模型一样就行,没有新的需要下载的文件。 ```python # Loading an Img2Img pipeline model_id = "stabilityai/stable-diffusion-2-1-base" img2img_pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id).to(device) ``` Fetching 16 files: 0%| | 0/16 [00:00