From c53252af2602a9e1e646a368b2c5882fd52fa013 Mon Sep 17 00:00:00 2001 From: Etherealxx Date: Sun, 10 Sep 2023 07:12:50 +0700 Subject: [PATCH] sd-webui-reactor as optional extension - Added `sd-webui-reactor` (roop alternative) as optional choosable extension. `additionalextensions.txt` now support running bash code if an extension is selected (mostly for dependencies). --- README.md | 1 + additionalextensions.txt | 7 ++++++- camendurucolab3.py | 12 ++++++++++-- extensioninstaller3.py | 21 ++++++++++++++++++--- volatile_concentration_localux_colab.ipynb | 21 +++++++++++++++++++-- 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0476e02..5ee8f4b 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Huge thanks to [camenduru](https://github.com/camenduru), without him this colab Read [here](https://github.com/etherealxx/volatile-concentration-localux-colab/blob/main/error403guide.md) for guide to fix it. ### 🆙 Latest Update: +- 10/09/2023 (September): Added `sd-webui-reactor` (roop alternative) as optional choosable extension. `additionalextensions.txt` now support running bash code if an extension is selected (mostly for dependencies). - 12/08/2023 (August): Gradio version bump to v3.37.0 (fixing the bug where extension selection doesn't appear and when orange button is pressed, error JSON input will shows up). ~~gradio_client version bump to v0.2.10 to matches the Gradio version.~~ - 27/07/2023 (July): Memory fix. The sed lines are now synced with camenduru's repo. - 22/07/2023 (July): Added a little bit of documentation on the colab notebook. Removed unused old scripts. Fixed bug where unticking `choose_model` while at the same time ticking `controlnet_models` on the notebook makes SD fails to launch. Now changing branch after running the main cell atleast once will preserve the previously downloaded models and generated outputs. diff --git a/additionalextensions.txt b/additionalextensions.txt index 4ce1792..a655497 100644 --- a/additionalextensions.txt +++ b/additionalextensions.txt @@ -2,6 +2,7 @@ #_You can make a pull request and add your desired extension link here #_Line that starts with #branch will determine the repo's branch, the format is '#branch #_Line that starts with #commit will determine the repo's branch, the format is '#commit +#_Line that starts with #run will be run with subprocess when the extension is selected, the format is '#run ' #@Ahmedkel's request https://github.com/DominikDoom/a1111-sd-webui-tagcomplete @@ -13,4 +14,8 @@ https://github.com/a2569875/stable-diffusion-webui-composable-lora https://github.com/hnmr293/sd-webui-cutoff https://github.com/zanllp/sd-webui-infinite-image-browsing https://github.com/Coyote-A/ultimate-upscale-for-automatic1111 -https://github.com/Bing-su/adetailer \ No newline at end of file +https://github.com/Bing-su/adetailer + +#@otorre1's request, roop alternative +https://github.com/Gourieff/sd-webui-reactor +#run sd-webui-reactor pip install -q insightface==0.7.3 onnx==1.14.0 onnxruntime==1.15.0 opencv-python==4.7.0.72 tqdm \ No newline at end of file diff --git a/camendurucolab3.py b/camendurucolab3.py index 9a81c63..4a190c5 100644 --- a/camendurucolab3.py +++ b/camendurucolab3.py @@ -168,18 +168,26 @@ def rulesbroken(codetoexecute, sedlines=None): # Dumped from the main colab, where it compares every extensions to those chosen by user # ... resulting extensions to be removed/blacklisted extensiontoremove = pickleload(None, 'removedextensions') +extensionrequirements = pickleload(None, 'extrequirements') installextensions = [] for ext_line in extensionlines: + def addlineandcheck(name, line): + installextensions.append(line) + if name in extensionrequirements: + if extensionrequirements[name].startswith(name): + extensionrequirements[name] = extensionrequirements[name].lstrip(name) + installextensions.append(extensionrequirements[name]) + pattern = r"https://github.com/\S+/(\S+)" match = re.search(pattern, ext_line) if match: ext_name = match.group(1) if extensiontoremove: if not ext_name in extensiontoremove: - installextensions.append(ext_line) + addlineandcheck(ext_name, ext_line) else: - installextensions.append(ext_line) + addlineandcheck(ext_name, ext_line) # for x in ("linetoexecute_part1", "linetoexecute_part2", "linetoexecute_part2_1", "linetoexecute_part2_2", "linetoexecute_part3"): # print(f"{x} = {str(eval(x))}") diff --git a/extensioninstaller3.py b/extensioninstaller3.py index fc1f482..6ce4e0c 100644 --- a/extensioninstaller3.py +++ b/extensioninstaller3.py @@ -29,11 +29,13 @@ def list_additional_ext(): with open(addext_txtpath, 'r') as file: lines = [line.rstrip('\n') for line in file] exts = [ext for ext in lines if ext != "" and not ext.startswith("#")] + # commits and branches functions are untested and might not work commits = [ext.lstrip("#commit") for ext in lines if ext != "" and ext.startswith("#commit")] branches = [ext.lstrip("#branch") for ext in lines if ext != "" and ext.startswith("#branch")] - return exts, commits, branches + commands = [ext.lstrip("#run") for ext in lines if ext != "" and ext.startswith("#run")] + return exts, commits, branches, commands -additionalextensions, additionalcommits, additionalbranches = list_additional_ext() +additionalextensions, additionalcommits, additionalbranches, additionalcommands = list_additional_ext() # Dumped from the main colab colaboptions = pickleload(None, 'colaboptions') @@ -69,10 +71,12 @@ def list_additional_ext(): commandtoappend = stripped_line.replace('/content/stable-diffusion-webui', '/content/volatile-concentration-localux') extensionlines.append(commandtoappend) +linestorun = dict() + for addextgithublink in additionalextensions: gitclonestring = 'git clone https://github.com/' repoowner = addextgithublink.split("/")[-2] - reponame = addextgithublink.split("/")[-1] + reponame = addextgithublink.split("/")[-1].strip() for branchline in additionalbranches: if reponame in branchline: specificbranch = branchline.lstrip(reponame).strip() @@ -80,12 +84,23 @@ def list_additional_ext(): break extensionlines.append(f"{gitclonestring}{repoowner}/{reponame} {extensionpath}{reponame}") + for commitline in additionalcommits: if reponame in commitline: specificcommit = commitline.lstrip(reponame).strip() extensionlines.append(f"git checkout {specificcommit} .") break + + for commandline in additionalcommands: + if reponame in commandline: + linestorun[reponame] = commandline.lstrip(reponame).strip() +if linestorun: + pickledump(linestorun, 'extrequirements') +else: + extreqpath = os.path.join(vclvarpath, "extrequirements.pkl") + if os.path.exist(extreqpath): + os.remove(extreqpath) # extensionlines.append(f"{gitclonestring}a2569875/stable-diffusion-webui-composable-lora {extensionpath}stable-diffusion-webui-composable-lora") # extensionlines.append(f"{gitclonestring}DominikDoom/a1111-sd-webui-tagcomplete {extensionpath}a1111-sd-webui-tagcomplete") diff --git a/volatile_concentration_localux_colab.ipynb b/volatile_concentration_localux_colab.ipynb index 9394e32..f7abd03 100644 --- a/volatile_concentration_localux_colab.ipynb +++ b/volatile_concentration_localux_colab.ipynb @@ -18,7 +18,7 @@ "source": [ "##***Project `VCL-colab`***\n", "### All camenduru colab in one spot, synced in realtime\n", - "###### Last time updated: Aug 12, 23\n", + "###### Last time updated: Sep 10, 23\n", "###### (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).)" ] }, @@ -457,7 +457,7 @@ "!rm -rf /content/volatile-concentration-localux\n", "!rm -rf /content/vcltools\n", "%cd /content\n", - "!git clone -b dev8 https://github.com/etherealxx/volatile-concentration-localux-colab /content/vcltools" + "!git clone -b dev9 https://github.com/etherealxx/volatile-concentration-localux-colab /content/vcltools" ] }, { @@ -498,6 +498,23 @@ "copy_files(folder_A, folder_B)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# to remove folder and it's subdirectories from a specific path. Need this bcoz of the keyword ban\n", + "import os\n", + "keyword = \"reactor\"\n", + "\n", + "extpath = \"/content/volatile-concentration-localux/extensions\"\n", + "for folder in os.listdir(extpath):\n", + " if keyword in folder:\n", + " folderpath = os.path.join(extpath, folder)\n", + " !rm -rf {folderpath}" + ] + }, { "cell_type": "code", "execution_count": null,