Stable Diffusion Windows 部署简单认知

这篇具有很好参考价值的文章主要介绍了Stable Diffusion Windows 部署简单认知。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

写在前面


  • 偶然看到,简单了解
  • 博文为 SD 部署,以及简单使用,部署过程遇到问题解决
  • 理解不足小伙伴帮忙指正

对每个人而言,真正的职责只有一个:找到自我。然后在心中坚守其一生,全心全意,永不停息。所有其它的路都是不完整的,是人的逃避方式,是对大众理想的懦弱回归,是随波逐流,是对内心的恐惧 ——赫尔曼·黑塞《德米安》


Stable Diffusion 是一个先进文本转图像模型,可使用基本的自然语言提示创作复杂的作品

部署

安部署教程来自:

https://www.youtube.com/watch?v=onmqbI5XPH8&t=55s

下载并运行 Stable Diffusion 来从文本描述生成图像。

  • Stable Diffusion web demo: https://huggingface.co/spaces/stabilityai/stable-diffusion
  • Install Git: https://git-scm.com/download/win
  • Install Python: https://www.python.org/downloads/release/python-3106/
  • Stable Diffusion WebUI GitHub page: https://github.com/AUTOMATIC1111/stable-diffusion-webui
  • Command to download Stable Diffusion WebUI repository:
    Git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
  • Download model / checkpoint: https://huggingface.co/runwayml/stable-diffusion-v1-5
  • Overview of different models: https://stable-diffusion-art.com/models/
  • Command to update Stable Diffusion WebUI automatically:
    Git pull

Git 下载

https://git-scm.com/downloads

window 命令行下载


PS C:\Users\NUC> winget install --id Git.Git -e --source winget
已找到 Git [Git.Git] 版本 2.43.0
此应用程序由其所有者授权给你。
Microsoft 对第三方程序包概不负责,也不向第-三方程序包授予任何许可证。
正在下载 https://github.com/git-for-windows/git/releases/download/v2.43.0.windows.1/Git-2.43.0-64-bit.exe
  ██████████████████████████████  58.0 MB / 58.0 MB
已成功验证安装程序哈希
正在启动程序包安装...
已成功安装
PS C:\Users\NUC>

添加系统环境变量 C:\Program Files\Git\bin

C:\Program Files\Git\bin

关闭终端重新打开测试

PS C:\Users\NUC> git --version
git version 2.43.0.windows.1

Python 安装

https://www.python.org/downloads/release/python-3106/

window 命令行下载

PS C:\Users\NUC> winget install --id Python.Python.3.10 -e --source winget
已找到 Python 3.10 [Python.Python.3.10] 版本 3.10.11
此应用程序由其所有者授权给你。
Microsoft 对第三方程序包概不负责,也不向第三方程序包授予任何许可证。
正在下载 https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe
  ██████████████████████████████  27.6 MB / 27.6 MB
已成功验证安装程序哈希
正在启动程序包安装...
已成功安装
PS C:\Users\NUC>

添加系统环境变量

C:\Users\NUC\AppData\Local\Programs\Python\Python310

关闭终端重新打开测试

PS C:\Users\NUC> python --version
Python 3.10.11
PS C:\Users\NUC>

部署项目

克隆项目 git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui

更新 pip

PS C:\Users\NUC\Documents\GitHub\stable-diffusion-webui> C:\Users\NUC\Documents\GitHub\stable-diffusion-webui\venv\Scripts\python.exe -m pip install --upgrade pip

设置全局的 pip 源


PS C:\Users\NUC\Documents\GitHub\stable-diffusion-webui> pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Writing to C:\Users\NUC\AppData\Roaming\pip\pip.ini

运行部署脚本(需要科学上网)

PS C:\Users\NUC\Documents\GitHub\stable-diffusion-webui> .\webui-user.bat

命令行下载基础模型

PS C:\Users\NUC\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion> wget -O v1-5-pruned-emaonly.ckpt  https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt

