一、midjourney是什么?

midjourney 是一款AI绘画工具,输入描述自动生成图片。

二、使用步骤

1.安装anaconda

安装之前先在cmd里输入conda看下有没有安装过,没有的话安装一下
安装完成之后,在安装目录下找到.condarc文件,修改文件里的内容,直接覆盖

channels:
 - defaults
show_channel_urls: true
default_channels:
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
 conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
 simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

完成后输入 conda clean -i清除索引缓存,确保使用的是镜像站地址

2.设置python

conda create --name stable-diffusion-webui python=3.10.6

创建python环境
升级pip

python -m pip install --upgr2ade pip

如果出现报错:
AttributeError: 'HTTPResponse' object has no attribute 'strict'
就重新设置下载镜像

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

3.安装git

4.安装cuda

先查看电脑中cuda版本

nvidia-smi

在这里插入图片描述

根据版本下载对应的cuda
官网地址:https://developer.nvidia.com/cuda-toolkit-archive
在这里插入图片描述

5.下载stable diffusion源码

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

这里拉取代码时间可能比较长

进入到stable diffusion项目里,使用conda activate激活环境,如果出现报错usage error就执行conda init
在这里插入图片描述
在当前项目目录下,执行webui-user.bat

如果出现报错RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check
就在webui-user.bat文件里 第11行 加上

set COMMANDLINE_ARGS=--skip-torch-cuda-test

如果出现报错stderr: ERROR: Ignored the following versions that require a different python version: 1.6.2 Requires-Python >=3.7,< 3.10; 1.6.3 Requires-Python >=3.7,< 3.10; 1.7.0 Requires-Python >=3.7,< 3.10; 1.7.1 Requires-Python >=3.7,< 3.10 ERROR: Could not find a version that satisfies the requirement tb-nightly (from versions: none) ERROR: No matching distribution found for tb-nightly
重点是后面报错里表示了 tb-nightly没有相关匹配分布
换成阿里的源

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple

之后再重新执行 webui-user.bat

6.开始画图

成功执行bat会自动跳转到127.0.0.1:7860页面上
在这里插入图片描述
左边输入照片描述,点击右边的Generate即可生成图片

在这里插入图片描述
执行生成图片的时候如果报错
SafetensorError: Error while deserializing header: MetadataIncompleteBuffer
解决方式:
下载https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/main 中v1-5-pruned-emaonly.ckpt
从下面的地址下载ckpt文件,并保存至…\models\Stable-diffusion:

复制完之后 bat重新执行下
再次执行

如果报错
RuntimeError: "LayerNormKernelImpl" not implemented for 'Half'
那就在执行bat时候添加 webui.bat --precision full –no-half
如果上述没有用,就给webui-user.bat文件里加上–no-half

set COMMANDLINE_ARGS= --skip-torch-cuda-test --no-half

然后重新启动bat
这样就可以自己画图啦^^
在这里插入图片描述

总结

第一次使用midjourney画出的图都比较写实,不太清楚怎么才能画出卡通图片~~

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