{ "cells": [ { "cell_type": "markdown", "id": "f06bea55-7889-4576-a83b-d3b207729e3d", "metadata": {}, "source": [ "# Stable Diffusion WebUI" ] }, { "attachments": {}, "cell_type": "markdown", "id": "9fab4ab6-be4b-4206-ba12-8dad73bac833", "metadata": {}, "source": [ "阿里云 DSW 一键脚本 By bilibili@秋葉aaaki\n", "\n", "#### 更新日志\n", "\n", "- 添加了部分插件(LoRA)\n", "- 添加了下载文件用的代码" ] }, { "cell_type": "markdown", "id": "39df08ff-45e4-4a86-add4-a5af9cc7f7d6", "metadata": {}, "source": [ "## 安装 第一次需要执行" ] }, { "cell_type": "code", "execution_count": null, "id": "567fe4a3-a897-48b6-bde2-0afb3d064c80", "metadata": {}, "outputs": [], "source": [ "!apt update\n", "!apt install -y aria2\n", "\n", "!git clone https://gitcode.net/overbill1683/stable-diffusion-webui\n", "%cd stable-diffusion-webui\n", "!mkdir repositories\n", "%cd repositories\n", "!git clone \"https://gitcode.net/overbill1683/stablediffusion\" \"stable-diffusion-stability-ai\"\n", "!git clone \"https://gitcode.net/overbill1683/taming-transformers\" \"taming-transformers\"\n", "!git clone \"https://gitcode.net/overbill1683/k-diffusion\" \"k-diffusion\"\n", "!git clone \"https://gitcode.net/overbill1683/CodeFormer\" \"CodeFormer\"\n", "!git clone \"https://gitcode.net/overbill1683/BLIP\" \"BLIP\"\n", "\n", "%cd /mnt/workspace/stable-diffusion-webui\n", "!wget -O \"config.json\" \"https://gitcode.net/Akegarasu/sd-webui-configs/-/raw/master/config.json\"" ] }, { "cell_type": "code", "execution_count": null, "id": "29c0c31d-ea47-4056-9ace-ff044cc42cbd", "metadata": {}, "outputs": [], "source": [ "## 安装常用插件\n", "extensions = [\n", " \"https://gitcode.net/ranting8323/a1111-sd-webui-tagcomplete\",\n", " \"https://gitcode.net/ranting8323/stable-diffusion-webui-localization-zh_CN\",\n", " \"https://gitcode.net/ranting8323/sd-webui-additional-networks\",\n", "]\n", "\n", "%cd /mnt/workspace/stable-diffusion-webui\n", "for e in extensions:\n", " !git -C \"extensions\" clone {e}" ] }, { "cell_type": "markdown", "id": "ced6371a-1cff-4dbf-9400-459ebb588df2", "metadata": {}, "source": [ "## 下载模型" ] }, { "cell_type": "code", "execution_count": null, "id": "8c290ca4-0880-41e1-b1c5-58fd9a755bb7", "metadata": {}, "outputs": [], "source": [ "def aria2(url, filename, d):\n", " !aria2c --console-log-level=error -c -x 16 -s 16 {url} -o {filename} -d {d}\n", "\n", "model_url = \"https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.5_fp16.safetensors\"\n", "aria2(model_url, model_url.split(\"/\")[-1], \"/mnt/workspace/stable-diffusion-webui/models/Stable-diffusion\")" ] }, { "cell_type": "markdown", "id": "d90eabd2-39cb-445d-b1b1-6e2740938948", "metadata": {}, "source": [ "## 下载 VAE" ] }, { "cell_type": "code", "execution_count": null, "id": "9936de5b-3f98-41ab-9af2-5691f60c4764", "metadata": {}, "outputs": [], "source": [ "VAE_URL = \"https://huggingface.co/akibanzu/animevae/resolve/main/animevae.pt\"\n", "aria2(VAE_URL, VAE_URL.split(\"/\")[-1], \"/mnt/workspace/stable-diffusion-webui/models/VAE\")" ] }, { "attachments": {}, "cell_type": "markdown", "id": "383abdf0", "metadata": {}, "source": [ "## 下载 其他文件(可选)" ] }, { "cell_type": "code", "execution_count": null, "id": "e1dd7015", "metadata": {}, "outputs": [], "source": [ "# 这部分是可选的!!!!!有需要再执行!!!!!!! 修改对应文本,运行即可下载文件\n", "DOWNLOAD_URL = \"文件链接\" # 文件链接,需要下载的url直链才可以\n", "FILE_NAME = \"aki\" # 下载保存的文件名\n", "SAVE_DIR = \"~/\" # 文件保存的路径\n", "aria2(DOWNLOAD_URL, FILE_NAME, SAVE_DIR)" ] }, { "cell_type": "markdown", "id": "e4bff16e-1f2d-4324-b1b8-78758b107eed", "metadata": {}, "source": [ "## 启动WebUI" ] }, { "cell_type": "code", "execution_count": null, "id": "edb12c51-eacb-4086-857e-e2eac64ac94f", "metadata": {}, "outputs": [], "source": [ "import os\n", "package_envs = [\n", " {\n", " \"env\": \"GFPGAN_PACKAGE\",\n", " \"url\": \"git+https://gitcode.net/overbill1683/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379\"\n", " },\n", " {\n", " \"env\": \"CLIP_PACKAGE\",\n", " \"url\": \"git+https://gitcode.net/overbill1683/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1\"\n", " },\n", " {\n", " \"env\": \"OPENCLIP_PACKAGE\",\n", " \"url\": \"git+https://gitcode.net/overbill1683/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b\"\n", " }\n", "]\n", "os.environ[\"PIP_INDEX_URL\"] = \"https://mirrors.bfsu.edu.cn/pypi/web/simple\"\n", "for i in package_envs:\n", " os.environ[i[\"env\"]] = i[\"url\"]\n", "\n", "%cd /mnt/workspace/stable-diffusion-webui\n", "!python launch.py --no-download-sd-model --xformers --share --listen" ] }, { "cell_type": "code", "execution_count": null, "id": "b778a001-6f15-459f-ab52-f0ae75c8c8af", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" } }, "nbformat": 4, "nbformat_minor": 5 }