PS C:\Users\NUC\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion> wget -O v1-5-pruned.ckpt https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned.ckpt

报错解决

OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.

解决办法:

http://www.chen-studio.com/archives/128.html

git clone https://huggingface.co/openai/clip-vit-large-patch14

huggingface 模型库命令行工具安装

部分模型需要在 huggingface 下载,一直下载不下来,后来登录了发现可以了

操作步骤

pip install huggingface_hub
You already have it if you installed transformers or datasets

huggingface-cli login
Log in using a token from huggingface.co/settings/tokens
Create a model or dataset repo from the CLI if needed
huggingface-cli repo create repo_name --type {model, dataset, space}

下载

PS C:\Users\NUC\Documents\GitHub\stable-diffusion-webui> pip install huggingface_hub
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

登录(需要提前使用谷歌账户注册)

PS C:\Users\NUC\Documents\GitHub\stable-diffusion-webui> huggingface-cli login

    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|

    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token can be pasted using 'Right-Click'.
Token:
Add token as git credential? (Y/n) Y
Token is valid (permission: read).
Your token has been saved in your configured git credential helpers (manager).
Your token has been saved to C:\Users\NUC\.cache\huggingface\token
Login successful
PS C:\Users\NUC\Documents\GitHub\stable-diffusion-webui>

前端页面报错 Expecting value: line 1 column 1 (char 0)

解决办法

https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/14037

上面的 issues 找到了解决办法


git pull
@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=  --xformers --no-gradio-queue

call webui.bat

启动脚本添加参数 : --xformers --no-gradio-queue

pip 下载报错

修改脚本部分代码,添加 pip 源,或者修改全局配置

C:\Users\NUC\Documents\GitHub\stable-diffusion-webui\modules\launch_utils.py

添加国内 pip 镜像,同时把科学上网关掉

下面为修改后的代码

index_url_line = f' --index-url {index_url}' if index_url != '' else ' -i https://pypi.tuna.tsinghua.edu.cn/simple'

这里希望直接使用可以直接下载封装好的包,不过没有试过

https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/tag/v1.0.0-pre

使用测试

运行启动脚本

PS C:\Users\NUC\Documents\GitHub\stable-diffusion-webui> .\webui-user.bat
venv "C:\Users\NUC\Documents\GitHub\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Version: v1.6.1
Commit hash: 4afaaf8a020c1df457bcf7250cb1c7f609699fa7
current transparent-background 1.2.9
Installing SD-CN-Animation requirement: scikit-image
Installing sd-webui-controlnet requirement: mediapipe
Installing sd-webui-controlnet requirement: svglib
Installing sd-webui-controlnet requirement: fvcore
Launching Web UI with arguments: --xformers --no-gradio-queue
dirname:  C:\Users\NUC\Documents\GitHub\stable-diffusion-webui\localizations
localizations:  {'zh_CN': 'C:\\Users\\NUC\\Documents\\GitHub\\stable-diffusion-webui\\extensions\\stable-diffusion-webui-localization-zh_CN\\localizations\\zh_CN.json'}
2023-12-19 03:19:35,825 - ControlNet - INFO - ControlNet v1.1.419
ControlNet preprocessor location: C:\Users\NUC\Documents\GitHub\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads
2023-12-19 03:19:36,090 - ControlNet - INFO - ControlNet v1.1.419
Loading weights [cc6cb27103] from C:\Users\NUC\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.ckpt
*Deforum ControlNet support: enabled*
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 55.0s (prepare environment: 41.1s, import torch: 4.8s, import gradio: 2.1s, setup paths: 2.0s, initialize shared: 0.2s, other imports: 1.6s, setup codeformer: 0.2s, list SD models: 0.3s, load scripts: 1.8s, create ui: 0.8s, gradio launch: 0.2s).
Creating model from config: C:\Users\NUC\Documents\GitHub\stable-diffusion-webui\configs\v1-inference.yaml
Applying attention optimization: xformers... done.
Model loaded in 11.8s (load weights from disk: 5.4s, create model: 0.3s, apply weights to model: 2.3s, apply half(): 1.9s, load VAE: 0.2s, calculate empty prompt: 1.7s).

