diffusers笔记

# https://github.com/huggingface/diffusers
# pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
from diffusers import DiffusionPipeline
import torch
import numpy as np
import matplotlib.pyplot as plt

print(torch.__version__)
print(torch.cuda.is_available())

pipeline = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
pipeline.to("cuda")
image = pipeline("An image of a squirrel in Picasso style").images[0]

# 假设你的image对象是一个PIL图像
image_np = np.array(image)

plt.imshow(image_np)
plt.show()

diffusers笔记_第1张图片

你可能感兴趣的:(AIGC,笔记)