服务器CentOS 7 安装 Stable Diffusion WebUI ,并映射到本地浏览器

目录

  • 配置环境
  • 下载安装Stable Diffusion WebUI
  • 解决安装过程的报错
    • 报错一: Couldn’t checkout {name}’s hash: {commithash}
    • 报错二:Couldn’t determine Stable Diffusion’s hash
    • 报错三:Error setting up CodeFormer
  • 使用
    • 映射到本地服务器
    • 公网访问
    • 设置中文

配置环境

  1. 创建一个python=3.10.6的环境,该环境出错几率低
conda create -n sd python=3.10.6
  1. 激活该环境
conda activate sd
  1. 切换到要安装的目录
cd ./longjs

下载安装Stable Diffusion WebUI

  1. 需要注意的是,如果按照官网的安装方式,是默认安装在 /home/$(whoami)/stable-diffusion-webui/的,如果服务器不是这种结构,则会提示错误
bash <(wget -qO- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh)
  1. ( 非默认方式安装)下载文件
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
  1. 切换到/stable-diffusion-webui/
cd stable-diffusion-webui/
  1. 运行安装文件
bash webui.sh

解决安装过程的报错

报错一: Couldn’t checkout {name}’s hash: {commithash}

  1. 报错如下
RuntimeError: Couldn't checkout {name}'s hash: {commithash}.
Command: "git" -C "/group2/longjs/stable-diffusion-webui/repositories/stable-diffusion-stability-ai" checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e
Error code: 129
stdout: <empty>
stderr: Unknown option: -C
usage: git [--version] [--help] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
  1. 该错误需要修改launch.py文件
vim launch.py
  1. 在vim 中查找-C 并替换成 --exec-path

参考GitHub社区

:%s/-C/--exec-path/g   # 查找全部-C并替换成--exec-path

报错二:Couldn’t determine Stable Diffusion’s hash

  • 由于服务器没有科学的方式,所以运行到中间,会报错,提示无法从GitHub clone 文件下来。
  • 这时候就需要从报错信息中找到缺失的文件,在其他地方手动下载并放置到相应的文件夹里。
  • 浏览器下载比较慢,可以复制下载链接通过IDM下载。
  • 缺失文件和需要的放置文件夹均会在报错信息中显示,或者直接在launch.py中查看。推荐后者,更快捷。
  • 可能的缺失文件链接如下:
  1. Stable Diffusion
  2. Taming Transformers
  3. K_diffusion
  4. CodeFormer
  5. BLIP

报错三:Error setting up CodeFormer

参考GitHub社区

下载缺失文件,更名为codeformer-v0.1.0.pth,并在/models/Codeformer中替换

使用

映射到本地服务器

webui-user.sh中添加

export COMMANDLINE_ARGS="--listen --no-half-vae --enable-insecure-extension-access"

通过xshell隧道转移到本地浏览器,目标主机为服务器公网ip,目标端口默认为7860.可添加--port 其他端口修改。

详细设置可见往期文章

设置

公网访问

webui-user.sh中添加--share

export COMMANDLINE_ARGS="--listen --no-half-vae --enable-insecure-extension-access --share"

运行webui.sh之后,即可生成一个公网链接。该链接为临时链接,有效期三天。

设置中文

  1. 打开链接,找到extensions选项卡依次点击下述选项,找到并安装zh_CN Localization中文安装包
    1
    2
  2. 回到settings选项,并找到user interface,拉到最后面,选择中文包
    3
    4
  3. 保存设置并重启UI界面
    5

enjoy it !
6

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
社会演员多的头像社会演员多普通用户
上一篇 2023年12月23日
下一篇 2023年12月23日

相关推荐