|
| 1 | +{ |
| 2 | + "nbformat": 4, |
| 3 | + "nbformat_minor": 0, |
| 4 | + "metadata": { |
| 5 | + "colab": { |
| 6 | + "provenance": [] |
| 7 | + }, |
| 8 | + "kernelspec": { |
| 9 | + "name": "python3", |
| 10 | + "display_name": "Python 3" |
| 11 | + }, |
| 12 | + "language_info": { |
| 13 | + "name": "python" |
| 14 | + }, |
| 15 | + "accelerator": "GPU", |
| 16 | + "gpuClass": "standard" |
| 17 | + }, |
| 18 | + "cells": [ |
| 19 | + { |
| 20 | + "cell_type": "markdown", |
| 21 | + "metadata": { |
| 22 | + "id": "view-in-github" |
| 23 | + }, |
| 24 | + "source": [ |
| 25 | + "[](https://colab.research.google.com/github/d8ahazard/sd_dreambooth_extension/blob/Torch2/D8-DreamBooth.ipynb)" |
| 26 | + ] |
| 27 | + }, |
| 28 | + { |
| 29 | + "cell_type": "code", |
| 30 | + "source": [ |
| 31 | + "from google.colab import drive\n", |
| 32 | + "import os\n", |
| 33 | + "\n", |
| 34 | + "drive.mount(\"/content/gdrive\", force_remount=True)\n", |
| 35 | + "\n", |
| 36 | + "if not os.path.exists(\"/content/gdrive/MyDrive/sd-db-d8\"):\n", |
| 37 | + " os.mkdirs(\"/content/gdrive/MyDrive/sd-db-d8\")\n", |
| 38 | + "\n", |
| 39 | + "if not os.path.exists(\"/content/working/\"):\n", |
| 40 | + " os.mkdirs(\"/content/working/\")\n", |
| 41 | + "\n", |
| 42 | + "!rm -f /content/working/stable-diffusion-webui\n", |
| 43 | + "!ln -s /content/gdrive/MyDrive/sd-db-d8 /content/working/stable-diffusion-webui" |
| 44 | + ], |
| 45 | + "metadata": { |
| 46 | + "id": "W4eFr-nSHE85" |
| 47 | + }, |
| 48 | + "execution_count": null, |
| 49 | + "outputs": [] |
| 50 | + }, |
| 51 | + { |
| 52 | + "cell_type": "markdown", |
| 53 | + "source": [ |
| 54 | + "Install various packages" |
| 55 | + ], |
| 56 | + "metadata": { |
| 57 | + "id": "PLbCegoEyO4M" |
| 58 | + } |
| 59 | + }, |
| 60 | + { |
| 61 | + "cell_type": "code", |
| 62 | + "execution_count": null, |
| 63 | + "metadata": { |
| 64 | + "id": "upF9RGj0tTiH" |
| 65 | + }, |
| 66 | + "outputs": [], |
| 67 | + "source": [ |
| 68 | + "# **fast-DreamBooth colab From https://github.com/d8ahazard/sd_dreambooth_extension, modified from https://github.com/camenduru/stable-diffusion-webui-collab**\n", |
| 69 | + "!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui /content/working/stable-diffusion-webui/\n", |
| 70 | + "!wget https://raw.githubusercontent.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py -O /content/working/stable-diffusion-webui/scripts/run_n_times.py\n", |
| 71 | + "!git clone https://github.com/AlUlkesh/stable-diffusion-webui-images-browser /content/working/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser\n", |
| 72 | + "!git clone https://github.com/camenduru/stable-diffusion-webui-huggingface /content/working/stable-diffusion-webui/extensions/stable-diffusion-webui-huggingface\n", |
| 73 | + "!git clone https://github.com/camenduru/sd-civitai-browser /content/working/stable-diffusion-webui/extensions/sd-civitai-browser\n", |
| 74 | + "!git clone https://github.com/camenduru/sd-webui-additional-networks /content/working/stable-diffusion-webui/extensions/sd-webui-additional-networks\n", |
| 75 | + "!git clone -b Torch2 https://github.com/d8ahazard/sd_dreambooth_extension /content/working/stable-diffusion-webui/extensions/sd_dreambooth_extension\n", |
| 76 | + "\n", |
| 77 | + "%cd /content/working/stable-diffusion-webui\n" |
| 78 | + ] |
| 79 | + }, |
| 80 | + { |
| 81 | + "cell_type": "markdown", |
| 82 | + "source": [ |
| 83 | + "Bump Python Version (RUN ONCE)" |
| 84 | + ], |
| 85 | + "metadata": { |
| 86 | + "id": "no--xkmZyJGx" |
| 87 | + } |
| 88 | + }, |
| 89 | + { |
| 90 | + "cell_type": "code", |
| 91 | + "source": [ |
| 92 | + "\n", |
| 93 | + "!wget https://github.com/korakot/kora/releases/download/v0.10/py310.sh\n", |
| 94 | + "!bash ./py310.sh -b -f -p /usr/local\n", |
| 95 | + "!python -m ipykernel install --name \"py310\" --user\n" |
| 96 | + ], |
| 97 | + "metadata": { |
| 98 | + "id": "IJxdOKeBvUGp" |
| 99 | + }, |
| 100 | + "execution_count": null, |
| 101 | + "outputs": [] |
| 102 | + }, |
| 103 | + { |
| 104 | + "cell_type": "markdown", |
| 105 | + "source": [ |
| 106 | + "Download the 1.5 Model" |
| 107 | + ], |
| 108 | + "metadata": { |
| 109 | + "id": "sQirFY6cyr1O" |
| 110 | + } |
| 111 | + }, |
| 112 | + { |
| 113 | + "cell_type": "code", |
| 114 | + "source": [ |
| 115 | + "!wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned.safetensors -O /content/working/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned.safetensors\n" |
| 116 | + ], |
| 117 | + "metadata": { |
| 118 | + "id": "F42Hh4v8yjyB" |
| 119 | + }, |
| 120 | + "execution_count": null, |
| 121 | + "outputs": [] |
| 122 | + }, |
| 123 | + { |
| 124 | + "cell_type": "markdown", |
| 125 | + "source": [ |
| 126 | + "And/Or download the 2.1 Model" |
| 127 | + ], |
| 128 | + "metadata": { |
| 129 | + "id": "K0uL_P3OyvC5" |
| 130 | + } |
| 131 | + }, |
| 132 | + { |
| 133 | + "cell_type": "code", |
| 134 | + "source": [ |
| 135 | + "!wget https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-nonema-pruned.safetensors -O /content/working/stable-diffusion-webui/models/Stable-diffusion/v2-1_768-nonema-pruned.safetensors\n", |
| 136 | + "\n", |
| 137 | + "!wget https://huggingface.co/ckpt/stable-diffusion-2-1/raw/main/v2-inference-v.yaml -O /content/working/stable-diffusion-webui/models/Stable-diffusion/v2-1_768-nonemaema-pruned.yaml\n" |
| 138 | + ], |
| 139 | + "metadata": { |
| 140 | + "id": "FKyzSN7SyfbZ" |
| 141 | + }, |
| 142 | + "execution_count": null, |
| 143 | + "outputs": [] |
| 144 | + }, |
| 145 | + { |
| 146 | + "cell_type": "markdown", |
| 147 | + "source": [ |
| 148 | + "Install Dreambooth and Auto1111 dependencies (RUN ONCE)" |
| 149 | + ], |
| 150 | + "metadata": { |
| 151 | + "id": "kzh_c4qvyFUs" |
| 152 | + } |
| 153 | + }, |
| 154 | + { |
| 155 | + "cell_type": "code", |
| 156 | + "source": [ |
| 157 | + "!%cd /content/working/stable-diffusion-webui/\n", |
| 158 | + "# Clone Auto1111 repos\n", |
| 159 | + "!git clone \"https://github.com/Stability-AI/stablediffusion.git\" \"/content/working/stable-diffusion-webui/repositories/stable-diffusion-stability-ai\" \n", |
| 160 | + "!%cd \"/content/working/stable-diffusion-webui/repositories/stable-diffusion-stability-ai\" \n", |
| 161 | + "!git checkout \"47b6b607fdd31875c9279cd2f4f16b92e4ea958e\"\n", |
| 162 | + "!git clone \"https://github.com/CompVis/taming-transformers.git\" \"/content/working/stable-diffusion-webui/repositories/taming-transformers\" \n", |
| 163 | + "!%cd \"/content/working/stable-diffusion-webui/repositories/taming-transformers\" \n", |
| 164 | + "!git checkout \"24268930bf1dce879235a7fddd0b2355b84d7ea6\"\n", |
| 165 | + "!git clone \"https://github.com/crowsonkb/k-diffusion.git\" \"/content/working/stable-diffusion-webui/repositories/k-diffusion\"\n", |
| 166 | + "!%cd \"/content/working/stable-diffusion-webui/repositories/k-diffusion\"\n", |
| 167 | + "!git checkout \"5b3af030dd83e0297272d861c19477735d0317ec\"\n", |
| 168 | + "!git clone \"https://github.com/sczhou/CodeFormer.git\" \"/content/working/stable-diffusion-webui/repositories/CodeFormer\"\n", |
| 169 | + "!%cd \"/content/working/stable-diffusion-webui/repositories/CodeFormer\" \n", |
| 170 | + "!git checkout \"c5b4593074ba6214284d6acd5f1719b6c5d739af\"\n", |
| 171 | + "!git clone \"https://github.com/salesforce/BLIP.git\" \"/content/working/stable-diffusion-webui/repositories/BLIP\" \n", |
| 172 | + "!%cd \"/content/working/stable-diffusion-webui/repositories/BLIP\"\n", |
| 173 | + "!git checkout \"48211a1594f1321b00f14c9f7a5b4813144b2fb9\"\n" |
| 174 | + ], |
| 175 | + "metadata": { |
| 176 | + "id": "q4-o5-Grx_sw" |
| 177 | + }, |
| 178 | + "execution_count": null, |
| 179 | + "outputs": [] |
| 180 | + }, |
| 181 | + { |
| 182 | + "cell_type": "markdown", |
| 183 | + "source": [ |
| 184 | + "Setup VENV" |
| 185 | + ], |
| 186 | + "metadata": { |
| 187 | + "id": "_G-NX4mvIv-G" |
| 188 | + } |
| 189 | + }, |
| 190 | + { |
| 191 | + "cell_type": "code", |
| 192 | + "source": [ |
| 193 | + "# Install PIP stuff\n", |
| 194 | + "!%cd /content/working/stable-diffusion-webui/\n", |
| 195 | + "!pip install virtualenv\n", |
| 196 | + "!virtualenv venv\n", |
| 197 | + "!source venv/bin/activate\n", |
| 198 | + "# Install Auto1111 PIP packages\n", |
| 199 | + "!pip install git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379\n", |
| 200 | + "!pip install git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1\n", |
| 201 | + "!pip install git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b\n", |
| 202 | + "\n", |
| 203 | + "# Install Requirements\n", |
| 204 | + "!pip install -r /content/working/stable-diffusion-webui/requirements_versions.txt\n", |
| 205 | + "!pip install -r /content/working/stable-diffusion-webui./extensions/sd_dreambooth_extension/requirements.txt\n", |
| 206 | + "!pip install https://github.com/ArrowM/xformers/releases/download/xformers-0.0.17%2B36e23c5.d20230209-cp310-cu118/xformers-0.0.17+36e23c5.d20230209-cp310-cp310-linux_x86_64.whl\n", |
| 207 | + "!pip install https://download.pytorch.org/whl/nightly/cu118/torch-2.0.0.dev20230209%2Bcu118-cp310-cp310-linux_x86_64.whl https://download.pytorch.org/whl/nightly/cu118/torchvision-0.15.0.dev20230209%2Bcu118-cp310-cp310-linux_x86_64.whl\n" |
| 208 | + ], |
| 209 | + "metadata": { |
| 210 | + "id": "XIdP81K-Isiw" |
| 211 | + }, |
| 212 | + "execution_count": null, |
| 213 | + "outputs": [] |
| 214 | + }, |
| 215 | + { |
| 216 | + "cell_type": "markdown", |
| 217 | + "source": [ |
| 218 | + "Run Auto1111" |
| 219 | + ], |
| 220 | + "metadata": { |
| 221 | + "id": "A_AePD55yYeQ" |
| 222 | + } |
| 223 | + }, |
| 224 | + { |
| 225 | + "cell_type": "code", |
| 226 | + "source": [ |
| 227 | + "!%cd /content/working/stable-diffusion-webui/extensions/sd_dreambooth_extension/\n", |
| 228 | + "!git fetch && git pull\n", |
| 229 | + "!%cd /content/working/stable-diffusion-webui/ \n", |
| 230 | + "!python launch.py --share --xformers --enable-insecure-extension-access --torch2 --skip-install --skip-torch-cuda-test" |
| 231 | + ], |
| 232 | + "metadata": { |
| 233 | + "id": "qa5T38izv6CX" |
| 234 | + }, |
| 235 | + "execution_count": null, |
| 236 | + "outputs": [] |
| 237 | + } |
| 238 | + ] |
| 239 | +} |
0 commit comments