赞
踩
- pip install paddlepaddle-gpu
- pip install paddlehub
- from PIL import Image
- import paddlehub as hub
- module = hub.Module(name='stable_diffusion')
-
- ## 保存在demo目录
- result = module.generate_image(text_prompts="clouds surround the mountains and Chinese palaces,sunshine,lake,overlook,overlook,unreal engine,light effect,Dream,Greg Rutkowski,James Gurney,artstation", output_dir='demo')
pip install diffusers transformers accelerate scipy safetensors
- import torch
- from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
- import matplotlib.pyplot as plt
- import matplotlib.image as mpimg
-
- def show(image_path):
- # 使用 Matplotlib 加载图片文件
- image = mpimg.imread(image_path)
-
- # 显示图片
- plt.imshow(image)
- plt.axis('off') # 关闭坐标轴
- plt.show()
-
- model_id = "stabilityai/stable-diffusion-2-1"
-
- # Use the DPMSolverMultistepScheduler (DPM-Solver++) scheduler here instead
- pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
- pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
- pipe = pipe.to("cuda")
-
-
- prompt = "clouds surround the mountains and Chinese palaces,sunshine,lake,overlook,overlook,unreal engine,light effect,Dream,Greg Rutkowski,James Gurney,artstation"
- image = pipe(prompt).images[0]
-
- image.save("test.png")
- show('test.png')
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。