Skip to content

Commit

Permalink
sd-webui-reactor as optional extension
Browse files Browse the repository at this point in the history
- 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).
  • Loading branch information
etherealxx committed Sep 10, 2023
1 parent 4bb8103 commit c53252a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion additionalextensions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <reponame> <branchname>
#_Line that starts with #commit will determine the repo's branch, the format is '#commit <reponame> <commitnumber>
#_Line that starts with #run will be run with subprocess when the extension is selected, the format is '#run <reponame> <command>'

#@Ahmedkel's request
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete
Expand All @@ -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
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
12 changes: 10 additions & 2 deletions camendurucolab3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))}")
Expand Down
21 changes: 18 additions & 3 deletions extensioninstaller3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -69,23 +71,36 @@ 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()
gitclonestring = f'git clone -b {specificbranch} https://github.com/'
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")

Expand Down
21 changes: 19 additions & 2 deletions volatile_concentration_localux_colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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).)"
]
},
Expand Down Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c53252a

Please sign in to comment.