需要安装conda
1.创建虚拟环境
conda create -n sd python==3.10.14
激活虚拟环境
conda activate sd
1.下载table-diffusion-webui——>解压缩
Releases · AUTOMATIC1111/stable-diffusion-webui · GitHub
2.下载git
3.进入本地路径 F:\stable-diffusion-webui-1.9.4
——————————
下载可换源
conda config --show channels
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
pip config list
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
——————————
去除以下两个依赖中torch后安装
pip install -r requirements.txt
pip install -r requirements_versions.txt
pip uninstall torch & conda install pytorch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2
pytorch-cuda=12.1 -c pytorch -c nvidia
pip uninstall charset_normalizer & pip install charset_normalizer
pip install xformers==0.0.23.post1(xformers的版本一定要和pyt cu匹配)
具体查看https://anaconda.org/xformers/xformers/files
pip install scikit-learn einops ipywidgets pandas tqdm jupyterlab matplotlib seaborn
pip uninstall pillow & pip install pillow==9.5.0
——————————————
某次安装clip遇到问题(解决)
pip install clip
git clone https://github.com/openai/CLIP.git
cd CLIP
git checkout d50d76daa670286dd6cacf3bcd80b5e4823fc8e1
pip install .
4.更改webui.bat
@echo off
REM 增加Git超时设置
git config --global http.lowSpeedLimit 1000
git config --global http.lowSpeedTime 300
git config --global core.compression 0
git config --global http.postBuffer 1048576000
if exist webui.settings.bat (
call webui.settings.bat
)
REM 直接设置Python路径
set PYTHON=D:\AnaConda\envs\sd\python.exe
REM 检查Python是否存在
if not exist %PYTHON% (
echo Python executable not found at %PYTHON%
echo Please check if the path is correct.
goto :endofscript
)
if defined GIT (set "GIT_PYTHON_GIT_EXECUTABLE=%GIT%")
set SD_WEBUI_RESTART=tmp/restart
set ERROR_REPORTING=FALSE
mkdir tmp 2>NUL
%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :check_pip
echo Couldn't launch python
goto :show_stdout_stderr
:check_pip
%PYTHON% -mpip --help >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :launch
echo Couldn't find pip. Please ensure it's installed in your Conda environment.
goto :show_stdout_stderr
:launch
echo Launching Stable Diffusion WebUI...
%PYTHON% launch.py --allow-code --medvram --xformers --enable-insecure-extension-access --api %*
if EXIST tmp/restart goto :launch
pause
exit /b
:show_stdout_stderr
echo.
echo Exit code: %errorlevel%
for /f %%i in ("tmp\stdout.txt") do set size=%%~zi
if %size% equ 0 goto :show_stderr
echo.
echo stdout:
type tmp\stdout.txt
:show_stderr
for /f %%i in ("tmp\stderr.txt") do set size=%%~zi
if %size% equ 0 goto :endofscript
echo.
echo stderr:
type tmp\stderr.txt
:endofscript
echo.
echo Launch unsuccessful. Exiting.
pause
通过脚本准备好之后
后面也可以直接运行
python webui.py --allow-code --medvram --xformers --enable-insecure-extension-access --api
5.网络错误就切梯子
double-click--->webui-user.bat(好像需要重启)
放一个不错的模型:
https://civitai.com/models/43331/majicmix-realistic