A pipeline links stages that process data or work toward an outcome. In deep learning, it can package the parts of an inference workflow or divide a model across devices for scheduled execution. section 2.2.2 section 16.5.1
Two practical uses show how the term changes with the task:
- For inpainting, a diffusers pipeline bundles the tokenizer, text encoder, denoiser, VAE, and scheduler behind an interface that takes a prompt, image, and mask. section 2.2.2
- For pipeline parallelism, PyTorch splits a model into stages on different ranks and schedules microbatches across them; GPipe runs all forwards before backwards. section 16.5.1
- Earlier NLP systems used multistage rule-based pipelines, while later systems trained networks end to end; a segmentation-then-classification pipeline is proposed as an exercise. section 4.5 section 15.10
Inpainting a horse
Pass a horse image, a mask, and a prompt asking for a zebra replacement to the inpainting pipeline; it returns a generated image. section 2.2.2
# In[2]:
from diffusers import StableDiffusionInpaintPipeline
import torch
import PIL.Image as Image
device = "cuda" if torch.cuda.is_available() else "cpu"
pipe = StableDiffusionInpaintPipeline.from_pretrained(
"sd2-community/stable-diffusion-2-inpainting",
torch_dtype=torch.float16
).to(device)
The listing shows how to load a Stable Diffusion inpainting pipeline and move it to the selected device. section 2.2.2















































