本地部署stable diffusion

本地部署stable diffusion

    正在检查是否收录...

计划本地部署stable diffusion,然后将其软件化为exe(始终认为用gradio属于原型开发,而不是部署落地)

1 一键安装包

目前比较主流的有秋叶包,提取码:xvro

2 代码开发

安装xformer

pip install xformers==0.0.20 

环境

torch 2.0.1+cu118
python 3.10.13
cuda 11.8

整个代码

 import torch import requests from PIL import Image from io import BytesIO from matplotlib import pyplot as plt # We'll be exploring a number of pipelines today! from diffusers import ( StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, StableDiffusionInpaintPipeline, StableDiffusionDepth2ImgPipeline ) # Set device device = ( "mps" if torch.backends.mps.is_available() else "cuda" if torch.cuda.is_available() else "cpu" ) # Load the pipeline model_id = "stabilityai/stable-diffusion-2-1-base" pipe = StableDiffusionPipeline.from_pretrained(model_id).to(device) # Set up a generator for reproducibility generator = torch.Generator(device=device).manual_seed(42) # Run the pipeline, showing some of the available arguments pipe_output = pipe( prompt="A passionate couple, Asia boy and girl, ", # What to generate negative_prompt="Oversaturated, blurry, low quality", # What NOT to generate height=480, width=640, # Specify the image size guidance_scale=8, # How h2ly to follow the prompt num_inference_steps=35, # How many steps to take generator=generator # Fixed random seed ) # View the resulting image: image = pipe_output.images[0] image.show() 

SDXL_DEMO
SDXLSourceCode

diffusiongeneratorstablediffusioncodepromptsdxltpustable diffusionurl代码开发cpugradio本地部署pythonguisatfix
  • 本文作者:李琛
  • 本文链接: https://wapzz.net/post-2887.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.3W+
5
0
1
WAP站长官方

ChatGPT唤醒AI游戏:AIGC持续走深,游戏或成AI最佳抓手

上一篇

Stable DiffusionAI绘画一键启动整合包

下一篇
  • 复制图片
按住ctrl可打开默认菜单