赞
踩
环境相关下载 python(文档推荐:Install Python 3.10.6 (Newer version of Python does not support torch)) https://www.python.org/downloads/ git-win https://git-scm.com/download CUDA(根据电脑配置选择) https://developer.nvidia.com/cuda-toolkit nvidia驱动(根据电脑配置选择) https://www.nvidia.com/Download/index.aspx 项目部署相关下载 项目(具体部署以此项目文档为准) https://github.com/AUTOMATIC1111/stable-diffusion-webui 汉化(操作流程参考此项目文档) https://github.com/VinsonLaro/stable-diffusion-webui-chinese 模型(本示例选择:sd-v1-4.ckpt) https://huggingface.co/CompVis/stable-diffusion-v-1-4-original 备注: 环境安装查看其他文档
- 模型配置
- 复制到:stable-diffusion-webui\models\Stable-diffusion目录
- webui-user.bat配置(根据情况添加)
- set COMMANDLINE_ARGS= --api --no-half
-
- cmd运行:webui-user.bat
-
- 备注:
- --api 开启sdapi
- gui地址:http://127.0.0.1:7860/
- api-docs地址:http://127.0.0.1:7860/docs
- 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')
-
-
- from diffusers import StableDiffusionPipeline
-
- ### 环境使用SD2
-
- model_id = "alibaba-pai/pai-diffusion-artist-large-zh"
- pipe = StableDiffusionPipeline.from_pretrained(model_id)
- pipe = pipe.to("cuda")
-
- prompt = "云环绕群山和中国宫殿,阳光,湖泊,俯瞰,俯瞰,虚幻的引擎,灯光效果,梦想,格雷格·鲁特考斯基,詹姆斯·格尼,艺术站"
- image = pipe(prompt).images[0]
- image.save("result.png")
- show('result.png')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。