当前界面安装了一些插件,所以展示这样的,默认为橘黄色

Stable Diffusion Windows 部署简单认知,AI认知HarmonyOS笔记,windows

模型获取网站:

https://civitai.com/models

Stable Diffusion Windows 部署简单认知,AI认知HarmonyOS笔记,windows

简单测试

Stable Diffusion Windows 部署简单认知,AI认知HarmonyOS笔记,windows

Stable Diffusion Windows 部署简单认知,AI认知HarmonyOS笔记,windows

常见的正向反向提示词

反向:

DeepNegative,EasyNegativeV2,bad-hands-5,bad_prompt_version2,deformed,missing limbs,amputated,disfigured,poorly drawn face,mutation,mutated,ugly,disgusting,oversaturated,doubled face,b&w,black and white,sepia,freckles,no masks,duplicate image,paintings,sketches,(worst quality:2),(low quality:2),(normal quality:2),lowres,monochrome,grayscale,bad anatomy,(fat:1.2),tilted head,bad hands,error,missing fingers,extra digit,fewer digits,cropped,blurry,bad feet,jpeg (artifacts:1.2),
canvas frame, (high contrast:1.2), (over saturated:1.2), (glossy:1.1), ((disfigured)), ((bad art)), ((b&w)), blurry, ((bad anatomy)), (((bad proportions))), ((extra limbs)), cloned face, (((disfigured))), extra limbs, (bad anatomy), gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutated hands, (fused fingers), (too many fingers), (((long neck))), photoshop, video game, ugly, tiling, poorly drawn hands, (nsfw:1.2), nude, naked, pink nipples

正向:

high quality 3d rendering high resolution raytracing  
(front focus),(in the dark:1.6), 
(masterpiece:1.1),(highest quality:1.1),(HDR:1),ambient light,ultra-high quality,( ultra detailed original illustration), 
film grain and (medium full shot:1.2) and 8K HD RAW photo 

博文部分内容参考

© 文中涉及参考链接内容版权归原作者所有,如有侵权请告知,这是一个开源项目,如果你认可它,不要吝啬星星哦 😃


什么是LoRA模型,如何使用和训练LoRA模型?你想要的都在这!:https://zhuanlan.zhihu.com/p/624230991

项目地址: https://github.com/AUTOMATIC1111/stable-diffusion-webui

部署教程地址: https://www.youtube.com/watch?v=onmqbI5XPH8&t=55s


© 2018-2023 liruilonger@gmail.com, All rights reserved. 保持署名-非商用-相同方式共享(CC BY-NC-SA 4.0)文章来源地址https://www.toymoban.com/news/detail-766437.html

