{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "8cd9b419-e368-4416-9ec8-370de5db7e22", "metadata": {}, "outputs": [], "source": [ "# web-uiのインストール ※初回のみ実行\n", "%cd /notebooks\n", "!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui\n", "%cd /notebooks/stable-diffusion-webui" ] }, { "cell_type": "code", "execution_count": null, "id": "7754e8bf-d149-4e3e-9115-e954639c1a12", "metadata": {}, "outputs": [], "source": [ "# googleドライブからファイルダウンロードするのに必要なツールのインストール ※初回のみ実行\n", "!pip install gdown\n", "!pip install --upgrade gdown" ] }, { "cell_type": "code", "execution_count": null, "id": "2fe03bfa", "metadata": {}, "outputs": [], "source": [ "# install xformers\n", "# https://rentry.co/paperspace_de_xformers\n", "from pathlib import Path\n", "%cd /notebooks/\n", "! mkdir lora\n", "\n", "%cd lora\n", "! git clone https://github.com/kohya-ss/sd-scripts.git\n", "! git clone https://github.com/derrian-distro/LoRA_Easy_Training_Scripts.git\n", "\n", "%cd /notebooks/lora/sd-scripts\n", "! cp ~/LoRA_Easy_Training_Scripts/lora_train_command_line.py ./\n", "! apt install python3.10 python3.10-dev -y\n", "! pip3.10 install setuptools\n", "! apt autoremove python3-yaml python3-lxml --purge -y\n", "! curl https://bootstrap.pypa.io/get-pip.py | python3.10\n", "! pip3.10 install lxml\n", "! pip3.10 install -U torch==1.12.1+cu116 torchvision==0.13.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116\n", "! pip3.10 install `grep 'fairscale==' requirements.txt` --no-build-isolation\n", "! pip3.10 install gradio==3.16.2 altair==4.2.2 easygui requests timm==0.4.12 \"tensorflow<2.11\" huggingface-hub\n", "! pip3.10 install -r requirements.txt\n", "! pip3.10 install -U --pre triton\n", "! pip3.10 uninstall accelerate -y;pip3.10 install accelerate\n", "! pip3.10 install -U https://github.com/ninele7/xfromers_builds/releases/download/3393900949/xformers-0.0.14.dev0-cp310-cp310-linux_x86_64.whl\n", "! sed -i 's/^accelerate.*//g' /notebooks/stable-diffusion-webui/requirements_versions.txt\n", "d = Path(\"/root/.cache/huggingface/accelerate\")\n", "if not d.exists():\n", " d.mkdir(parents=True)\n", "p = d / Path(\"default_config.yaml\")\n", "p.write_text(\"\"\"command_file: null\n", "commands: null\n", "compute_environment: LOCAL_MACHINE\n", "deepspeed_config: {}\n", "distributed_type: 'NO'\n", "downcast_bf16: 'no'\n", "dynamo_backend: 'NO'\n", "fsdp_config: {}\n", "gpu_ids: all\n", "machine_rank: 0\n", "main_process_ip: null\n", "main_process_port: null\n", "main_training_function: main\n", "megatron_lm_config: {}\n", "mixed_precision: fp16\n", "num_machines: 1\n", "num_processes: 1\n", "rdzv_backend: static\n", "same_network: true\n", "tpu_name: null\n", "tpu_zone: null\n", "use_cpu: false\"\"\")\n", "\n", "! echo FINISHED!\n", "! date" ] }, { "cell_type": "code", "execution_count": null, "id": "22601392", "metadata": {}, "outputs": [], "source": [ "# install extensions\n", "%cd /notebooks/stable-diffusion-webui/extensions\n", "!git clone https://github.com/kohya-ss/sd-webui-additional-networks\n", "!git clone https://github.com/Mikubill/sd-webui-controlnet.git\n", "!git clone https://github.com/yfszzx/stable-diffusion-webui-images-browser\t\n", "!git clone https://github.com/toriato/stable-diffusion-webui-wd14-tagger.git\n", "!git clone https://github.com/toriato/stable-diffusion-webui-daam.git" ] }, { "cell_type": "code", "execution_count": null, "id": "f34e111a-28d7-456e-bb38-c142c781a680", "metadata": {}, "outputs": [], "source": [ "# 各モデルのダウンロード ※初回のみ実行\n", "# ※なにかしらのモデルが入っていないとweb-uiは起動しません\n", "%cd /notebooks/stable-diffusion-webui/models/Stable-diffusion\n", "!curl -OL https://huggingface.co/Defpoint/Defmix-v2.0/resolve/main/Defmix-v2.0.safetensors # 2.1GB" ] }, { "cell_type": "code", "execution_count": null, "id": "0eb13e70", "metadata": {}, "outputs": [], "source": [ "## download models\n", "\n", "### CKPT\n", "%cd /notebooks/stable-diffusion-webui/models/Stable-diffusion/\n", "#!curl -OL https://huggingface.co/syaimu/7th_Layer/resolve/main/7th_anime_v3/7th_anime_v3_B.safetensors # \n", "#!curl -OL https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3A1.safetensors # 2.13 GB\n", "#!curl -OL https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.5.safetensors # 7.7 GB\n", "#!curl -OL https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/ElyOrangeMix/ElyNightOrangeMix.ckpt # 4.27 GB\n", "#!curl -OL https://huggingface.co/Defpoint/Defmix-v2.0/resolve/main/Defmix-v2.0.safetensors # 2.1GB\n", "\n", "### VAE\n", "%cd /notebooks/stable-diffusion-webui/models/VAE/\n", "!curl -OL https://huggingface.co/andite/anything-v4.0/resolve/main/anything-v4.0.vae.pt\n", "\n", "### EMBEDDING\n", "%cd /notebooks/stable-diffusion-webui/embeddings/\n", "#!curl -OL https://huggingface.co/datasets/Nerfgun3/bad_prompt/resolve/main/bad_prompt_version2.pt\n", "!curl -OL https://huggingface.co/datasets/gsdf/EasyNegative/resolve/main/EasyNegative.safetensors\n", "#!curl -OL https://huggingface.co/nick-x-hacker/bad-artist/resolve/main/bad-artist.pt\n", "\n", "### LoRA\n", "%cd /notebooks/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/lora/\n", "#!curl -OL https://huggingface.co/yui-futao/LoRA-fto/resolve/main/fto-v43.safetensors\n", "\n", "### ControlNet\n", "%cd /notebooks/stable-diffusion-webui/extensions/sd-webui-controlnet/models\n", "#!curl -OL https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_canny-fp16.safetensors\n", "#!curl -OL https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors\n", "#!curl -OL https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_normal-fp16.safetensors\n", "#!curl -OL https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors\n", "#!curl -OL https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_seg-fp16.safetensors" ] }, { "cell_type": "code", "execution_count": null, "id": "5d7a0b98-720c-4d6f-bf51-966114128c63", "metadata": {}, "outputs": [], "source": [ "# config.json の復元\n", "%cd /notebooks/stable-diffusion-webui/\n", "!curl -OL https://huggingface.co/datasets/yui-futao/notebooks/raw/main/config.json\n", "!curl -OL https://huggingface.co/datasets/yui-futao/notebooks/raw/main/ui-config.json" ] }, { "cell_type": "code", "execution_count": null, "id": "837b2843", "metadata": {}, "outputs": [], "source": [ "!cd; git clone https://github.com/doHub1/dotfiles.git; cd dotfiles; bash install.sh; cd /notebooks/ #DOT\n", "!cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime #TZ=JST" ] }, { "cell_type": "code", "execution_count": null, "id": "ca0e037f-4f6d-4122-9b4e-0ce8853e2bf3", "metadata": {}, "outputs": [], "source": [ "# web-uiの起動\n", "# ログイン用のユーザーネームとパスワードは --gradio-auth ユーザーネーム:パスワード となる。書き換え推奨。\n", "%cd /notebooks/stable-diffusion-webui\n", "!python launch.py\\\n", "--gradio-auth :\\\n", "--share\\\n", "--xformers\\\n", "--no-half-vae\\\n", "--skip-version-check\\\n", "--enable-insecure-extension-access" ] }, { "cell_type": "code", "execution_count": null, "id": "a9b447c8", "metadata": {}, "outputs": [], "source": [ "!watch -d -n 10 \"ls -lh /notebooks/stable-diffusion-webui/outputs/ |grep 2023 & du -h /notebooks/stable-diffusion-webui/outputs/ |grep 2023\"" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.10" }, "vscode": { "interpreter": { "hash": "3834a203b0427e23345e2285a24ec315196163d8a2ce1fe7c01f4ca5296d844c" } } }, "nbformat": 4, "nbformat_minor": 5 }