This lesson is being piloted (Beta version)

Using Stable Diffusion with SuperPOD

Overview

Teaching: 20 min
Exercises: 0 min
Questions
  • How to use Stable Diffusion model

Objectives
  • Learn how to download and install Stable Diffusion from HuggingFace

User can now access to Stable Diffusion from HuggingFace but still utilizing the power of SPOD’s A100 GPU to inference the data with any incoming prompt. The following take an example from Stable Diffusion model from HuggingFace

pip install diffusers --upgrade
from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
pipe.to("cuda")

# if using torch < 2.0
# pipe.enable_xformers_memory_efficient_attention()

prompt = "An astronaut riding a green horse"

images = pipe(prompt=prompt).images[0]

image

Key Points

  • Stable Diffusion, Prompt, HuggingFace