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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"metadata": {
|
| 6 |
+
"id": "e78dCt3JZ6UX"
|
| 7 |
+
},
|
| 8 |
+
"source": [
|
| 9 |
+
"##***Project `VCL-colab`***\n",
|
| 10 |
+
"### All camenduru colab in one spot, synced in realtime\n",
|
| 11 |
+
"###### Last time updated: Aug 12, 23\n",
|
| 12 |
+
"###### (something doesn't work properly? Make sure you use the [latest version](https://colab.research.google.com/github/etherealxx/volatile-concentration-localux-colab/blob/main/volatile_concentration_localux_colab.ipynb), or [report a bug](https://github.com/etherealxx/volatile-concentration-localux-colab/issues).)"
|
| 13 |
+
]
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"cell_type": "markdown",
|
| 17 |
+
"metadata": {
|
| 18 |
+
"id": "mRkHg3INcszO"
|
| 19 |
+
},
|
| 20 |
+
"source": [
|
| 21 |
+
"###### \n",
|
| 22 |
+
"To use:\n",
|
| 23 |
+
"- Click the play button\n",
|
| 24 |
+
"- Wait for less than a minute, until a UI with **big orange button** shows up\n",
|
| 25 |
+
"- Choose the model you want, **wait** for the **extension checkboxes** to shows up, choose the extension that you wanted, then click the orange button\n",
|
| 26 |
+
"- Just wait for about 8 minute until the webui links shows up on the bottom\n",
|
| 27 |
+
"\n",
|
| 28 |
+
"About the options:\n",
|
| 29 |
+
"- `repo_branch`: Read [here](https://github.com/camenduru/stable-diffusion-webui-colab) (just use `stable` as default)\n",
|
| 30 |
+
"- `choose_models`: Untick this if you're relaunching the UI, or if you don't want to choose model (The webui will always download sd 1.4 model instead)\n",
|
| 31 |
+
"- `controlnet_model`: Tick this if you want to download controlnet models (for controlnet usage). Untick this if you're relaunching the UI. Note that `lite` branch won't download any controlnet model regardless if this checkbox is being ticked or not.\n",
|
| 32 |
+
"\n",
|
| 33 |
+
"Got an Error 403 instead of the UI with big orange button? Read [here](https://github.com/etherealxx/volatile-concentration-localux-colab/blob/main/error403guide.md) to fix it."
|
| 34 |
+
]
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"cell_type": "markdown",
|
| 38 |
+
"metadata": {
|
| 39 |
+
"id": "4bsCMAOQcSIn"
|
| 40 |
+
},
|
| 41 |
+
"source": [
|
| 42 |
+
"## ⠀\n",
|
| 43 |
+
"(open the hidden cell to show help☝️)"
|
| 44 |
+
]
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"cell_type": "code",
|
| 48 |
+
"execution_count": null,
|
| 49 |
+
"metadata": {
|
| 50 |
+
"cellView": "form",
|
| 51 |
+
"id": "HRLSD-HXLRNk"
|
| 52 |
+
},
|
| 53 |
+
"outputs": [],
|
| 54 |
+
"source": [
|
| 55 |
+
"#@title 👇 Run this\n",
|
| 56 |
+
"repo_branch = 'nightly' #@param [\"lite\", \"stable\", \"nightly\"]\n",
|
| 57 |
+
"choose_models = False #@param {type:\"boolean\"}\n",
|
| 58 |
+
"controlnet_models = False #@param {type:\"boolean\"}\n",
|
| 59 |
+
"\n",
|
| 60 |
+
"print(\"\u001b[1;32mWait for about a minute until a UI with a big orange button shows up below\")\n",
|
| 61 |
+
"print('\u001b[0m')\n",
|
| 62 |
+
"\n",
|
| 63 |
+
"from IPython.display import clear_output\n",
|
| 64 |
+
"import time\n",
|
| 65 |
+
"%cd /content\n",
|
| 66 |
+
"\n",
|
| 67 |
+
"try:\n",
|
| 68 |
+
" start_colab\n",
|
| 69 |
+
"except:\n",
|
| 70 |
+
" start_colab = int(time.time())-5\n",
|
| 71 |
+
"# clear_output()\n",
|
| 72 |
+
"\n",
|
| 73 |
+
"%env TF_CPP_MIN_LOG_LEVEL=1\n",
|
| 74 |
+
"!git clone https://github.com/etherealxx/volatile-concentration-localux-colab /content/vcltools\n",
|
| 75 |
+
"!pip install -q gradio==3.37.0\n",
|
| 76 |
+
"\n",
|
| 77 |
+
"emptymodel = False\n",
|
| 78 |
+
"\n",
|
| 79 |
+
"colaboptions = {\n",
|
| 80 |
+
" \"branch\": repo_branch,\n",
|
| 81 |
+
" \"filename\": \"stable_diffusion_1_5_webui_colab.ipynb\",\n",
|
| 82 |
+
" \"part\": \"part2\",\n",
|
| 83 |
+
" \"controlnet\": controlnet_models,\n",
|
| 84 |
+
" \"download_model\": choose_models,\n",
|
| 85 |
+
" \"empty_model\": emptymodel\n",
|
| 86 |
+
"} #default\n",
|
| 87 |
+
"\n",
|
| 88 |
+
"import os, pickle, sys, re, shutil\n",
|
| 89 |
+
"import gradio as gr\n",
|
| 90 |
+
"\n",
|
| 91 |
+
"vclvarpath = '/content/vclvariables'\n",
|
| 92 |
+
"os.makedirs(vclvarpath, exist_ok=True)\n",
|
| 93 |
+
"!python /content/vcltools/cloneall3.py\n",
|
| 94 |
+
"\n",
|
| 95 |
+
"# This will dumps 'sortedcolabname'\n",
|
| 96 |
+
"!python /content/vcltools/choosemodel4.py {repo_branch}\n",
|
| 97 |
+
"\n",
|
| 98 |
+
"def pickledump(vartodump, outputfile):\n",
|
| 99 |
+
" outputpath = os.path.join(vclvarpath, outputfile + '.pkl')\n",
|
| 100 |
+
" with open(outputpath, 'wb') as f:\n",
|
| 101 |
+
" pickle.dump(vartodump, f)\n",
|
| 102 |
+
"\n",
|
| 103 |
+
"def pickleload(prevvalue, inputfile):\n",
|
| 104 |
+
" inputpath = os.path.join(vclvarpath, inputfile + '.pkl')\n",
|
| 105 |
+
" if os.path.exists(inputpath):\n",
|
| 106 |
+
" with open(inputpath, 'rb') as f:\n",
|
| 107 |
+
" vartopass = pickle.load(f)\n",
|
| 108 |
+
" return vartopass\n",
|
| 109 |
+
" else:\n",
|
| 110 |
+
" return prevvalue\n",
|
| 111 |
+
"\n",
|
| 112 |
+
"vclpath = \"/content/volatile-concentration-localux\"\n",
|
| 113 |
+
"prevbranch = pickleload(None, 'prevbranch')\n",
|
| 114 |
+
"if prevbranch and prevbranch != repo_branch:\n",
|
| 115 |
+
" !python /content/vcltools/changebranch.py backup\n",
|
| 116 |
+
" pass\n",
|
| 117 |
+
"\n",
|
| 118 |
+
"# 'sortedcolabname' will not be accessed anymore\n",
|
| 119 |
+
"sortedcolabname = pickleload(None, 'sortedcolabname')\n",
|
| 120 |
+
"\n",
|
| 121 |
+
"!pip install base58\n",
|
| 122 |
+
"import base58\n",
|
| 123 |
+
"# The extension name of that must have extension for sd colabs, enabling multiple gradio UI tunneling at once\n",
|
| 124 |
+
"tunneltext = base58.b58decode(\"FFSgE5cGo6ewBdZ8cwDovS\".encode()).decode()\n",
|
| 125 |
+
"\n",
|
| 126 |
+
"if choose_models:\n",
|
| 127 |
+
" clear_output(wait=True)\n",
|
| 128 |
+
"\n",
|
| 129 |
+
"everycolab = f'/content/camendurus/{repo_branch}'\n",
|
| 130 |
+
"modelischosen = False\n",
|
| 131 |
+
"modelchosenmessage = ''\n",
|
| 132 |
+
"chosencolabname = ''\n",
|
| 133 |
+
"extensionlines = []\n",
|
| 134 |
+
"extensiontoremove = []\n",
|
| 135 |
+
"\n",
|
| 136 |
+
"def list_additional_ext():\n",
|
| 137 |
+
" addext_txtpath = \"/content/vcltools/additionalextensions.txt\"\n",
|
| 138 |
+
" with open(addext_txtpath, 'r') as file:\n",
|
| 139 |
+
" lines = [line.rstrip('\\n') for line in file]\n",
|
| 140 |
+
" exts = [ext for ext in lines if ext != \"\" and not ext.startswith(\"#\")]\n",
|
| 141 |
+
" return exts\n",
|
| 142 |
+
"\n",
|
| 143 |
+
"additionalextension_names = [x.split(\"/\")[-1] for x in list_additional_ext()]\n",
|
| 144 |
+
"\n",
|
| 145 |
+
"def no_model_install_extension():\n",
|
| 146 |
+
" global choose_models\n",
|
| 147 |
+
" global colaboptions\n",
|
| 148 |
+
" global emptymodel\n",
|
| 149 |
+
" global extensionlines\n",
|
| 150 |
+
"\n",
|
| 151 |
+
" extensionlist = []\n",
|
| 152 |
+
" choose_models = False\n",
|
| 153 |
+
" colaboptions[\"download_model\"] = False\n",
|
| 154 |
+
" emptymodel = True\n",
|
| 155 |
+
"\n",
|
| 156 |
+
" # This script extracts every \"git clone\" line from selected camenduru's colab notebook\n",
|
| 157 |
+
" # The result is 'extensions' pickle file, containing git clone lines as a python list\n",
|
| 158 |
+
" !python /content/vcltools/extensioninstaller3.py\n",
|
| 159 |
+
"\n",
|
| 160 |
+
" extensionlines = pickleload(extensionlines, 'extensions')\n",
|
| 161 |
+
"\n",
|
| 162 |
+
" for ext_gitcloneline in extensionlines:\n",
|
| 163 |
+
" pattern = r\"https://github.com/\\S+/(\\S+)\"\n",
|
| 164 |
+
" match = re.search(pattern, ext_gitcloneline)\n",
|
| 165 |
+
" if match:\n",
|
| 166 |
+
" ext_name = match.group(1)\n",
|
| 167 |
+
" if not ext_name == tunneltext:\n",
|
| 168 |
+
" extensionlist.append(ext_name)\n",
|
| 169 |
+
" # print(repo_name)\n",
|
| 170 |
+
" pickledump(extensionlist, 'fullextensions')\n",
|
| 171 |
+
"\n",
|
| 172 |
+
"def modelchosen(chosenmodel, chosenextension):\n",
|
| 173 |
+
" global modelischosen\n",
|
| 174 |
+
" global modelchosenmessage\n",
|
| 175 |
+
" global chosencolabname\n",
|
| 176 |
+
" global colaboptions\n",
|
| 177 |
+
" global choose_models\n",
|
| 178 |
+
" global extensionlines\n",
|
| 179 |
+
" global extensiontoremove\n",
|
| 180 |
+
" global emptymodel\n",
|
| 181 |
+
"\n",
|
| 182 |
+
" # for link in extensionlines:\n",
|
| 183 |
+
" # match = re.search(r\"https://github.com/\\S+/(\\S+)\", link)\n",
|
| 184 |
+
" # if match:\n",
|
| 185 |
+
" # repo_name = match.group(1)\n",
|
| 186 |
+
" # if repo_name in chosenextension:\n",
|
| 187 |
+
" # usedextensionlinks.append(link)\n",
|
| 188 |
+
" # pickledump(usedextensionlinks, '/content/extensions.pkl')\n",
|
| 189 |
+
"\n",
|
| 190 |
+
" # For the first time launching the colab, there will be no 'chosenextension' pickle file\n",
|
| 191 |
+
" # This will later get accessed after the user choose the model, to preserve the user's chosen extension from previous cell run\n",
|
| 192 |
+
" pickledump(chosenextension, 'chosenextensions')\n",
|
| 193 |
+
"\n",
|
| 194 |
+
" # This will also being accessed by `additionalextension.py`\n",
|
| 195 |
+
" # WIP\n",
|
| 196 |
+
" fullextension = pickleload(None, 'fullextensions')\n",
|
| 197 |
+
"\n",
|
| 198 |
+
" if fullextension:\n",
|
| 199 |
+
" extensiontoremove = [x for x in fullextension if x not in chosenextension]\n",
|
| 200 |
+
"\n",
|
| 201 |
+
" # This will later accessed by `camendurucolab3.py` to filter only chosen extension that will be cloned\n",
|
| 202 |
+
" # ... and those who aren't chosen will be removed\n",
|
| 203 |
+
" pickledump(extensiontoremove, 'removedextensions')\n",
|
| 204 |
+
"\n",
|
| 205 |
+
" if chosenmodel:\n",
|
| 206 |
+
" modelchosenmessage = \"\u001b[1;32mModel \" + chosenmodel + \" was chosen. It'll be downloaded soon. Continue scroll down and wait for the webui to be loaded.\"\n",
|
| 207 |
+
" textbox_text = f\"Model '{chosenmodel} was chosen. It'll be downloaded soon. Continue scroll down and wait for the webui to be loaded.\"\n",
|
| 208 |
+
" chosencolabname = chosenmodel\n",
|
| 209 |
+
" emptymodel = False\n",
|
| 210 |
+
" else:\n",
|
| 211 |
+
" modelchosenmessage = \"\u001b[1;32mNo model was chosen. Continue scroll down and wait for the webui to be loaded.\"\n",
|
| 212 |
+
" textbox_text = f\"No model was chosen. Continue scroll down and wait for the webui to be loaded.\"\n",
|
| 213 |
+
"\n",
|
| 214 |
+
" no_model_install_extension()\n",
|
| 215 |
+
"\n",
|
| 216 |
+
" modelischosen = True\n",
|
| 217 |
+
" return [gr.Button.update(visible=False), gr.Textbox.update(value=textbox_text, visible=True), gr.CheckboxGroup.update(visible=False), gr.Dropdown.update(interactive=False)]\n",
|
| 218 |
+
"\n",
|
| 219 |
+
"def extensionschoose(modelthatischosen):\n",
|
| 220 |
+
" extensionlist = []\n",
|
| 221 |
+
" global colaboptions\n",
|
| 222 |
+
" global extensionlines\n",
|
| 223 |
+
" global additionalextension_names\n",
|
| 224 |
+
" if modelthatischosen:\n",
|
| 225 |
+
" colabfilename = modelthatischosen + '_webui_colab.ipynb'\n",
|
| 226 |
+
" colaboptions[\"filename\"] = colabfilename\n",
|
| 227 |
+
" # chosencolabfilepath = os.path.join(everycolab, colabfilename)\n",
|
| 228 |
+
"\n",
|
| 229 |
+
" # Contains branch name, camenduru's colab notebook name, part (unused),\n",
|
| 230 |
+
" # ... and three booleans: :controlnet\", \"download_model\", \"empty_model\"\n",
|
| 231 |
+
" # Need to be loaded in \"camendurucolab3.py\", \"extensioninstaller3.py\", and \"runaria3.py\"\n",
|
| 232 |
+
" pickledump(colaboptions, 'colaboptions')\n",
|
| 233 |
+
"\n",
|
| 234 |
+
" # This script extracts every \"git clone\" line from selected camenduru's colab notebook\n",
|
| 235 |
+
" # The result is 'extensions' pickle file, containing git clone lines as a python list\n",
|
| 236 |
+
" !python /content/vcltools/extensioninstaller3.py\n",
|
| 237 |
+
" extensionlines = pickleload(extensionlines, 'extensions')\n",
|
| 238 |
+
"\n",
|
| 239 |
+
" for ext_gitcloneline in extensionlines:\n",
|
| 240 |
+
" pattern = r\"https://github.com/\\S+/(\\S+)\"\n",
|
| 241 |
+
" match = re.search(pattern, ext_gitcloneline)\n",
|
| 242 |
+
" if match:\n",
|
| 243 |
+
" ext_name = match.group(1)\n",
|
| 244 |
+
" if not ext_name == tunneltext:\n",
|
| 245 |
+
" extensionlist.append(ext_name)\n",
|
| 246 |
+
" # print(repo_name)\n",
|
| 247 |
+
"\n",
|
| 248 |
+
" # Contains only the extension name, excluding the tunnel extension\n",
|
| 249 |
+
" # This also includes the additional extensions\n",
|
| 250 |
+
" pickledump(extensionlist, 'fullextensions')\n",
|
| 251 |
+
"\n",
|
| 252 |
+
" !python /content/vcltools/additionalextension.py\n",
|
| 253 |
+
"\n",
|
| 254 |
+
" # Extensions that are from camenduru's repo. Used only as a fallback of 'chosenextensions'\n",
|
| 255 |
+
" templist = pickleload(None, 'tempext')\n",
|
| 256 |
+
"\n",
|
| 257 |
+
" # List of extensions that were choosen by the user\n",
|
| 258 |
+
" chosenextension = pickleload(templist, 'chosenextensions')\n",
|
| 259 |
+
"\n",
|
| 260 |
+
" # Group the extensions based from the source (camenduru's colab or additional exts)\n",
|
| 261 |
+
" # ... and then sort them alphabetically\n",
|
| 262 |
+
" extensionlist = list(set(extensionlist) - set(additionalextension_names))\n",
|
| 263 |
+
" extensionlist.sort()\n",
|
| 264 |
+
" additionalextension_names.sort()\n",
|
| 265 |
+
" # extensionlist.extend(chosenextension)\n",
|
| 266 |
+
" for extname in additionalextension_names:\n",
|
| 267 |
+
" extensionlist.append(extname)\n",
|
| 268 |
+
"\n",
|
| 269 |
+
" return gr.CheckboxGroup.update(choices=extensionlist, value=chosenextension, visible=True)\n",
|
| 270 |
+
"\n",
|
| 271 |
+
"def dumpchoice(extensionthatischosen):\n",
|
| 272 |
+
" # Always update whenever user modifies the extensions checkboxes\n",
|
| 273 |
+
" pickledump(extensionthatischosen, 'chosenextensions')\n",
|
| 274 |
+
"\n",
|
| 275 |
+
"with gr.Blocks() as vclcolab:\n",
|
| 276 |
+
" with gr.Column():\n",
|
| 277 |
+
" choose = gr.Dropdown(sortedcolabname, label=\"Choose Your Model\", interactive=True)\n",
|
| 278 |
+
" confirm = gr.Button(\"Use This Model\", variant=\"primary\", visible=True)\n",
|
| 279 |
+
" donetext = gr.Textbox(\"\", label=\"\", visible=False)\n",
|
| 280 |
+
" extchooser = gr.CheckboxGroup([\"placeholder\"], label=\"Extensions\", info=\"Untick the checkboxes on those extensions that you want to disable\", visible=False, interactive=True)\n",
|
| 281 |
+
" confirm.click(modelchosen, inputs=[choose, extchooser], outputs=[confirm, donetext, extchooser, choose])\n",
|
| 282 |
+
" choose.change(extensionschoose, inputs=[choose], outputs=[extchooser])\n",
|
| 283 |
+
" extchooser.change(dumpchoice, inputs=[extchooser])\n",
|
| 284 |
+
"\n",
|
| 285 |
+
"gr.close_all()\n",
|
| 286 |
+
"if choose_models:\n",
|
| 287 |
+
" tryport = 7860\n",
|
| 288 |
+
" while True:\n",
|
| 289 |
+
" tryport += 1\n",
|
| 290 |
+
" try:\n",
|
| 291 |
+
" print(\"\u001b[1;32mNo need to click on the public url yet. Just wait until a UI with a big orange button shows up below\")\n",
|
| 292 |
+
" print(\"\u001b[1;32mIf 'Error 403' shows instead, click the stop button twice until 'Gradio UI interrupted' message shows up, then read here: https://github.com/etherealxx/volatile-concentration-localux-colab/blob/main/error403guide.md\")\n",
|
| 293 |
+
" print('\u001b[0m')\n",
|
| 294 |
+
" vclcolab.launch(server_port=tryport)\n",
|
| 295 |
+
" break\n",
|
| 296 |
+
" except OSError:\n",
|
| 297 |
+
" pass\n",
|
| 298 |
+
"\n",
|
| 299 |
+
" while True:\n",
|
| 300 |
+
" try:\n",
|
| 301 |
+
" if modelischosen:\n",
|
| 302 |
+
" clear_output(wait=True)\n",
|
| 303 |
+
" print(modelchosenmessage)\n",
|
| 304 |
+
" print('\u001b[0m')\n",
|
| 305 |
+
" vclcolab.close()\n",
|
| 306 |
+
" break\n",
|
| 307 |
+
" except KeyboardInterrupt:\n",
|
| 308 |
+
" clear_output(wait=True)\n",
|
| 309 |
+
" print(\"\u001b[1;33mGradio UI interrupted\")\n",
|
| 310 |
+
" print('\u001b[0m')\n",
|
| 311 |
+
" vclcolab.close()\n",
|
| 312 |
+
" # sys.exit()\n",
|
| 313 |
+
" # os._exit(1)\n",
|
| 314 |
+
" break\n",
|
| 315 |
+
"\n",
|
| 316 |
+
"aria2c_lines = []\n",
|
| 317 |
+
"colabfilename = ''\n",
|
| 318 |
+
"chosencolabfilepath = os.path.join(everycolab, colaboptions[\"filename\"])\n",
|
| 319 |
+
"\n",
|
| 320 |
+
"if chosencolabname:\n",
|
| 321 |
+
" colabfilename = chosencolabname + '_webui_colab.ipynb'\n",
|
| 322 |
+
" colaboptions[\"filename\"] = colabfilename\n",
|
| 323 |
+
" chosencolabfilepath = os.path.join(everycolab, colabfilename)\n",
|
| 324 |
+
"\n",
|
| 325 |
+
"if os.path.exists(chosencolabfilepath):\n",
|
| 326 |
+
" print(\"\u001b[1;32mGathering aria2c code from \" + chosencolabfilepath + \"...\")\n",
|
| 327 |
+
" print('\u001b[0m')\n",
|
| 328 |
+
" with open(chosencolabfilepath, 'r', encoding='utf-8') as f:\n",
|
| 329 |
+
" for line in f:\n",
|
| 330 |
+
" stripped_line = line.strip()\n",
|
| 331 |
+
" if stripped_line.startswith('\"!aria2c'):\n",
|
| 332 |
+
" aria2c_lines.append(stripped_line)\n",
|
| 333 |
+
"\n",
|
| 334 |
+
"if aria2c_lines:\n",
|
| 335 |
+
" # Every aria2c lines in camenduru's notebook, in which case it's either a checkpoint model, controlnet model, or a vae link\n",
|
| 336 |
+
" pickledump(aria2c_lines, 'arialist')\n",
|
| 337 |
+
"\n",
|
| 338 |
+
"colaboptions[\"empty_model\"] = emptymodel\n",
|
| 339 |
+
"\n",
|
| 340 |
+
"pickledump(colaboptions, 'colaboptions')\n",
|
| 341 |
+
"\n",
|
| 342 |
+
"# !python /content/vcltools/camendurucolab.py {colabfilename} {repo_branch} part1\n",
|
| 343 |
+
"!apt -y update -qq\n",
|
| 344 |
+
"#👇 Memory fix by camenduru & slowargo\n",
|
| 345 |
+
"if not os.path.exists(\"/content/libtcmalloc_minimal.so.4\"):\n",
|
| 346 |
+
" !git clone -b colab https://github.com/camenduru/gperftools\n",
|
| 347 |
+
" %cd /content/gperftools\n",
|
| 348 |
+
" %env CXXFLAGS=-std=c++14\n",
|
| 349 |
+
" !chmod +x /content/gperftools/configure\n",
|
| 350 |
+
" print(\"building libtcmalloc_minimal.so.4, please wait...\")\n",
|
| 351 |
+
" !(./configure --enable-minimal --enable-libunwind --enable-frame-pointers --enable-dynamic-sized-delete-support --enable-sized-delete --enable-emergency-malloc; make -j4) > /content/libtcmalloc_buildlog.txt 2>&1\n",
|
| 352 |
+
" !cp .libs/libtcmalloc*.so* /content\n",
|
| 353 |
+
"%env LD_PRELOAD=/content/libtcmalloc_minimal.so.4\n",
|
| 354 |
+
"%cd /content\n",
|
| 355 |
+
"\n",
|
| 356 |
+
"def thispickleexist(filename):\n",
|
| 357 |
+
" return os.path.exists(os.path.join(vclvarpath, filename + \".pkl\"))\n",
|
| 358 |
+
"\n",
|
| 359 |
+
"if not thispickleexist(\"extensions\") or not thispickleexist(\"removedextensions\"):\n",
|
| 360 |
+
" no_model_install_extension()\n",
|
| 361 |
+
"\n",
|
| 362 |
+
"# This runs every download process from camenduru's notebook, like git clones\n",
|
| 363 |
+
"# Needs 'colaboptions', 'extensions', and 'removedextensions'\n",
|
| 364 |
+
"!python /content/vcltools/camendurucolab3.py #{colabfilename} {repo_branch} part2\n",
|
| 365 |
+
"\n",
|
| 366 |
+
"# This runs the aria2c lines\n",
|
| 367 |
+
"!python /content/vcltools/runaria3.py\n",
|
| 368 |
+
"\n",
|
| 369 |
+
"%cd /content/volatile-concentration-localux\n",
|
| 370 |
+
"\n",
|
| 371 |
+
"# if extensiontoremove and not emptymodel:\n",
|
| 372 |
+
"# for ext in extensiontoremove:\n",
|
| 373 |
+
"# extpath = os.path.join('/content/volatile-concentration-localux/extensions', ext)\n",
|
| 374 |
+
"# if os.path.exists(extpath):\n",
|
| 375 |
+
"# shutil.rmtree(extpath)\n",
|
| 376 |
+
"# print(f\"removed {ext} extension\")\n",
|
| 377 |
+
"\n",
|
| 378 |
+
"# !python /content/vcltools/camendurucolab.py {colabfilename} {repo_branch} part3\n",
|
| 379 |
+
"\n",
|
| 380 |
+
"if prevbranch and prevbranch != repo_branch:\n",
|
| 381 |
+
" !python /content/vcltools/changebranch.py restore\n",
|
| 382 |
+
"pickledump(repo_branch, \"prevbranch\")\n",
|
| 383 |
+
"\n",
|
| 384 |
+
"# 👇 Now it's being handled in camendurucolab3.py\n",
|
| 385 |
+
"# !sed -i -e '''/from modules import launch_utils/a\\import os''' /content/volatile-concentration-localux/launch.py\n",
|
| 386 |
+
"# !sed -i -e '''/ prepare_environment()/a\\ os.system\\(f\\\"\"\"sed -i -e ''\\\"s/dict()))/dict())).cuda()/g\\\"'' /content/volatile-concentration-localux/repositories/stable-diffusion-stability-ai/ldm/util.py\"\"\")''' /content/volatile-concentration-localux/launch.py\n",
|
| 387 |
+
"# !sed -i -e 's/\\\"sd_model_checkpoint\\\"\\]/\\\"sd_model_checkpoint\\\"\\,\\\"sd_vae\\\"\\,\\\"CLIP_stop_at_last_layers\\\"\\]/g' /content/volatile-concentration-localux/modules/shared.py\n",
|
| 388 |
+
"\n",
|
| 389 |
+
"print(\"\u001b[1;32mlaunching the webui...\")\n",
|
| 390 |
+
"print('\u001b[0m')\n",
|
| 391 |
+
"\n",
|
| 392 |
+
"!python /content/vcltools/setuptimer.py\n",
|
| 393 |
+
"!echo -n {start_colab} > /content/volatile-concentration-localux/static/colabTimer.txt\n",
|
| 394 |
+
"!wget -q https://raw.githubusercontent.com/etherealxx/batchlinks-webui/main/notification.mp3 -P /content/volatile-concentration-localux\n",
|
| 395 |
+
"\n",
|
| 396 |
+
"!python launch.py --listen --xformers --enable-insecure-extension-access --theme dark --gradio-queue --multiple"
|
| 397 |
+
]
|
| 398 |
+
},
|
| 399 |
+
{
|
| 400 |
+
"cell_type": "markdown",
|
| 401 |
+
"metadata": {
|
| 402 |
+
"id": "ZGlOpxFdEIB5"
|
| 403 |
+
},
|
| 404 |
+
"source": [
|
| 405 |
+
"(If you got 'Error 403' when the big orange button is supposed to shows up, read [here](https://github.com/etherealxx/volatile-concentration-localux-colab/blob/main/error403guide.md) for the fix)"
|
| 406 |
+
]
|
| 407 |
+
},
|
| 408 |
+
{
|
| 409 |
+
"cell_type": "markdown",
|
| 410 |
+
"metadata": {
|
| 411 |
+
"id": "dYiw0gLVRpTz"
|
| 412 |
+
},
|
| 413 |
+
"source": [
|
| 414 |
+
"## ⠀"
|
| 415 |
+
]
|
| 416 |
+
},
|
| 417 |
+
{
|
| 418 |
+
"cell_type": "markdown",
|
| 419 |
+
"metadata": {
|
| 420 |
+
"id": "0BEVRlWUcbj3"
|
| 421 |
+
},
|
| 422 |
+
"source": [
|
| 423 |
+
" ### (debug area)"
|
| 424 |
+
]
|
| 425 |
+
},
|
| 426 |
+
{
|
| 427 |
+
"cell_type": "code",
|
| 428 |
+
"execution_count": null,
|
| 429 |
+
"metadata": {
|
| 430 |
+
"id": "ZokmtbXibfQf"
|
| 431 |
+
},
|
| 432 |
+
"outputs": [],
|
| 433 |
+
"source": [
|
| 434 |
+
"from google.colab import drive\n",
|
| 435 |
+
"drive.mount('/content/drive')"
|
| 436 |
+
]
|
| 437 |
+
},
|
| 438 |
+
{
|
| 439 |
+
"cell_type": "code",
|
| 440 |
+
"execution_count": null,
|
| 441 |
+
"metadata": {
|
| 442 |
+
"id": "pij1YzxGDw7y"
|
| 443 |
+
},
|
| 444 |
+
"outputs": [],
|
| 445 |
+
"source": [
|
| 446 |
+
"!rm -rf /content/vclvariables\n",
|
| 447 |
+
"!rm -rf /content/volatile-concentration-localux\n",
|
| 448 |
+
"!rm -rf /content/vcltools\n",
|
| 449 |
+
"%cd /content\n",
|
| 450 |
+
"!git clone -b dev8 https://github.com/etherealxx/volatile-concentration-localux-colab /content/vcltools"
|
| 451 |
+
]
|
| 452 |
+
},
|
| 453 |
+
{
|
| 454 |
+
"cell_type": "code",
|
| 455 |
+
"execution_count": null,
|
| 456 |
+
"metadata": {
|
| 457 |
+
"id": "e-bXoxXtbgeY"
|
| 458 |
+
},
|
| 459 |
+
"outputs": [],
|
| 460 |
+
"source": [
|
| 461 |
+
"import os\n",
|
| 462 |
+
"import shutil\n",
|
| 463 |
+
"\n",
|
| 464 |
+
"def copy_files(source_dir, destination_dir):\n",
|
| 465 |
+
" # Create destination directory if it doesn't exist\n",
|
| 466 |
+
" if not os.path.exists(destination_dir):\n",
|
| 467 |
+
" os.makedirs(destination_dir)\n",
|
| 468 |
+
" print(f\"Created directory: {destination_dir}\")\n",
|
| 469 |
+
"\n",
|
| 470 |
+
" # Get the list of files in the source directory\n",
|
| 471 |
+
" files = os.listdir(source_dir)\n",
|
| 472 |
+
"\n",
|
| 473 |
+
" for file in files:\n",
|
| 474 |
+
" source_file = os.path.join(source_dir, file)\n",
|
| 475 |
+
" destination_file = os.path.join(destination_dir, file)\n",
|
| 476 |
+
"\n",
|
| 477 |
+
" # Copy the file to the destination directory\n",
|
| 478 |
+
" shutil.copy2(source_file, destination_file)\n",
|
| 479 |
+
"\n",
|
| 480 |
+
" # Print success message with the filename\n",
|
| 481 |
+
" print(f\"Successfully copied {file}.\")\n",
|
| 482 |
+
"\n",
|
| 483 |
+
"# Specify the source and destination directories\n",
|
| 484 |
+
"folder_A = \"/content/volatile-concentration-localux/outputs/txt2img-images/xxx\"\n",
|
| 485 |
+
"folder_B = \"/content/drive/MyDrive/xxx\"\n",
|
| 486 |
+
"\n",
|
| 487 |
+
"# Copy files from folder A to folder B\n",
|
| 488 |
+
"copy_files(folder_A, folder_B)"
|
| 489 |
+
]
|
| 490 |
+
},
|
| 491 |
+
{
|
| 492 |
+
"cell_type": "code",
|
| 493 |
+
"execution_count": null,
|
| 494 |
+
"metadata": {
|
| 495 |
+
"id": "nSGdJN0OAqDL"
|
| 496 |
+
},
|
| 497 |
+
"outputs": [],
|
| 498 |
+
"source": [
|
| 499 |
+
"%cd /content\n",
|
| 500 |
+
"!git clone https://github.com/etherealxx/volatile-concentration-localux-colab /content/colabtools"
|
| 501 |
+
]
|
| 502 |
+
},
|
| 503 |
+
{
|
| 504 |
+
"cell_type": "code",
|
| 505 |
+
"execution_count": null,
|
| 506 |
+
"metadata": {
|
| 507 |
+
"id": "g4UAZfaZ4wgo"
|
| 508 |
+
},
|
| 509 |
+
"outputs": [],
|
| 510 |
+
"source": [
|
| 511 |
+
"!rm -rf /content/volatile-concentration-localux\n",
|
| 512 |
+
"!rm -rf /content/camendurus\n",
|
| 513 |
+
"!rm /content/frpc_linux_amd64"
|
| 514 |
+
]
|
| 515 |
+
},
|
| 516 |
+
{
|
| 517 |
+
"cell_type": "code",
|
| 518 |
+
"execution_count": null,
|
| 519 |
+
"metadata": {
|
| 520 |
+
"id": "--HDCkoxCHnT"
|
| 521 |
+
},
|
| 522 |
+
"outputs": [],
|
| 523 |
+
"source": [
|
| 524 |
+
"import os, pickle\n",
|
| 525 |
+
"\n",
|
| 526 |
+
"toopen = '/content/vclvariables/extensions.pkl'\n",
|
| 527 |
+
"\n",
|
| 528 |
+
"if os.path.exists(toopen):\n",
|
| 529 |
+
" with open(toopen, 'rb') as f:\n",
|
| 530 |
+
" arialines2 = pickle.load(f)\n",
|
| 531 |
+
"\n",
|
| 532 |
+
"for line in arialines2:\n",
|
| 533 |
+
" print(line)"
|
| 534 |
+
]
|
| 535 |
+
},
|
| 536 |
+
{
|
| 537 |
+
"cell_type": "code",
|
| 538 |
+
"execution_count": null,
|
| 539 |
+
"metadata": {
|
| 540 |
+
"id": "pE0A4A_jGXkR"
|
| 541 |
+
},
|
| 542 |
+
"outputs": [],
|
| 543 |
+
"source": [
|
| 544 |
+
"repo_branch = 'nightly' #@param [\"lite\", \"stable\", \"nightly\"]\n",
|
| 545 |
+
"\n",
|
| 546 |
+
"colaboptions = {\n",
|
| 547 |
+
" \"branch\": repo_branch,\n",
|
| 548 |
+
" \"filename\": \"stable_diffusion_1_5_webui_colab.ipynb\",\n",
|
| 549 |
+
" \"part\": \"part2\"\n",
|
| 550 |
+
"} #default\n",
|
| 551 |
+
"\n",
|
| 552 |
+
"\n",
|
| 553 |
+
"print(colaboptions['branch'])"
|
| 554 |
+
]
|
| 555 |
+
},
|
| 556 |
+
{
|
| 557 |
+
"cell_type": "code",
|
| 558 |
+
"execution_count": null,
|
| 559 |
+
"metadata": {
|
| 560 |
+
"id": "ouZRtBpEMq3V"
|
| 561 |
+
},
|
| 562 |
+
"outputs": [],
|
| 563 |
+
"source": [
|
| 564 |
+
"with open('/content/camendurus/nightly/a_certain_model_webui_colab.ipynb', 'r', encoding='utf-8') as f:\n",
|
| 565 |
+
" for line in f:\n",
|
| 566 |
+
" stripped_line = line.strip()\n",
|
| 567 |
+
" if stripped_line.startswith('\"!aria2c'):\n",
|
| 568 |
+
" # aria2c_lines.append(stripped_line)\n",
|
| 569 |
+
" print(\"\u001b[1;32m\" + stripped_line)\n",
|
| 570 |
+
" print('\u001b[0m')\n",
|
| 571 |
+
" else:\n",
|
| 572 |
+
" print(stripped_line)"
|
| 573 |
+
]
|
| 574 |
+
},
|
| 575 |
+
{
|
| 576 |
+
"cell_type": "code",
|
| 577 |
+
"execution_count": null,
|
| 578 |
+
"metadata": {
|
| 579 |
+
"id": "jKUgiWbaN-TW"
|
| 580 |
+
},
|
| 581 |
+
"outputs": [],
|
| 582 |
+
"source": [
|
| 583 |
+
"checktest = None\n",
|
| 584 |
+
"with open('/content/arialist.pkl', 'rb') as f:\n",
|
| 585 |
+
" checktest = pickle.load(f)\n",
|
| 586 |
+
"print(checktest)"
|
| 587 |
+
]
|
| 588 |
+
},
|
| 589 |
+
{
|
| 590 |
+
"cell_type": "code",
|
| 591 |
+
"execution_count": null,
|
| 592 |
+
"metadata": {
|
| 593 |
+
"id": "uYmGyckPbZaQ"
|
| 594 |
+
},
|
| 595 |
+
"outputs": [],
|
| 596 |
+
"source": []
|
| 597 |
+
}
|
| 598 |
+
],
|
| 599 |
+
"metadata": {
|
| 600 |
+
"accelerator": "GPU",
|
| 601 |
+
"colab": {
|
| 602 |
+
"collapsed_sections": [
|
| 603 |
+
"e78dCt3JZ6UX",
|
| 604 |
+
"0BEVRlWUcbj3"
|
| 605 |
+
],
|
| 606 |
+
"private_outputs": true,
|
| 607 |
+
"provenance": []
|
| 608 |
+
},
|
| 609 |
+
"gpuClass": "standard",
|
| 610 |
+
"kernelspec": {
|
| 611 |
+
"display_name": "Python 3",
|
| 612 |
+
"language": "python",
|
| 613 |
+
"name": "python3"
|
| 614 |
+
},
|
| 615 |
+
"language_info": {
|
| 616 |
+
"name": "python",
|
| 617 |
+
"version": "3.9.6"
|
| 618 |
+
},
|
| 619 |
+
"vscode": {
|
| 620 |
+
"interpreter": {
|
| 621 |
+
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
|
| 622 |
+
}
|
| 623 |
+
}
|
| 624 |
+
},
|
| 625 |
+
"nbformat": 4,
|
| 626 |
+
"nbformat_minor": 0
|
| 627 |
+
}
|