到了这里,关于Stable Diffusion Windows 部署简单认知的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 本地部署 Stable Diffusion(Windows 系统)

    相对于使用整合包,手动在 Windows 系统下本地部署 Stable Diffusion Web UI(简称 SD-WebUI),更能让人了解一些事情的来龙去脉。 一、安装前置软件:Python 和 Git 1、安装 Python for windows。 下载地址 https://www.python.org/downloads/ 建议下载 3.10.6 Windows 64 位版。 安装时,请勾选“Add Python

    2024年02月11日
    浏览(33)
  • Stable-Diffusion——Windows部署教程

    参考文章:从零开始,手把手教你本地部署Stable Diffusion Webui AI绘画(非最新版) 一键脚本安装 默认环境安装在项目路径的 venv 下 安装pytorch:(正常用国内网就行) 运行核心脚本 安装依赖: 踩坑特定环境版本: 运行 模型网站: 配置网络: 在webui路径下创建openai文件夹:

    2024年02月05日
    浏览(39)
  • Windows端部署Stable Diffusion完整教程

    Python 3.10.6 Python3.10的安装方法(Windows10版本)_python3.10.10_ckirt的博客-CSDN博客 详细参见: Windows环境关于CUDA+CUDNN的安装教程_windows安装cuda和cudnn_不知名高校研究生的博客-CSDN博客 从github来取最新的SD仓库代码到本地 下载权重文件sd-v1-4.ckpt https://huggingface.co/CompVis/stable-diffusion-

    2024年02月16日
    浏览(32)
  • 【AI进阶】Stable Diffusion安装部署

    Stable Diffusion是一种潜在 扩散模型(Latent Diffusion Model) ,能够从文本描述中生成详细的图像。是目前非常热门的AI图片生成工具,在github(可下载)上开源安装在本地上使用本地GPU资源生成图片。 1.sd从github上下载解压之后,通过点击 webui-user.bat 进行启动。 🟡2.这里提示安装py

    2024年02月04日
    浏览(70)
  • Windows 部署Stable-Diffusion-WebUI

    前往Nvidia CUDA-1171 依次选择参数 Windows =》 x86_64 =》 11 =》 exe(local) (根据自身需求选择),下载并安装 版本说明:cu117这个版本可以使用,torch不支持更高版本 前置: 良好的网络环境 、 Python3.10.6+ 、 Git操作 可选操作: set http_proxy=http://127.0.0.1:1080 在CMD中使用代理 可选操作:

    2024年02月16日
    浏览(40)
  • stable diffusion(1): webui的本地部署(windows)

    一、前言 是的,现在是202308月份了,网上已经有很多打包好的工具,或者直接进一个web就能用SD的功能,但是我们作为程序员,就应该去躺坑,这样做也是为了能够有更多自主操作的空间。 像其他AI一样,先出结果才是王道,所以先不直接搞SD源码或者命令行,而是先用起来

    2024年02月14日
    浏览(31)
  • 【Stable Diffusion】在windows环境下部署并使用Stable Diffusion Web UI---通过 Conda

    本专栏主要记录人工智能的应用方面的内容,包括chatGPT、AI绘图等等; 在当今AI的热潮下,不学习AI,就要被AI淘汰;所以欢迎小伙伴加入本专栏和我一起探索AI的应用,通过AI来帮助自己提升生产力; 订阅后可私聊我获取 《从零注册并登录使用ChatGPT》《从零开始使用chatGPT的

    2024年02月04日
    浏览(38)
  • 〔AI 绘画〕Stable Diffusion 之 简单汉化和双语汉化 篇

    在上一篇文章中,我们安装好了 Stable Diffusion 开源 AI 绘画工具 但是整个页面都是英文版的,对于英文不好的同学看起来可相当的不友好 那么有没有办法对这个软件进行汉化处理呢?当然是可以的 这个软件的汉化,是通过汉化插件解决的,下载插件时一般都需要开启魔法上网

    2024年02月13日
    浏览(30)
  • AI-绘画:Stable-Diffusion部署分析

    目录 1.介绍下AI绘画(水一下) 1.1使用条件 2.工具准备和安装 2.1.工具下载 2.2.环境安装 3.Stable-Diffusion服务的启动 4.Stable-Diffusion的使用 5.模型文件 5.1模型文件下载  5.2模型文件安装 6. Stable-Diffusion优秀教程推荐 7.我的心得体会(水) 8.学习经历(水) 9.Git 的基本概念和使用方

    2024年02月11日
    浏览(60)
  • Stable diffusion ai图像生成本地部署教程

    前言 本文将用最干最简单的方式告诉你怎么将Stable Diffusion AI图像生成软件部署到你的本地环境 关于Stable Diffusion的实现原理和训练微调请看我其他文章 部署Stable Diffusion主要分为三个部分 下载模型(模型可以认为是被训练好的,生成图像的大脑) 部署Web UI(可通过浏览器访

    2024年02月04日
    浏览(38)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包