├── README.md
├── additionalextension.py
├── additionalextensions.txt
├── batchlinksdebug.py
├── camendurucolab3.py
├── changebranch.py
├── choosemodel4.py
├── cloneall3.py
├── colab-timer.js
├── error403guide.md
├── extensioninstaller3.py
├── images
├── guide1.png
├── guide2.png
├── guide3.png
├── guide4.png
└── guide5.png
├── runaria3.py
├── setuptimer.py
├── volatile-concentration-localux_colab_downloader.ipynb
├── volatile_concentration_localux_colab.ipynb
└── volatile_concentration_localux_colab_backup.ipynb
/README.md:
--------------------------------------------------------------------------------
1 | [](https://colab.research.google.com/github/etherealxx/volatile-concentration-localux-colab/blob/main/volatile_concentration_localux_colab.ipynb) <- Click here to access the colab
2 | # Project VCL-Colab
3 | Another camenduru colab ~~clone~~ alternative.😋
4 | May only works for Colab Pro user.
5 |
6 | Features:
7 | - All camenduru colab flavor in one single colab
8 | - Option to choose model from a Gradio UI directly on Colab cell output
9 | - Automatic update, synced in real time with Camenduru's repo
10 | - ~~Bypass the damned google colab warning (when it detects `stable-diffusion-webui` and `sd-webui` string)~~ MAY NOT WORK ANYMORE.
11 |
12 | The automatic update works by basically scraping from camenduru's repo, so it will automatically update the model list everytime camenduru's repo got new models.
13 | As long as he doesn't change much on the repo code, this colab will always works without the need to maintain it.
14 |
15 | Basically proof-of-concept. Would like to hear feedbacks and suggestion on the issues page.
16 |
17 | Huge thanks to [camenduru](https://github.com/camenduru), without him this colab wouldn't be possible. Check out his [original repo](https://github.com/camenduru/stable-diffusion-webui-colab).
18 |
19 | ### ⚠️ Things to Note!
20 | - The usual `/content/stable-diffusion-webui` is renamed to `/content/volatile-concentration-localux`, just keep in mind. Every file and folder inside is normal. (Pretty obvious though)
21 |
22 | ### ⚠️ Got an Error 403?
23 | Read [here](https://github.com/etherealxx/volatile-concentration-localux-colab/blob/main/error403guide.md) for guide to fix it.
24 |
25 | ### 🆙 Latest Update:
26 | - 12/01/2024 (February): Using camenduru's v2.7 branch to fix [this issue](https://github.com/camenduru/stable-diffusion-webui-colab/issues/494). Using `--disable-model-loading-ram-optimization` to fix another issue.
27 | - 10/01/2024 (February): Gradio version bump to v3.41.2. Updated `choosemodel4.py` to exclude camenduru's 'run' colab. Added `httpx` pip install. Merging the September branch (lol i forgot)
28 | - 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).
29 |
30 | -
31 | Older Updates
32 |
33 | - 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.~~
34 | - 27/07/2023 (July): Memory fix. The sed lines are now synced with camenduru's repo.
35 | - 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.
36 | - 20/07/2023 (July): Added functionality for the extension installer where extension's branch and commits are choosable in `additionalextensions.txt`. Removed the whole `libtcmalloc` lines. Adjusted the way this colab gather the code with the recent changes.
37 | - 10/07/2023 (July): Added `sd-webui-cutoff`, `sd-webui-infinite-image-browsing`, `ultimate-upscale-for-automatic1111`, and `adetailer` as optional choosable extension. Now optional extensions are stored on `additionalextensions.txt`. Now optional extensions are listed at the bottom of the extension checkboxes on the gradio UI.
38 | - 07/07/2023 (July): Fixed some typo in the repo extract code (fixed lite branch). Added `torchmetrics==0.11.4` as an additional dependency for lite branch.
39 | - 02/07/2023 (July): Bypass the new colab warning that detects `sd-webui` string.
40 | - 16/06/2023 (June): Added `a1111-sd-webui-tagcomplete` and `composable-lora extension` as optional choosable extension. Fixed 'all extension is missing' bug.
41 |
42 |
43 |
--------------------------------------------------------------------------------
/additionalextension.py:
--------------------------------------------------------------------------------
1 | import os, pickle
2 |
3 | vclvarpath = '/content/vclvariables'
4 | def pickledump(vartodump, outputfile):
5 | outputpath = os.path.join(vclvarpath, outputfile + '.pkl')
6 | with open(outputpath, 'wb') as f:
7 | pickle.dump(vartodump, f)
8 |
9 | def pickleload(prevvalue, inputfile):
10 | inputpath = os.path.join(vclvarpath, inputfile + '.pkl')
11 | if os.path.exists(inputpath):
12 | with open(inputpath, 'rb') as f:
13 | vartopass = pickle.load(f)
14 | return vartopass
15 | else:
16 | return prevvalue
17 |
18 | def list_additional_ext():
19 | addext_txtpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "additionalextensions.txt")
20 | with open(addext_txtpath, 'r') as file:
21 | lines = [line.rstrip('\n') for line in file]
22 | exts = [ext for ext in lines if ext != "" and not ext.startswith("#")]
23 | return exts
24 |
25 | # Dumped from the main colab notebook. List of extension names
26 | everyextension = pickleload(None, 'fullextensions')
27 |
28 | additionalextensions = list_additional_ext()
29 |
30 | extnameonly = [x.split("/")[-1] for x in additionalextensions] # Separating extension (repo) name from the full github link
31 |
32 | # Extensions that are from camenduru's repo
33 | templist = [x for x in everyextension if x not in extnameonly]
34 | pickledump(templist, 'tempext')
--------------------------------------------------------------------------------
/additionalextensions.txt:
--------------------------------------------------------------------------------
1 | #_Line with hashtag on front will get ignored, excepts line that starts with #branch or #commit
2 | #_You can make a pull request and add your desired extension link here
3 | #_Line that starts with #branch will determine the repo's branch, the format is '#branch
4 | #_Line that starts with #commit will determine the repo's branch, the format is '#commit
5 | #_Line that starts with #run will be run with subprocess when the extension is selected, the format is '#run '
6 |
7 | #@Ahmedkel's request
8 | https://github.com/DominikDoom/a1111-sd-webui-tagcomplete
9 |
10 | #@basedholychad's request
11 | https://github.com/a2569875/stable-diffusion-webui-composable-lora
12 |
13 | #@Orbimac's requests
14 | https://github.com/hnmr293/sd-webui-cutoff
15 | https://github.com/zanllp/sd-webui-infinite-image-browsing
16 | https://github.com/Coyote-A/ultimate-upscale-for-automatic1111
17 | https://github.com/Bing-su/adetailer
18 |
19 | #@otorre1's request, roop alternative
20 | https://github.com/Gourieff/sd-webui-reactor
21 | #run sd-webui-reactor pip install -q insightface==0.7.3 onnx "onnxruntime-gpu>=1.16.1" opencv-python tqdm
--------------------------------------------------------------------------------
/batchlinksdebug.py:
--------------------------------------------------------------------------------
1 | import os, subprocess, sys, shlex, pickle
2 |
3 | curdir = '/content'
4 | branch = '-b uiupdate+aria ' #'-b ariacivitnew ' <-space in the end
5 | linetoexecute = [
6 | 'git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui /content/volatile-concentration-localux',
7 | f'git clone {branch}https://github.com/etherealxx/batchlinks-webui /content/volatile-concentration-localux/extensions/batchlinks-webui'
8 | ]
9 |
10 | def rulesbroken(codetoexecute, cwd=''):
11 | global curdir
12 | for line in codetoexecute:
13 | line = line.strip()
14 | try:
15 | if curdir:
16 | print("[1;32m" + line)
17 | print('[0m')
18 | splittedcommand = shlex.split(line)
19 | # subprocess.run(line, shell=True, check=True, cwd=curdir)
20 | process = subprocess.Popen(splittedcommand, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, cwd=curdir)
21 | while True:
22 | # Read the output from the process
23 | nextline = process.stdout.readline()
24 | if nextline == '' and process.poll() is not None:
25 | break
26 | # Check if the line contains progress information
27 | else:
28 | if "%" in nextline.strip():
29 | stripnext = nextline.strip()
30 | print("\r", end="")
31 | print(f"\r{stripnext}", end='')
32 | else:
33 | print(nextline, end='')
34 |
35 | except Exception as e:
36 | print("Exception: " + str(e))
37 |
38 | rulesbroken(linetoexecute)
--------------------------------------------------------------------------------
/camendurucolab3.py:
--------------------------------------------------------------------------------
1 | import os, subprocess, shlex, pickle, re, shutil
2 |
3 | debugmode = False
4 | curdir = '/'
5 | linetoexecute_part1, linetoexecute_part2, linetoexecute_part2_1, linetoexecute_part2_2, linetoexecute_part3 = [], [], [], [], []
6 | startcapture = False
7 | afteraria = False
8 | currentpart = 'part1'
9 | parttoexecute = 'part1'
10 | currentbranch = 'stable'
11 | emptymodel = False
12 | gradio_client_ver = "0.2.10"
13 |
14 | filename = 'stable_diffusion_1_5_webui_colab.ipynb'
15 |
16 | vclvarpath = '/content/vclvariables'
17 |
18 | def pickleload(prevvalue, inputfile):
19 | inputpath = os.path.join(vclvarpath, inputfile + '.pkl')
20 | if os.path.exists(inputpath):
21 | with open(inputpath, 'rb') as f:
22 | vartopass = pickle.load(f)
23 | return vartopass
24 | else:
25 | return prevvalue
26 |
27 | # def printdebug(toprint):
28 | # if debugmode:
29 | # print(toprint)
30 |
31 | # Dumped from the main colab
32 | colaboptions = pickleload(None, 'colaboptions')
33 | if colaboptions:
34 | currentbranch = colaboptions["branch"]
35 | parttoexecute = colaboptions["part"]
36 | filename = colaboptions["filename"]
37 | emptymodel = colaboptions["empty_model"]
38 |
39 |
40 | colabpath = f"/content/camendurus/{currentbranch}/{filename}"
41 |
42 | if debugmode==True:
43 | colabpath = r"C:\Users\Ethereal\Downloads\526_mix_webui_colab.ipynb"
44 |
45 | print("[1;32mGathering code from " + colabpath + "...")
46 | print('[0m')
47 |
48 | camendururepo = 'camenduru/stable-diffusion-webui'
49 |
50 | with open(colabpath, 'r', encoding='utf-8') as f:
51 | for line in f:
52 | stripped_line = line.strip()
53 | if stripped_line.startswith(r'"%cd /content'):
54 | startcapture = True
55 | if startcapture:
56 | if stripped_line.startswith('"'):
57 | stripped_line = stripped_line[1:]
58 | if stripped_line.startswith('!'):
59 | stripped_line = stripped_line[1:]
60 | if stripped_line.endswith('\\n",'):
61 | stripped_line = stripped_line[:-4]
62 | if stripped_line.startswith('apt -y install'):
63 | currentpart = 'part2'
64 | # print("[1;33mprepare " + currentpart + "[0m: " + stripped_line)
65 | elif stripped_line.startswith("git clone") and "https://github.com" in stripped_line:
66 | if stripped_line.endswith(camendururepo):
67 | currentpart = 'part2'
68 | else:
69 | currentpart = 'part2_1'
70 | # print("[1;33mprepare " + currentpart + "[0m: " + stripped_line)
71 | elif stripped_line.startswith("%cd /content/stable-diffusion-webui"):
72 | currentpart = "part2_2"
73 | # print("[1;33mprepare " + currentpart + "[0m: " + stripped_line)
74 | elif stripped_line.startswith('sed'):
75 | currentpart = 'part3'
76 | # print("[1;33mprepare " + currentpart + "[0m: " + stripped_line)
77 |
78 | #camendururepo = 'camenduru/stable-diffusion-webui'
79 | if camendururepo in stripped_line and not '/content/volatile-concentration-localux' in stripped_line:
80 |
81 | # Attempt to fix `TypeError: kill() missing 1 required positional argument: 'self'` issue
82 | if "-b v2.4" in stripped_line:
83 | stripped_line = stripped_line.replace("-b v2.4", "-b v2.7")
84 |
85 | if (stripped_line.find(camendururepo) + len(camendururepo) == len(stripped_line) or stripped_line[stripped_line.find(camendururepo) + len(camendururepo)] in [' ', '\n']):
86 | stripped_line += ' /content/volatile-concentration-localux'
87 | # if currentbranch == "lite":
88 | # if "https://download.pytorch.org/whl/cu116" in stripped_line and not "torchmetrics==0.11.4" in stripped_line:
89 | # line_parts = stripped_line.partition("--extra-index-url")
90 | # stripped_line = line_parts[0].strip() + " torchmetrics==0.11.4 " + line_parts[1] + line_parts[2]
91 |
92 | # if "gradio_client" in stripped_line:
93 | # importedverpattern = r'(gradio_client==)(\S+)'
94 | # importedvermatch = re.search(importedverpattern, stripped_line)
95 | # if importedvermatch.group(2) != gradio_client_ver:
96 | # changedverpattern = r'(gradio_client==)\S+'
97 | # stripped_line = re.sub(changedverpattern, rf'\g<1>{gradio_client_ver}', stripped_line)
98 |
99 | if stripped_line:
100 | if stripped_line.startswith('aria2c') and not '4x-UltraSharp.pth' in stripped_line:
101 | pass
102 | elif stripped_line.startswith(r'%env'):
103 | pass
104 | elif stripped_line.startswith('python launch.py'):
105 | pass
106 | elif stripped_line=='rm *.deb':
107 | pass
108 | else:
109 | commandtoappend = stripped_line.replace('/content/stable-diffusion-webui', '/content/volatile-concentration-localux')
110 | if currentpart == 'part1':
111 | linetoexecute_part1.append(commandtoappend)
112 | elif currentpart == 'part2':
113 | linetoexecute_part2.append(commandtoappend)
114 | # print(f"appended to part2: {commandtoappend}")
115 | elif currentpart == 'part2_1':
116 | linetoexecute_part2_1.append(commandtoappend)
117 | # print(f"appended to part2_1: {commandtoappend}")
118 | elif currentpart == 'part2_2':
119 | linetoexecute_part2_2.append(commandtoappend)
120 | elif currentpart == 'part3':
121 | linetoexecute_part3.append(commandtoappend)
122 | if stripped_line.startswith('python launch.py'):
123 | startcapture = False
124 |
125 | def debugline(codetodebug):
126 | if codetodebug:
127 | # print(linetoexecute)
128 | for line in codetodebug:
129 | print(line)
130 |
131 | def rulesbroken(codetoexecute, sedlines=None):
132 | global curdir
133 | for line in codetoexecute:
134 | line = line.strip()
135 | if line.startswith('!'):
136 | line = line[1:]
137 | if not line == '':
138 | if line.startswith(r'%cd'):
139 | curdir = line.replace(r'%cd', '').strip()
140 | else:
141 | try:
142 | if curdir:
143 | print("[1;32m" + line)
144 | print('[0m')
145 | splittedcommand = shlex.split(line)
146 | if sedlines:
147 | # escapedcommand = line.replace(r'\"', r'\\"')
148 | # quotedcommand = shlex.quote(line)
149 | # print("commmand before: " + line)
150 | commandafter = line.replace('\\\\', '\\').replace('\\"', '"')
151 | # print("commmand after: " + commandafter)
152 | subprocess.run(commandafter, shell=True)
153 | else:
154 | process = subprocess.Popen(splittedcommand, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, cwd=curdir)
155 | while True:
156 | nextline = process.stdout.readline()
157 | if nextline == '' and process.poll() is not None:
158 | break
159 | else:
160 | if "%" in nextline.strip():
161 | stripnext = nextline.strip()
162 | print("\r", end="")
163 | print(f"\r{stripnext}", end='')
164 | else:
165 | print(nextline, end='')
166 |
167 | except Exception as e:
168 | print("Exception: " + str(e))
169 |
170 | # List of git clone lines
171 | extensionlines = pickleload(linetoexecute_part2_1, 'extensions')
172 |
173 | # Dumped from the main colab, where it compares every extensions to those chosen by user
174 | # ... resulting extensions to be removed/blacklisted
175 | extensiontoremove = pickleload(None, 'removedextensions')
176 | extensionrequirements = pickleload(None, 'extrequirements')
177 | installextensions = []
178 |
179 | for ext_line in extensionlines:
180 | def addlineandcheck(name, line):
181 | installextensions.append(line)
182 | if name in extensionrequirements:
183 | if extensionrequirements[name].startswith(name):
184 | extensionrequirements[name] = extensionrequirements[name].lstrip(name)
185 | installextensions.append(extensionrequirements[name])
186 |
187 | pattern = r"https://github.com/\S+/(\S+)"
188 | match = re.search(pattern, ext_line)
189 | if match:
190 | ext_name = match.group(1)
191 | if extensiontoremove:
192 | if not ext_name in extensiontoremove:
193 | addlineandcheck(ext_name, ext_line)
194 | else:
195 | addlineandcheck(ext_name, ext_line)
196 |
197 | # for x in ("linetoexecute_part1", "linetoexecute_part2", "linetoexecute_part2_1", "linetoexecute_part2_2", "linetoexecute_part3"):
198 | # print(f"[1;33m{x}[0m = {str(eval(x))}")
199 |
200 | # if debugmode==True:
201 | # debugline(linetoexecute_part1)
202 | # else:
203 | # if parttoexecute == 'part1':
204 | # # print("[1;33m" + parttoexecute + "[0m")
205 | # rulesbroken(linetoexecute_part1)
206 | # elif parttoexecute == 'part2':
207 | # print("[1;33m" + "part2" + "[0m")
208 |
209 | # print("linetoexecute_part2: " + str(linetoexecute_part2))
210 | # print("installextensions: " + str(installextensions))
211 | # print("linetoexecute_part2_2: " + str(linetoexecute_part2_2))
212 | # print("linetoexecute_part3: " + str(linetoexecute_part3))
213 |
214 | rulesbroken(linetoexecute_part2)
215 | # rulesbroken(linetoexecute_part2_1) # Do not use this, installextensions is linetoexecute_part2_1
216 | # print("[1;33m" + "part2_1" + "[0m")
217 | rulesbroken(installextensions)
218 | # print("[1;33m" + "part2_2" + "[0m")
219 | rulesbroken(linetoexecute_part2_2)
220 | rulesbroken(linetoexecute_part3, "sedlines")
221 | # elif parttoexecute == 'part3':
222 | # # print("[1;33m" + parttoexecute + "[0m")
223 | # rulesbroken(linetoexecute_part3, "sedlines")
224 |
225 | if extensiontoremove:
226 | for removed_ext in extensiontoremove:
227 | pattern = r"https://github.com/\S+/(\S+)"
228 | match = re.search(pattern, ext_line)
229 | if match:
230 | ext_name = match.group(1)
231 | if not ext_name in extensiontoremove:
232 | installextensions.append(ext_line)
233 |
234 | if not emptymodel:
235 | for ext in extensiontoremove:
236 | extpath = os.path.join('/content/volatile-concentration-localux/extensions', ext)
237 | if os.path.exists(extpath):
238 | shutil.rmtree(extpath)
239 | print(f"removed {ext} extension")
--------------------------------------------------------------------------------
/changebranch.py:
--------------------------------------------------------------------------------
1 | import os, shutil, sys, pickle
2 |
3 | mode = ''
4 |
5 | if len(sys.argv) == 2:
6 | arg = sys.argv[1]
7 | mode = arg
8 |
9 | def manualcopytree(source_dir, destination_dir):
10 | os.makedirs(destination_dir, exist_ok=True)
11 | for root, dirs, files in os.walk(source_dir):
12 | # Create a relative path from the source directory to the current directory being walked
13 | relative_path = os.path.relpath(root, source_dir)
14 | destination_subdir = os.path.join(destination_dir, relative_path)
15 |
16 | # Create the corresponding subdirectory in the destination directory if it doesn't exist
17 | os.makedirs(destination_subdir, exist_ok=True)
18 |
19 | for file in files:
20 | source_file_path = os.path.join(root, file)
21 | destination_file_path = os.path.join(destination_subdir, file)
22 |
23 | # Check if the file already exists in the destination directory
24 | if not os.path.exists(destination_file_path):
25 | # Copy the file from the source to the destination
26 | shutil.copy2(source_file_path, destination_file_path)
27 |
28 | temppath = "/content/temp"
29 | vclpath = "/content/volatile-concentration-localux"
30 |
31 | if mode == "backup":
32 | if os.path.exists(temppath):
33 | shutil.rmtree(temppath)
34 | print("Backing up generated outputs before changing branch...")
35 | manualcopytree(os.path.join(vclpath, "outputs"), os.path.join(temppath, "outputs"))
36 | print("Backing up downloaded models before changing branch...")
37 | manualcopytree(os.path.join(vclpath, "models"), os.path.join(temppath, "models"))
38 | shutil.rmtree(vclpath)
39 |
40 | elif mode == "restore":
41 | if os.path.exists(temppath):
42 | print("Restoring generated outputs after changing branch...")
43 | manualcopytree(os.path.join(temppath, "outputs"), os.path.join(vclpath, "outputs"))
44 | print("Restoring up downloaded models after changing branch...")
45 | manualcopytree(os.path.join(temppath, "models"), os.path.join(vclpath, "models"))
46 | shutil.rmtree(temppath)
--------------------------------------------------------------------------------
/choosemodel4.py:
--------------------------------------------------------------------------------
1 | import os, math, subprocess, pickle, sys
2 |
3 | branchtype = 'lite'
4 |
5 | if len(sys.argv) == 2:
6 | branchargs = sys.argv[1]
7 | branchtype = branchargs
8 |
9 | import gradio as gr
10 |
11 | # subprocess.run("apt -y install -qq aria2", shell=True, check=True)
12 |
13 | everycolab = f'/content/camendurus/{branchtype}'
14 | everycolabname = []
15 | colabnamepair = []
16 | for colabname in os.listdir(everycolab):
17 | if not colabname.endswith('_run.ipynb'):
18 | colabnamepruned = colabname.partition('_webui_colab.ipynb')[0]
19 | everycolabname.append(colabnamepruned)
20 |
21 | sortedcolabname = sorted(everycolabname)
22 |
23 | vclvarpath = '/content/vclvariables'
24 | def pickledump(vartodump, outputfile):
25 | outputpath = os.path.join(vclvarpath, outputfile + '.pkl')
26 | with open(outputpath, 'wb') as f:
27 | pickle.dump(vartodump, f)
28 |
29 | # 'sortedcolabname' will be accessed by the main colab notebook
30 | pickledump(sortedcolabname, 'sortedcolabname')
31 |
32 |
33 | # totalcolabcount = len(everycolabname)
34 | # for i, colabname in enumerate(sortedcolabname):
35 | # halfall = math.ceil(totalcolabcount / 2)
36 | # numberedname = "{} | {}".format(i, colabname.ljust(30))
37 | # if i <= halfall:
38 | # colabnamepair.append(numberedname)
39 | # else:
40 | # rev_index = (i - halfall) - 1
41 | # colabnamepair[rev_index] += "\t" + numberedname
42 |
43 | # for colabpair in colabnamepair:
44 | # print(colabpair)
45 |
46 | # chosencolabname = ''
47 |
48 | # while True:
49 | # choosenumber = input('Choose the number of the model you want: ')
50 | # if choosenumber.isdigit() and int(choosenumber) < totalcolabcount:
51 | # chosencolabname = sortedcolabname[int(choosenumber)] + '_webui_colab.ipynb'
52 | # print("Model from " + chosencolabname + " will be downloaded immediately after all the dependencies is installed. Please wait")
53 | # break
54 | # elif choosenumber == '':
55 | # print("No model will be pre-downloaded. Dependencies installation will continue.")
56 | # break
57 |
58 | # aria2c_lines = []
59 |
60 | # if chosencolabname:
61 | # if os.path.exists(os.path.join(everycolab, chosencolabname)):
62 | # with open(os.path.join(everycolab, chosencolabname), 'r', encoding='utf-8') as f:
63 | # for line in f:
64 | # stripped_line = line.strip()
65 | # if stripped_line.startswith('"!aria2c'):
66 | # aria2c_lines.append(stripped_line)
67 |
68 | # if aria2c_lines:
69 | # with open('/content/arialist.pkl', 'wb') as f:
70 | # pickle.dump(aria2c_lines, f)
--------------------------------------------------------------------------------
/cloneall3.py:
--------------------------------------------------------------------------------
1 | import subprocess
2 |
3 | repo_path = '/content/volatile-concentration-localux'
4 |
5 | codetorun = """
6 | !git clone https://github.com/camenduru/stable-diffusion-webui-colab /content/camendurus
7 | """
8 |
9 | lines = codetorun.splitlines()
10 |
11 | def rulesbroken(codetoexecute, cwd=''):
12 | for line in lines:
13 | line = line.strip()
14 | if line.startswith('!'):
15 | line = line[1:]
16 | if not line == '':
17 | try:
18 | if cwd:
19 | subprocess.run(line, shell=True, check=True, cwd=repo_path)
20 | else:
21 | subprocess.run(line, shell=True, check=True)
22 | except Exception as e:
23 | print("Exception: " + str(e))
24 |
25 | rulesbroken(lines)
26 |
--------------------------------------------------------------------------------
/colab-timer.js:
--------------------------------------------------------------------------------
1 | let startTime;
2 | let timeout;
3 | let myHeaders = new Headers();
4 | myHeaders.append("Bypass-Tunnel-Reminder", "Thanks for checking my code lol")
5 | myHeaders.append("ngrok-skip-browser-warning", "Seriously tho, thank you so much!")
6 | // hello nocrypt, etherealxx here. mind if i... ummm, borrow your code for a bit? 😋
7 |
8 | function updateTimer(el) {
9 | const a = (i) => (i < 10 ? "0" + i : i);
10 | const b = (x) => Math.floor(x);
11 | let c = b(Date.now() / 1000) - startTime;
12 | h = a(b(c / 3600));
13 | m = a(b((c / 60) % 60));
14 | s = a(b(c % 60));
15 | // console.log(h,m,s)
16 |
17 | // show different text betwen 4:58 and 5:15
18 | if (c > 298 && c < 315) {
19 | el.innerText =
20 | "Usually there's captcha at this time, please check your colab (" +
21 | h +
22 | ":" +
23 | m +
24 | ":" +
25 | s +
26 | ")";
27 | } else {
28 | el.innerText = h + ":" + m + ":" + s;
29 | }
30 |
31 | //refresh timer every 30 seconds
32 | if (c % 30 == 0) {
33 | refreshTimer(el, true);
34 | return;
35 | }
36 |
37 | timeout = setTimeout(() => updateTimer(el), 1000);
38 | }
39 |
40 | refreshTimer = (timerEl, notext = false) => {
41 | if (timeout) {
42 | clearTimeout(timeout);
43 | timeout = null;
44 | }
45 | if (!notext) timerEl.innerText = "Connecting...";
46 | fetch("file=static/colabTimer.txt", { cache: "no-store", headers: myHeaders })
47 | .then((response) => {
48 | if (response.status == 404) {
49 | timerEl.innerText = "Error. Colab disconnected!";
50 | return;
51 | }
52 | response.text().then((text) => {
53 | startTime = parseInt(text);
54 | if (isNaN(startTime))
55 | timerEl.innerText = "Error. NaN stuff... Maybe network error";
56 | else updateTimer(timerEl);
57 | });
58 | })
59 | .catch((err) => {
60 | console.log(err);
61 | timerEl.innerText = "Error. "+err;
62 | });
63 | };
64 |
65 | toggleNotification = (imgEl, audioEl, divEl) => {
66 | audioEl.muted = !audioEl.muted
67 | audioEl.currentTime = 0;
68 | audioEl.play();
69 | divEl.title = !audioEl.muted ? "Currently not-muted. Click to mute" : "Currently muted. Click to unmute";
70 | divEl.style.borderColor =
71 | !audioEl.muted
72 | ? "#00ff00"
73 | : "#ff0000";
74 | imgEl.src = audioEl.muted ? "https://api.iconify.design/ion:md-notifications-off.svg?color=%23ff0000" : "https://api.iconify.design/ion:md-notifications.svg?color=%2300ff00";
75 | }
76 |
77 | onUiLoaded(function () {
78 | const quickSettings = gradioApp().querySelector("#quicksettings");
79 | const audioEl = gradioApp().querySelector("#audio_notification > audio")
80 |
81 | if (gradioApp().querySelector("#nocrypt-timer") != null) return;
82 |
83 | let mainDiv = document.createElement("div");
84 | mainDiv.id = "nocrypt-timer";
85 | mainDiv.className = "flex justify-start";
86 | mainDiv.style = "gap: 10px; user-select: none; margin-block: -10px; transform-origin: left center; scale: 0.8;";
87 |
88 | let div2 = document.createElement("div");
89 | div2.className = "flex gap-2 items-center border-solid border gr-box";
90 | div2.style =
91 | "cursor: pointer; padding-block: 3px; width: fit-content; padding-inline: 5px; border-color: hsl(300, 65%, 61%); z-index: 999; background-color: transparent !important;";
92 | div2.title = "Colab Timer Integration by NoCrypt. Click to refresh.";
93 |
94 | let img = document.createElement("img");
95 | img.src =
96 | "https://ssl.gstatic.com/colaboratory-static/common/de56aa663d279b80074b6c21f69dc872/img/favicon.ico";
97 | img.width = 24;
98 | img.style.filter = "hue-rotate(270deg)";
99 |
100 | let timerEl = document.createElement("div");
101 | timerEl.style = "font-family: monospace;color: hsl(300, 65%, 61%);";
102 | timerEl.innerText = "Connecting...";
103 | div2.appendChild(img);
104 | div2.appendChild(timerEl);
105 | mainDiv.appendChild(div2);
106 | div2.onclick = () => refreshTimer(timerEl);
107 |
108 | // notification mute
109 | audioEl.volume = 0.6; // Request from RileyX: "its a bit too loud"
110 | let div3 = document.createElement("div");
111 | div3.className = "flex gap-2 items-center border-solid border gr-box";
112 | div3.style =
113 | "cursor: pointer; padding-block: 3px; width: fit-content; padding-inline: 5px; border-color: lime; z-index: 999; background-color: transparent !important;";
114 | div3.title = "Currently not-muted. Click to mute";
115 |
116 | let img2 = document.createElement("img");
117 | img2.src =
118 | "https://api.iconify.design/ion:md-notifications.svg?color=%2300ff00";
119 | img2.width = 20;
120 | div3.appendChild(img2);
121 | div3.onclick = () => toggleNotification(img2, audioEl, div3);
122 | mainDiv.appendChild(div3);
123 |
124 | quickSettings.parentNode.insertBefore(mainDiv, quickSettings.nextSibling);
125 | refreshTimer(timerEl);
126 | });
127 |
--------------------------------------------------------------------------------
/error403guide.md:
--------------------------------------------------------------------------------
1 | # Guide if you got Error 403
2 | ### Works on Chromium based browser (Including Bromite)
3 |
4 | - Click the three dots on the upper right corner and then click settings
5 |
6 |
7 |
8 |
9 | - Type `cookies` on the settings search bar and then click the **"Cookies and other site data"** options
10 |
11 |
12 |
13 |
14 | - When you arrived on the **"Cookies and other site data"** menu, scroll down
15 |
16 |
17 |
18 |
19 | - Look for **"Sites that can always use cookies"** option, and then click the **"Add"** button
20 |
21 |
22 |
23 |
24 | - Type `colab.research.google.com` and tick the **"Including third-party cookies on this site"** checkbox, and then click the **"Add"** button
25 |
26 |
27 |
28 |
29 | - You're done. Restart the colab (the runtime) and see if it now works
30 |
--------------------------------------------------------------------------------
/extensioninstaller3.py:
--------------------------------------------------------------------------------
1 | import os, pickle, re
2 |
3 | debugmode = False
4 | curdir = '/'
5 | startcapture = False
6 | afteraria = False
7 | currentbranch = 'stable'
8 | extensionlines = []
9 |
10 | filename = 'stable_diffusion_1_5_webui_colab.ipynb'
11 |
12 | vclvarpath = '/content/vclvariables'
13 | def pickledump(vartodump, outputfile):
14 | outputpath = os.path.join(vclvarpath, outputfile + '.pkl')
15 | with open(outputpath, 'wb') as f:
16 | pickle.dump(vartodump, f)
17 |
18 | def pickleload(prevvalue, inputfile):
19 | inputpath = os.path.join(vclvarpath, inputfile + '.pkl')
20 | if os.path.exists(inputpath):
21 | with open(inputpath, 'rb') as f:
22 | vartopass = pickle.load(f)
23 | return vartopass
24 | else:
25 | return prevvalue
26 |
27 | def list_additional_ext():
28 | addext_txtpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "additionalextensions.txt")
29 | with open(addext_txtpath, 'r') as file:
30 | lines = [line.rstrip('\n') for line in file]
31 | exts = [ext for ext in lines if ext != "" and not ext.startswith("#")]
32 | # commits and branches functions are untested and might not work
33 | commits = [ext.lstrip("#commit") for ext in lines if ext != "" and ext.startswith("#commit")]
34 | branches = [ext.lstrip("#branch") for ext in lines if ext != "" and ext.startswith("#branch")]
35 | commands = [ext.lstrip("#run") for ext in lines if ext != "" and ext.startswith("#run")]
36 | return exts, commits, branches, commands
37 |
38 | additionalextensions, additionalcommits, additionalbranches, additionalcommands = list_additional_ext()
39 |
40 | # Dumped from the main colab
41 | colaboptions = pickleload(None, 'colaboptions')
42 | if colaboptions:
43 | currentbranch = colaboptions["branch"]
44 | filename = colaboptions["filename"]
45 |
46 | colabpath = f"/content/camendurus/{currentbranch}/{filename}"
47 | if debugmode==True:
48 | colabpath = r"C:\Users\Ethereal\Downloads\526_mix_webui_colab.ipynb"
49 |
50 | extensionpath = "/content/volatile-concentration-localux/extensions/"
51 |
52 | with open(colabpath, 'r', encoding='utf-8') as f:
53 | pattern = r"(?
"
11 | ]
12 | },
13 | {
14 | "cell_type": "code",
15 | "source": [
16 | "#@title Model Downloader (try this one)\n",
17 | "%cd /content\n",
18 | "!git clone https://github.com/etherealxx/volatile-concentration-localux-colab /content/colabtools\n",
19 | "!pip install -q gradio\n",
20 | "!apt -y install -qq aria2\n",
21 | "\n",
22 | "import os, pickle\n",
23 | "import gradio as gr\n",
24 | "from IPython.display import clear_output\n",
25 | "\n",
26 | "!python /content/colabtools/cloneall2.py\n",
27 | "!python /content/colabtools/choosemodel2.py\n",
28 | "\n",
29 | "if os.path.exists('/content/sortedcolabname.pkl'):\n",
30 | " with open('/content/sortedcolabname.pkl', 'rb') as f:\n",
31 | " sortedcolabname = pickle.load(f)\n",
32 | "\n",
33 | "clear_output(wait=True)\n",
34 | "\n",
35 | "everycolab = '/content/camendurus/lite'\n",
36 | "modelischosen = False\n",
37 | "modelchosenmessage = ''\n",
38 | "chosencolabname = ''\n",
39 | "\n",
40 | "def modelchosen(chosenmodel):\n",
41 | " global modelischosen\n",
42 | " global modelchosenmessage\n",
43 | " global chosencolabname\n",
44 | " modelchosenmessage = \"\u001b[1;32mModel \" + chosenmodel + \" was chosen. It'll be downloaded soon. Continue scroll down and wait for the webui to be loaded.\"\n",
45 | " textbox_text = f\"Model '{chosenmodel} was chosen. It'll be downloaded soon. Continue scroll down and wait for the webui to be loaded.\"\n",
46 | " chosencolabname = chosenmodel\n",
47 | " modelischosen = True\n",
48 | " return [gr.Button.update(visible=False), gr.Textbox.update(value=textbox_text, visible=True)]\n",
49 | "\n",
50 | "with gr.Blocks() as vclcolab:\n",
51 | " with gr.Column():\n",
52 | " choose = gr.Dropdown(sortedcolabname, label=\"Choose Your Model\")\n",
53 | " confirm = gr.Button(\"Use This Model\", variant=\"primary\", visible=True)\n",
54 | " donetext = gr.Textbox(\"\", label=\"\", visible=False)\n",
55 | " confirm.click(modelchosen, inputs=[choose], outputs=[confirm, donetext])\n",
56 | "vclcolab.launch()\n",
57 | "\n",
58 | "while True:\n",
59 | " if modelischosen:\n",
60 | " clear_output(wait=True)\n",
61 | " print(modelchosenmessage)\n",
62 | " print('\u001b[0m')\n",
63 | " break\n",
64 | "\n",
65 | "aria2c_lines = []\n",
66 | "\n",
67 | "if chosencolabname:\n",
68 | " colabfilename = chosencolabname + '_webui_colab.ipynb'\n",
69 | " if os.path.exists(os.path.join(everycolab, colabfilename)):\n",
70 | " with open(os.path.join(everycolab, colabfilename), 'r', encoding='utf-8') as f:\n",
71 | " for line in f:\n",
72 | " stripped_line = line.strip()\n",
73 | " if stripped_line.startswith('\"!aria2c'):\n",
74 | " aria2c_lines.append(stripped_line)\n",
75 | "\n",
76 | "if aria2c_lines:\n",
77 | " with open('/content/arialist.pkl', 'wb') as f:\n",
78 | " pickle.dump(aria2c_lines, f)\n",
79 | "\n",
80 | "!python /content/colabtools/runaria2.py"
81 | ],
82 | "metadata": {
83 | "cellView": "form",
84 | "id": "HRLSD-HXLRNk"
85 | },
86 | "execution_count": null,
87 | "outputs": []
88 | },
89 | {
90 | "cell_type": "code",
91 | "execution_count": null,
92 | "metadata": {
93 | "id": "SaAJk33ppFw1",
94 | "cellView": "form"
95 | },
96 | "outputs": [],
97 | "source": [
98 | "#@title (original colab code)\n",
99 | "from IPython.display import clear_output\n",
100 | "%cd /content\n",
101 | "!git clone https://github.com/etherealxx/volatile-concentration-localux-colab /content/colabtools\n",
102 | "!python /content/colabtools/cloneall.py\n",
103 | "!pip install -q gradio \n",
104 | "clear_output(wait=True)\n",
105 | "!python /content/colabtools/choosemodel.py\n",
106 | "\n",
107 | "%env TF_CPP_MIN_LOG_LEVEL=1\n",
108 | "\n",
109 | "!apt -y update -qq\n",
110 | "!wget http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb\n",
111 | "!wget https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb\n",
112 | "!wget https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb\n",
113 | "!wget https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb\n",
114 | "!apt install -qq libunwind8-dev\n",
115 | "!dpkg -i *.deb\n",
116 | "%env LD_PRELOAD=libtcmalloc.so\n",
117 | "!rm *.deb\n",
118 | "\n",
119 | "!apt -y install -qq aria2\n",
120 | "!pip install -q torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 torchtext==0.14.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu116 -U\n",
121 | "!pip install -q xformers==0.0.16 triton==2.0.0 -U\n",
122 | "!apt -y install -qq aria2\n",
123 | "\n",
124 | "!git clone https://github.com/etherealxx/volatile-concentration-localux /content/breaktherules\n",
125 | "!python /content/breaktherules/breaktherules.py\n",
126 | "\n",
127 | "%cd /content/volatile-concentration-localux\n",
128 | "!python /content/colabtools/runaria.py\n",
129 | "!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",
130 | "!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",
131 | "\n",
132 | "!python launch.py --listen --xformers --enable-insecure-extension-access --theme dark --gradio-queue --multiple"
133 | ]
134 | },
135 | {
136 | "cell_type": "code",
137 | "source": [
138 | "#@title (debug)\n",
139 | "import os, math, subprocess, pickle\n",
140 | "from IPython.display import clear_output\n",
141 | "\n",
142 | "!apt -y install -qq aria2\n",
143 | "clear_output(wait=True)\n",
144 | "\n",
145 | "everycolab = '/content/camendurus/lite'\n",
146 | "everycolabname = []\n",
147 | "colabnamepair = []\n",
148 | "for colabname in os.listdir(everycolab):\n",
149 | " colabnamepruned = colabname.partition('_webui_colab.ipynb')[0]\n",
150 | " everycolabname.append(colabnamepruned)\n",
151 | "\n",
152 | "sortedcolabname = sorted(everycolabname)\n",
153 | "totalcolabcount = len(everycolabname)\n",
154 | "for i, colabname in enumerate(sortedcolabname):\n",
155 | " halfall = math.ceil(totalcolabcount / 2)\n",
156 | " numberedname = \"{} | {}\".format(i, colabname.ljust(30))\n",
157 | " if i <= halfall:\n",
158 | " colabnamepair.append(numberedname)\n",
159 | " else:\n",
160 | " rev_index = (i - halfall) - 1\n",
161 | " colabnamepair[rev_index] += \"\\t\" + numberedname\n",
162 | "\n",
163 | "for colabpair in colabnamepair:\n",
164 | " print(colabpair)\n",
165 | "\n",
166 | "choosenumber = input('Choose the number of the model you want: ')\n",
167 | "if choosenumber.isdigit() and int(choosenumber) < totalcolabcount:\n",
168 | " chosencolabname = sortedcolabname[int(choosenumber)] + '_webui_colab.ipynb'\n",
169 | " print(\"Preparing to download model from \" + chosencolabname)\n",
170 | "\n",
171 | "aria2c_lines = []\n",
172 | "with open(os.path.join(everycolab, chosencolabname), 'r', encoding='utf-8') as f:\n",
173 | " for line in f:\n",
174 | " stripped_line = line.strip()\n",
175 | " if stripped_line.startswith('\"!aria2c'):\n",
176 | " aria2c_lines.append(stripped_line)\n",
177 | "\n",
178 | "# print(aria2c_lines)\n",
179 | "with open('/content/arialist.pkl', 'wb') as f:\n",
180 | " pickle.dump(aria2c_lines, f)\n",
181 | "\n",
182 | "!python /content/runaria.py"
183 | ],
184 | "metadata": {
185 | "cellView": "form",
186 | "id": "K3uKK-_4ldJB"
187 | },
188 | "execution_count": null,
189 | "outputs": []
190 | }
191 | ],
192 | "metadata": {
193 | "accelerator": "GPU",
194 | "colab": {
195 | "private_outputs": true,
196 | "provenance": [],
197 | "include_colab_link": true
198 | },
199 | "gpuClass": "standard",
200 | "kernelspec": {
201 | "display_name": "Python 3",
202 | "language": "python",
203 | "name": "python3"
204 | },
205 | "language_info": {
206 | "name": "python",
207 | "version": "3.9.6"
208 | },
209 | "vscode": {
210 | "interpreter": {
211 | "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
212 | }
213 | }
214 | },
215 | "nbformat": 4,
216 | "nbformat_minor": 0
217 | }
--------------------------------------------------------------------------------
/volatile_concentration_localux_colab.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {
6 | "colab_type": "text",
7 | "id": "view-in-github"
8 | },
9 | "source": [
10 | "
"
11 | ]
12 | },
13 | {
14 | "cell_type": "markdown",
15 | "metadata": {
16 | "id": "e78dCt3JZ6UX"
17 | },
18 | "source": [
19 | "##***Project `VCL-colab`***\n",
20 | "### All camenduru colab in one spot, synced in realtime\n",
21 | "###### Last time updated: Feb 12, 24\n",
22 | "###### (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).)"
23 | ]
24 | },
25 | {
26 | "cell_type": "markdown",
27 | "metadata": {
28 | "id": "mRkHg3INcszO"
29 | },
30 | "source": [
31 | "###### \n",
32 | "To use:\n",
33 | "- Click the play button\n",
34 | "- Wait for less than a minute, until a UI with **big orange button** shows up\n",
35 | "- 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",
36 | "- Just wait for about 8 minute until the webui links shows up on the bottom\n",
37 | "\n",
38 | "About the options:\n",
39 | "- `repo_branch`: Read [here](https://github.com/camenduru/stable-diffusion-webui-colab) (just use `stable` as default)\n",
40 | "- `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",
41 | "- `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",
42 | "\n",
43 | "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."
44 | ]
45 | },
46 | {
47 | "cell_type": "markdown",
48 | "metadata": {
49 | "id": "4bsCMAOQcSIn"
50 | },
51 | "source": [
52 | "## ⠀\n",
53 | "(open the hidden cell to show help☝️)"
54 | ]
55 | },
56 | {
57 | "cell_type": "code",
58 | "execution_count": null,
59 | "metadata": {
60 | "cellView": "form",
61 | "id": "HRLSD-HXLRNk"
62 | },
63 | "outputs": [],
64 | "source": [
65 | "#@title 👇 Run this\n",
66 | "repo_branch = 'stable' #@param [\"lite\", \"stable\", \"nightly\"]\n",
67 | "choose_models = True #@param {type:\"boolean\"}\n",
68 | "controlnet_models = False #@param {type:\"boolean\"}\n",
69 | "\n",
70 | "print(\"\u001b[1;32mWait for about a minute until a UI with a big orange button shows up below\")\n",
71 | "print('\u001b[0m')\n",
72 | "\n",
73 | "from IPython.display import clear_output\n",
74 | "import time\n",
75 | "%cd /content\n",
76 | "\n",
77 | "try:\n",
78 | " start_colab\n",
79 | "except:\n",
80 | " start_colab = int(time.time())-5\n",
81 | "# clear_output()\n",
82 | "\n",
83 | "%env TF_CPP_MIN_LOG_LEVEL=1\n",
84 | "!git clone https://github.com/etherealxx/volatile-concentration-localux-colab /content/vcltools\n",
85 | "!pip install -q gradio==3.41.2\n",
86 | "!pip install -q pastebin-replace httpx==0.24.1\n",
87 | "from pastebin_replace import pbreplace\n",
88 | "\n",
89 | "emptymodel = False\n",
90 | "\n",
91 | "colaboptions = {\n",
92 | " \"branch\": repo_branch,\n",
93 | " \"filename\": \"stable_diffusion_1_5_webui_colab.ipynb\",\n",
94 | " \"part\": \"part2\",\n",
95 | " \"controlnet\": controlnet_models,\n",
96 | " \"download_model\": choose_models,\n",
97 | " \"empty_model\": emptymodel\n",
98 | "} #default\n",
99 | "\n",
100 | "import os, pickle, sys, re, shutil\n",
101 | "import gradio as gr\n",
102 | "\n",
103 | "vclvarpath = '/content/vclvariables'\n",
104 | "os.makedirs(vclvarpath, exist_ok=True)\n",
105 | "!python /content/vcltools/cloneall3.py\n",
106 | "\n",
107 | "# This will dumps 'sortedcolabname'\n",
108 | "!python /content/vcltools/choosemodel4.py {repo_branch}\n",
109 | "\n",
110 | "def pickledump(vartodump, outputfile):\n",
111 | " outputpath = os.path.join(vclvarpath, outputfile + '.pkl')\n",
112 | " with open(outputpath, 'wb') as f:\n",
113 | " pickle.dump(vartodump, f)\n",
114 | "\n",
115 | "def pickleload(prevvalue, inputfile):\n",
116 | " inputpath = os.path.join(vclvarpath, inputfile + '.pkl')\n",
117 | " if os.path.exists(inputpath):\n",
118 | " with open(inputpath, 'rb') as f:\n",
119 | " vartopass = pickle.load(f)\n",
120 | " return vartopass\n",
121 | " else:\n",
122 | " return prevvalue\n",
123 | "\n",
124 | "vclpath = \"/content/volatile-concentration-localux\"\n",
125 | "prevbranch = pickleload(None, 'prevbranch')\n",
126 | "if prevbranch and prevbranch != repo_branch:\n",
127 | " !python /content/vcltools/changebranch.py backup\n",
128 | " pass\n",
129 | "\n",
130 | "# 'sortedcolabname' will not be accessed anymore\n",
131 | "sortedcolabname = pickleload(None, 'sortedcolabname')\n",
132 | "\n",
133 | "!pip install base58\n",
134 | "import base58\n",
135 | "# The extension name of that must have extension for sd colabs, enabling multiple gradio UI tunneling at once\n",
136 | "tunneltext = base58.b58decode(\"FFSgE5cGo6ewBdZ8cwDovS\".encode()).decode()\n",
137 | "\n",
138 | "if choose_models:\n",
139 | " clear_output(wait=True)\n",
140 | "\n",
141 | "everycolab = f'/content/camendurus/{repo_branch}'\n",
142 | "modelischosen = False\n",
143 | "modelchosenmessage = ''\n",
144 | "chosencolabname = ''\n",
145 | "extensionlines = []\n",
146 | "extensiontoremove = []\n",
147 | "\n",
148 | "def list_additional_ext():\n",
149 | " addext_txtpath = \"/content/vcltools/additionalextensions.txt\"\n",
150 | " with open(addext_txtpath, 'r') as file:\n",
151 | " lines = [line.rstrip('\\n') for line in file]\n",
152 | " exts = [ext for ext in lines if ext != \"\" and not ext.startswith(\"#\")]\n",
153 | " return exts\n",
154 | "\n",
155 | "additionalextension_names = [x.split(\"/\")[-1] for x in list_additional_ext()]\n",
156 | "\n",
157 | "def no_model_install_extension():\n",
158 | " global choose_models\n",
159 | " global colaboptions\n",
160 | " global emptymodel\n",
161 | " global extensionlines\n",
162 | " \n",
163 | " extensionlist = []\n",
164 | " choose_models = False\n",
165 | " colaboptions[\"download_model\"] = False\n",
166 | " emptymodel = True\n",
167 | "\n",
168 | " # This script extracts every \"git clone\" line from selected camenduru's colab notebook\n",
169 | " # The result is 'extensions' pickle file, containing git clone lines as a python list\n",
170 | " !python /content/vcltools/extensioninstaller3.py\n",
171 | " \n",
172 | " extensionlines = pickleload(extensionlines, 'extensions')\n",
173 | "\n",
174 | " for ext_gitcloneline in extensionlines:\n",
175 | " pattern = r\"https://github.com/\\S+/(\\S+)\"\n",
176 | " match = re.search(pattern, ext_gitcloneline)\n",
177 | " if match:\n",
178 | " ext_name = match.group(1)\n",
179 | " if not ext_name == tunneltext:\n",
180 | " extensionlist.append(ext_name)\n",
181 | " # print(repo_name)\n",
182 | " pickledump(extensionlist, 'fullextensions')\n",
183 | "\n",
184 | "def modelchosen(chosenmodel, chosenextension):\n",
185 | " global modelischosen\n",
186 | " global modelchosenmessage\n",
187 | " global chosencolabname\n",
188 | " global colaboptions\n",
189 | " global choose_models\n",
190 | " global extensionlines\n",
191 | " global extensiontoremove\n",
192 | " global emptymodel\n",
193 | "\n",
194 | " # for link in extensionlines:\n",
195 | " # match = re.search(r\"https://github.com/\\S+/(\\S+)\", link)\n",
196 | " # if match:\n",
197 | " # repo_name = match.group(1)\n",
198 | " # if repo_name in chosenextension:\n",
199 | " # usedextensionlinks.append(link)\n",
200 | " # pickledump(usedextensionlinks, '/content/extensions.pkl')\n",
201 | " \n",
202 | " # For the first time launching the colab, there will be no 'chosenextension' pickle file\n",
203 | " # This will later get accessed after the user choose the model, to preserve the user's chosen extension from previous cell run\n",
204 | " pickledump(chosenextension, 'chosenextensions')\n",
205 | " \n",
206 | " # This will also being accessed by `additionalextension.py`\n",
207 | " # WIP\n",
208 | " fullextension = pickleload(None, 'fullextensions')\n",
209 | " \n",
210 | " if fullextension:\n",
211 | " extensiontoremove = [x for x in fullextension if x not in chosenextension]\n",
212 | " \n",
213 | " # This will later accessed by `camendurucolab3.py` to filter only chosen extension that will be cloned\n",
214 | " # ... and those who aren't chosen will be removed\n",
215 | " pickledump(extensiontoremove, 'removedextensions')\n",
216 | " \n",
217 | " if chosenmodel:\n",
218 | " modelchosenmessage = \"\u001b[1;32mModel \" + chosenmodel + \" was chosen. It'll be downloaded soon. Continue scroll down and wait for the webui to be loaded.\"\n",
219 | " textbox_text = f\"Model '{chosenmodel} was chosen. It'll be downloaded soon. Continue scroll down and wait for the webui to be loaded.\"\n",
220 | " chosencolabname = chosenmodel\n",
221 | " emptymodel = False\n",
222 | " else:\n",
223 | " modelchosenmessage = \"\u001b[1;32mNo model was chosen. Continue scroll down and wait for the webui to be loaded.\"\n",
224 | " textbox_text = f\"No model was chosen. Continue scroll down and wait for the webui to be loaded.\"\n",
225 | " \n",
226 | " no_model_install_extension()\n",
227 | "\n",
228 | " modelischosen = True\n",
229 | " 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",
230 | "\n",
231 | "def extensionschoose(modelthatischosen):\n",
232 | " extensionlist = []\n",
233 | " global colaboptions\n",
234 | " global extensionlines\n",
235 | " global additionalextension_names\n",
236 | " if modelthatischosen:\n",
237 | " colabfilename = modelthatischosen + '_webui_colab.ipynb'\n",
238 | " colaboptions[\"filename\"] = colabfilename\n",
239 | " # chosencolabfilepath = os.path.join(everycolab, colabfilename)\n",
240 | " \n",
241 | " # Contains branch name, camenduru's colab notebook name, part (unused),\n",
242 | " # ... and three booleans: :controlnet\", \"download_model\", \"empty_model\"\n",
243 | " # Need to be loaded in \"camendurucolab3.py\", \"extensioninstaller3.py\", and \"runaria3.py\"\n",
244 | " pickledump(colaboptions, 'colaboptions')\n",
245 | "\n",
246 | " # This script extracts every \"git clone\" line from selected camenduru's colab notebook\n",
247 | " # The result is 'extensions' pickle file, containing git clone lines as a python list\n",
248 | " !python /content/vcltools/extensioninstaller3.py\n",
249 | " extensionlines = pickleload(extensionlines, 'extensions')\n",
250 | "\n",
251 | " for ext_gitcloneline in extensionlines:\n",
252 | " pattern = r\"https://github.com/\\S+/(\\S+)\"\n",
253 | " match = re.search(pattern, ext_gitcloneline)\n",
254 | " if match:\n",
255 | " ext_name = match.group(1)\n",
256 | " if not ext_name == tunneltext:\n",
257 | " extensionlist.append(ext_name)\n",
258 | " # print(repo_name)\n",
259 | " \n",
260 | " # Contains only the extension name, excluding the tunnel extension\n",
261 | " # This also includes the additional extensions\n",
262 | " pickledump(extensionlist, 'fullextensions')\n",
263 | "\n",
264 | " !python /content/vcltools/additionalextension.py\n",
265 | " \n",
266 | " # Extensions that are from camenduru's repo. Used only as a fallback of 'chosenextensions'\n",
267 | " templist = pickleload(None, 'tempext')\n",
268 | " \n",
269 | " # List of extensions that were choosen by the user\n",
270 | " chosenextension = pickleload(templist, 'chosenextensions')\n",
271 | "\n",
272 | " # Group the extensions based from the source (camenduru's colab or additional exts)\n",
273 | " # ... and then sort them alphabetically\n",
274 | " extensionlist = list(set(extensionlist) - set(additionalextension_names))\n",
275 | " extensionlist.sort()\n",
276 | " additionalextension_names.sort()\n",
277 | " # extensionlist.extend(chosenextension)\n",
278 | " for extname in additionalextension_names:\n",
279 | " extensionlist.append(extname)\n",
280 | "\n",
281 | " return gr.CheckboxGroup.update(choices=extensionlist, value=chosenextension, visible=True)\n",
282 | "\n",
283 | "def dumpchoice(extensionthatischosen):\n",
284 | " # Always update whenever user modifies the extensions checkboxes\n",
285 | " pickledump(extensionthatischosen, 'chosenextensions')\n",
286 | "\n",
287 | "with gr.Blocks() as vclcolab:\n",
288 | " with gr.Column():\n",
289 | " choose = gr.Dropdown(sortedcolabname, label=\"Choose Your Model\", interactive=True)\n",
290 | " confirm = gr.Button(\"Use This Model\", variant=\"primary\", visible=True)\n",
291 | " donetext = gr.Textbox(\"\", label=\"\", visible=False)\n",
292 | " extchooser = gr.CheckboxGroup([\"placeholder\"], label=\"Extensions\", info=\"Untick the checkboxes on those extensions that you want to disable\", visible=False, interactive=True)\n",
293 | " confirm.click(modelchosen, inputs=[choose, extchooser], outputs=[confirm, donetext, extchooser, choose])\n",
294 | " choose.change(extensionschoose, inputs=[choose], outputs=[extchooser])\n",
295 | " extchooser.change(dumpchoice, inputs=[extchooser])\n",
296 | "\n",
297 | "gr.close_all()\n",
298 | "if choose_models:\n",
299 | " tryport = 7860\n",
300 | " while True:\n",
301 | " tryport += 1\n",
302 | " try:\n",
303 | " 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",
304 | " 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",
305 | " print('\u001b[0m')\n",
306 | " vclcolab.launch(server_port=tryport)\n",
307 | " break\n",
308 | " except OSError:\n",
309 | " pass\n",
310 | "\n",
311 | " while True:\n",
312 | " try:\n",
313 | " if modelischosen:\n",
314 | " clear_output(wait=True)\n",
315 | " print(modelchosenmessage)\n",
316 | " print('\u001b[0m')\n",
317 | " vclcolab.close()\n",
318 | " break\n",
319 | " except KeyboardInterrupt:\n",
320 | " clear_output(wait=True)\n",
321 | " print(\"\u001b[1;33mGradio UI interrupted\")\n",
322 | " print('\u001b[0m')\n",
323 | " vclcolab.close()\n",
324 | " # sys.exit()\n",
325 | " # os._exit(1)\n",
326 | " break\n",
327 | "\n",
328 | "aria2c_lines = []\n",
329 | "colabfilename = ''\n",
330 | "chosencolabfilepath = os.path.join(everycolab, colaboptions[\"filename\"])\n",
331 | "\n",
332 | "if chosencolabname:\n",
333 | " colabfilename = chosencolabname + '_webui_colab.ipynb'\n",
334 | " colaboptions[\"filename\"] = colabfilename\n",
335 | " chosencolabfilepath = os.path.join(everycolab, colabfilename)\n",
336 | "\n",
337 | "if os.path.exists(chosencolabfilepath):\n",
338 | " print(\"\u001b[1;32mGathering aria2c code from \" + chosencolabfilepath + \"...\")\n",
339 | " print('\u001b[0m')\n",
340 | " with open(chosencolabfilepath, 'r', encoding='utf-8') as f:\n",
341 | " for line in f:\n",
342 | " stripped_line = line.strip()\n",
343 | " if stripped_line.startswith('\"!aria2c'):\n",
344 | " aria2c_lines.append(stripped_line)\n",
345 | "\n",
346 | "if aria2c_lines:\n",
347 | " # Every aria2c lines in camenduru's notebook, in which case it's either a checkpoint model, controlnet model, or a vae link\n",
348 | " pickledump(aria2c_lines, 'arialist')\n",
349 | "\n",
350 | "colaboptions[\"empty_model\"] = emptymodel\n",
351 | "\n",
352 | "pickledump(colaboptions, 'colaboptions')\n",
353 | "\n",
354 | "# !python /content/vcltools/camendurucolab.py {colabfilename} {repo_branch} part1\n",
355 | "!apt -y update -qq\n",
356 | "#👇 Memory fix by camenduru & slowargo\n",
357 | "if not os.path.exists(\"/content/libtcmalloc_minimal.so.4\"):\n",
358 | " !git clone -b colab https://github.com/camenduru/gperftools\n",
359 | " %cd /content/gperftools\n",
360 | " %env CXXFLAGS=-std=c++14\n",
361 | " !chmod +x /content/gperftools/configure\n",
362 | " print(\"building libtcmalloc_minimal.so.4, please wait...\")\n",
363 | " !(./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",
364 | " !cp .libs/libtcmalloc*.so* /content\n",
365 | "%env LD_PRELOAD=/content/libtcmalloc_minimal.so.4\n",
366 | "%cd /content\n",
367 | "\n",
368 | "def thispickleexist(filename):\n",
369 | " return os.path.exists(os.path.join(vclvarpath, filename + \".pkl\"))\n",
370 | "\n",
371 | "if not thispickleexist(\"extensions\") or not thispickleexist(\"removedextensions\"):\n",
372 | " no_model_install_extension()\n",
373 | "\n",
374 | "# This runs every download process from camenduru's notebook, like git clones\n",
375 | "# Needs 'colaboptions', 'extensions', and 'removedextensions'\n",
376 | "!python /content/vcltools/camendurucolab3.py #{colabfilename} {repo_branch} part2\n",
377 | "\n",
378 | "# This runs the aria2c lines\n",
379 | "!python /content/vcltools/runaria3.py\n",
380 | "\n",
381 | "%cd /content/volatile-concentration-localux\n",
382 | "\n",
383 | "# if extensiontoremove and not emptymodel:\n",
384 | "# for ext in extensiontoremove:\n",
385 | "# extpath = os.path.join('/content/volatile-concentration-localux/extensions', ext)\n",
386 | "# if os.path.exists(extpath):\n",
387 | "# shutil.rmtree(extpath)\n",
388 | "# print(f\"removed {ext} extension\")\n",
389 | "\n",
390 | "# !python /content/vcltools/camendurucolab.py {colabfilename} {repo_branch} part3\n",
391 | "\n",
392 | "if prevbranch and prevbranch != repo_branch:\n",
393 | " !python /content/vcltools/changebranch.py restore\n",
394 | "pickledump(repo_branch, \"prevbranch\")\n",
395 | "\n",
396 | "# 👇 Now it's being handled in camendurucolab3.py\n",
397 | "# !sed -i -e '''/from modules import launch_utils/a\\import os''' /content/volatile-concentration-localux/launch.py\n",
398 | "# !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",
399 | "# !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",
400 | "\n",
401 | "print(\"\u001b[1;32mlaunching the webui...\")\n",
402 | "print('\u001b[0m')\n",
403 | "\n",
404 | "!python /content/vcltools/setuptimer.py\n",
405 | "!echo -n {start_colab} > /content/volatile-concentration-localux/static/colabTimer.txt\n",
406 | "!wget -q https://raw.githubusercontent.com/etherealxx/batchlinks-webui/main/notification.mp3 -P /content/volatile-concentration-localux\n",
407 | "\n",
408 | "!python launch.py --listen --xformers --enable-insecure-extension-access --theme dark --gradio-queue --multiple --disable-model-loading-ram-optimization"
409 | ]
410 | },
411 | {
412 | "cell_type": "markdown",
413 | "metadata": {
414 | "id": "ZGlOpxFdEIB5"
415 | },
416 | "source": [
417 | "(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)"
418 | ]
419 | },
420 | {
421 | "cell_type": "markdown",
422 | "metadata": {
423 | "id": "dYiw0gLVRpTz"
424 | },
425 | "source": [
426 | "## ⠀"
427 | ]
428 | },
429 | {
430 | "cell_type": "markdown",
431 | "metadata": {
432 | "id": "0BEVRlWUcbj3"
433 | },
434 | "source": [
435 | " ### (debug area)"
436 | ]
437 | },
438 | {
439 | "cell_type": "code",
440 | "execution_count": null,
441 | "metadata": {
442 | "id": "ZokmtbXibfQf"
443 | },
444 | "outputs": [],
445 | "source": [
446 | "from google.colab import drive\n",
447 | "drive.mount('/content/drive')"
448 | ]
449 | },
450 | {
451 | "cell_type": "code",
452 | "execution_count": null,
453 | "metadata": {
454 | "id": "pij1YzxGDw7y"
455 | },
456 | "outputs": [],
457 | "source": [
458 | "!rm -rf /content/vclvariables\n",
459 | "!rm -rf /content/volatile-concentration-localux\n",
460 | "!rm -rf /content/vcltools\n",
461 | "%cd /content\n",
462 | "!git clone -b dev9 https://github.com/etherealxx/volatile-concentration-localux-colab /content/vcltools"
463 | ]
464 | },
465 | {
466 | "cell_type": "code",
467 | "execution_count": null,
468 | "metadata": {
469 | "id": "e-bXoxXtbgeY"
470 | },
471 | "outputs": [],
472 | "source": [
473 | "import os\n",
474 | "import shutil\n",
475 | "\n",
476 | "def copy_files(source_dir, destination_dir):\n",
477 | " # Create destination directory if it doesn't exist\n",
478 | " if not os.path.exists(destination_dir):\n",
479 | " os.makedirs(destination_dir)\n",
480 | " print(f\"Created directory: {destination_dir}\")\n",
481 | "\n",
482 | " # Get the list of files in the source directory\n",
483 | " files = os.listdir(source_dir)\n",
484 | "\n",
485 | " for file in files:\n",
486 | " source_file = os.path.join(source_dir, file)\n",
487 | " destination_file = os.path.join(destination_dir, file)\n",
488 | "\n",
489 | " # Copy the file to the destination directory\n",
490 | " shutil.copy2(source_file, destination_file)\n",
491 | "\n",
492 | " # Print success message with the filename\n",
493 | " print(f\"Successfully copied {file}.\")\n",
494 | "\n",
495 | "# Specify the source and destination directories\n",
496 | "folder_A = \"/content/volatile-concentration-localux/outputs/txt2img-images/xxx\"\n",
497 | "folder_B = \"/content/drive/MyDrive/xxx\"\n",
498 | "\n",
499 | "# Copy files from folder A to folder B\n",
500 | "copy_files(folder_A, folder_B)"
501 | ]
502 | },
503 | {
504 | "cell_type": "code",
505 | "execution_count": null,
506 | "metadata": {},
507 | "outputs": [],
508 | "source": [
509 | "# to remove folder and it's subdirectories from a specific path. Need this bcoz of the keyword ban\n",
510 | "import os\n",
511 | "keyword = \"reactor\"\n",
512 | "\n",
513 | "extpath = \"/content/volatile-concentration-localux/extensions\"\n",
514 | "for folder in os.listdir(extpath):\n",
515 | " if keyword in folder:\n",
516 | " folderpath = os.path.join(extpath, folder)\n",
517 | " !rm -rf {folderpath}"
518 | ]
519 | },
520 | {
521 | "cell_type": "code",
522 | "execution_count": null,
523 | "metadata": {
524 | "id": "nSGdJN0OAqDL"
525 | },
526 | "outputs": [],
527 | "source": [
528 | "%cd /content\n",
529 | "!git clone https://github.com/etherealxx/volatile-concentration-localux-colab /content/colabtools"
530 | ]
531 | },
532 | {
533 | "cell_type": "code",
534 | "execution_count": null,
535 | "metadata": {
536 | "id": "g4UAZfaZ4wgo"
537 | },
538 | "outputs": [],
539 | "source": [
540 | "!rm -rf /content/volatile-concentration-localux\n",
541 | "!rm -rf /content/camendurus\n",
542 | "!rm /content/frpc_linux_amd64"
543 | ]
544 | },
545 | {
546 | "cell_type": "code",
547 | "execution_count": null,
548 | "metadata": {
549 | "id": "--HDCkoxCHnT"
550 | },
551 | "outputs": [],
552 | "source": [
553 | "import os, pickle\n",
554 | "\n",
555 | "toopen = '/content/vclvariables/extensions.pkl'\n",
556 | "\n",
557 | "if os.path.exists(toopen):\n",
558 | " with open(toopen, 'rb') as f:\n",
559 | " arialines2 = pickle.load(f)\n",
560 | "\n",
561 | "for line in arialines2:\n",
562 | " print(line)"
563 | ]
564 | },
565 | {
566 | "cell_type": "code",
567 | "execution_count": null,
568 | "metadata": {
569 | "id": "pE0A4A_jGXkR"
570 | },
571 | "outputs": [],
572 | "source": [
573 | "repo_branch = 'nightly' #@param [\"lite\", \"stable\", \"nightly\"]\n",
574 | "\n",
575 | "colaboptions = {\n",
576 | " \"branch\": repo_branch,\n",
577 | " \"filename\": \"stable_diffusion_1_5_webui_colab.ipynb\",\n",
578 | " \"part\": \"part2\"\n",
579 | "} #default\n",
580 | "\n",
581 | "\n",
582 | "print(colaboptions['branch'])"
583 | ]
584 | },
585 | {
586 | "cell_type": "code",
587 | "execution_count": null,
588 | "metadata": {
589 | "id": "ouZRtBpEMq3V"
590 | },
591 | "outputs": [],
592 | "source": [
593 | "with open('/content/camendurus/nightly/a_certain_model_webui_colab.ipynb', 'r', encoding='utf-8') as f:\n",
594 | " for line in f:\n",
595 | " stripped_line = line.strip()\n",
596 | " if stripped_line.startswith('\"!aria2c'):\n",
597 | " # aria2c_lines.append(stripped_line)\n",
598 | " print(\"\u001b[1;32m\" + stripped_line)\n",
599 | " print('\u001b[0m')\n",
600 | " else:\n",
601 | " print(stripped_line)"
602 | ]
603 | },
604 | {
605 | "cell_type": "code",
606 | "execution_count": null,
607 | "metadata": {
608 | "id": "jKUgiWbaN-TW"
609 | },
610 | "outputs": [],
611 | "source": [
612 | "checktest = None\n",
613 | "with open('/content/arialist.pkl', 'rb') as f:\n",
614 | " checktest = pickle.load(f)\n",
615 | "print(checktest)"
616 | ]
617 | },
618 | {
619 | "cell_type": "code",
620 | "execution_count": null,
621 | "metadata": {
622 | "id": "uYmGyckPbZaQ"
623 | },
624 | "outputs": [],
625 | "source": []
626 | }
627 | ],
628 | "metadata": {
629 | "accelerator": "GPU",
630 | "colab": {
631 | "collapsed_sections": [
632 | "e78dCt3JZ6UX",
633 | "0BEVRlWUcbj3"
634 | ],
635 | "include_colab_link": true,
636 | "private_outputs": true,
637 | "provenance": []
638 | },
639 | "gpuClass": "standard",
640 | "kernelspec": {
641 | "display_name": "Python 3",
642 | "language": "python",
643 | "name": "python3"
644 | },
645 | "language_info": {
646 | "name": "python",
647 | "version": "3.9.6"
648 | },
649 | "vscode": {
650 | "interpreter": {
651 | "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
652 | }
653 | }
654 | },
655 | "nbformat": 4,
656 | "nbformat_minor": 0
657 | }
658 |
--------------------------------------------------------------------------------
/volatile_concentration_localux_colab_backup.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {
6 | "colab_type": "text",
7 | "id": "view-in-github"
8 | },
9 | "source": [
10 | "
"
11 | ]
12 | },
13 | {
14 | "cell_type": "markdown",
15 | "metadata": {
16 | "id": "e78dCt3JZ6UX"
17 | },
18 | "source": [
19 | "##***Project `VCL-colab`***\n",
20 | "### All camenduru colab in one spot, synced in realtime\n",
21 | "###### Last time updated: Jul 20, 23\n",
22 | "###### (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).)"
23 | ]
24 | },
25 | {
26 | "cell_type": "markdown",
27 | "metadata": {
28 | "id": "mRkHg3INcszO"
29 | },
30 | "source": [
31 | "###### \n",
32 | "To use:\n",
33 | "- Click the play button\n",
34 | "- Wait for less than a minute, until a UI with **big orange button** shows up\n",
35 | "- 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",
36 | "- Just wait for about 8 minute until the webui links shows up on the bottom\n",
37 | "\n",
38 | "About the options:\n",
39 | "- `repo_branch`: Read [here](https://github.com/camenduru/stable-diffusion-webui-colab) (just use `stable` as default)\n",
40 | "- `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",
41 | "- `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",
42 | "\n",
43 | "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."
44 | ]
45 | },
46 | {
47 | "cell_type": "markdown",
48 | "metadata": {
49 | "id": "4bsCMAOQcSIn"
50 | },
51 | "source": [
52 | "## ⠀\n",
53 | "(open the hidden cell to show help☝️)"
54 | ]
55 | },
56 | {
57 | "cell_type": "code",
58 | "execution_count": null,
59 | "metadata": {
60 | "cellView": "form",
61 | "id": "HRLSD-HXLRNk"
62 | },
63 | "outputs": [],
64 | "source": [
65 | "#@title 👇 Run this\n",
66 | "repo_branch = 'stable' #@param [\"lite\", \"stable\", \"nightly\"]\n",
67 | "choose_models = True #@param {type:\"boolean\"}\n",
68 | "controlnet_models = False #@param {type:\"boolean\"}\n",
69 | "\n",
70 | "print(\"\u001b[1;32mWait for about a minute until a UI with a big orange button shows up below\")\n",
71 | "print('\u001b[0m')\n",
72 | "\n",
73 | "from IPython.display import clear_output\n",
74 | "import time\n",
75 | "%cd /content\n",
76 | "\n",
77 | "try:\n",
78 | " start_colab\n",
79 | "except:\n",
80 | " start_colab = int(time.time())-5\n",
81 | "# clear_output()\n",
82 | "\n",
83 | "%env TF_CPP_MIN_LOG_LEVEL=1\n",
84 | "!git clone https://github.com/etherealxx/volatile-concentration-localux-colab /content/vcltools\n",
85 | "!pip install -q gradio==3.28.3\n",
86 | "\n",
87 | "emptymodel = False\n",
88 | "\n",
89 | "colaboptions = {\n",
90 | " \"branch\": repo_branch,\n",
91 | " \"filename\": \"stable_diffusion_1_5_webui_colab.ipynb\",\n",
92 | " \"part\": \"part2\",\n",
93 | " \"controlnet\": controlnet_models,\n",
94 | " \"download_model\": choose_models,\n",
95 | " \"empty_model\": emptymodel\n",
96 | "} #default\n",
97 | "\n",
98 | "import os, pickle, sys, re, shutil\n",
99 | "import gradio as gr\n",
100 | "\n",
101 | "vclvarpath = '/content/vclvariables'\n",
102 | "os.makedirs(vclvarpath, exist_ok=True)\n",
103 | "!python /content/vcltools/cloneall3.py\n",
104 | "!python /content/vcltools/choosemodel4.py {repo_branch}\n",
105 | "\n",
106 | "def pickledump(vartodump, outputfile):\n",
107 | " outputpath = os.path.join(vclvarpath, outputfile + '.pkl')\n",
108 | " with open(outputpath, 'wb') as f:\n",
109 | " pickle.dump(vartodump, f)\n",
110 | "\n",
111 | "def pickleload(prevvalue, inputfile):\n",
112 | " inputpath = os.path.join(vclvarpath, inputfile + '.pkl')\n",
113 | " if os.path.exists(inputpath):\n",
114 | " with open(inputpath, 'rb') as f:\n",
115 | " vartopass = pickle.load(f)\n",
116 | " return vartopass\n",
117 | " else:\n",
118 | " return prevvalue\n",
119 | "\n",
120 | "sortedcolabname = pickleload(None, 'sortedcolabname')\n",
121 | "\n",
122 | "!pip install base58\n",
123 | "import base58\n",
124 | "tunneltext = base58.b58decode(\"FFSgE5cGo6ewBdZ8cwDovS\".encode()).decode()\n",
125 | "\n",
126 | "clear_output(wait=True)\n",
127 | "\n",
128 | "everycolab = f'/content/camendurus/{repo_branch}'\n",
129 | "modelischosen = False\n",
130 | "modelchosenmessage = ''\n",
131 | "chosencolabname = ''\n",
132 | "extensionlines = []\n",
133 | "extensiontoremove = []\n",
134 | "\n",
135 | "def list_additional_ext():\n",
136 | " addext_txtpath = \"/content/vcltools/additionalextensions.txt\"\n",
137 | " with open(addext_txtpath, 'r') as file:\n",
138 | " lines = [line.rstrip('\\n') for line in file]\n",
139 | " exts = [ext for ext in lines if ext != \"\" and not ext.startswith(\"#\")]\n",
140 | " return exts\n",
141 | "\n",
142 | "additionalextension_names = [x.split(\"/\")[-1] for x in list_additional_ext()]\n",
143 | "\n",
144 | "def modelchosen(chosenmodel, chosenextension):\n",
145 | " global modelischosen\n",
146 | " global modelchosenmessage\n",
147 | " global chosencolabname\n",
148 | " global colaboptions\n",
149 | " global choose_models\n",
150 | " global extensionlines\n",
151 | " global extensiontoremove\n",
152 | " global emptymodel\n",
153 | " usedextensionlinks = []\n",
154 | " extensionlist = []\n",
155 | " # for link in extensionlines:\n",
156 | " # match = re.search(r\"https://github.com/\\S+/(\\S+)\", link)\n",
157 | " # if match:\n",
158 | " # repo_name = match.group(1)\n",
159 | " # if repo_name in chosenextension:\n",
160 | " # usedextensionlinks.append(link)\n",
161 | " # pickledump(usedextensionlinks, '/content/extensions.pkl')\n",
162 | " pickledump(chosenextension, 'chosenextensions')\n",
163 | " fullextension = pickleload(None, 'fullextensions')\n",
164 | " if fullextension:\n",
165 | " extensiontoremove = [x for x in fullextension if x not in chosenextension]\n",
166 | " pickledump(extensiontoremove, 'removedextensions')\n",
167 | " if chosenmodel:\n",
168 | " modelchosenmessage = \"\u001b[1;32mModel \" + chosenmodel + \" was chosen. It'll be downloaded soon. Continue scroll down and wait for the webui to be loaded.\"\n",
169 | " textbox_text = f\"Model '{chosenmodel} was chosen. It'll be downloaded soon. Continue scroll down and wait for the webui to be loaded.\"\n",
170 | " chosencolabname = chosenmodel\n",
171 | " emptymodel = False\n",
172 | " else:\n",
173 | " modelchosenmessage = \"\u001b[1;32mNo model was chosen. Continue scroll down and wait for the webui to be loaded.\"\n",
174 | " textbox_text = f\"No model was chosen. Continue scroll down and wait for the webui to be loaded.\"\n",
175 | " choose_models = False\n",
176 | " colaboptions[\"download_model\"] = False\n",
177 | " emptymodel = True\n",
178 | "\n",
179 | " !python /content/vcltools/extensioninstaller3.py\n",
180 | " extensionlines = pickleload(extensionlines, 'extensions')\n",
181 | "\n",
182 | " for ext_gitcloneline in extensionlines:\n",
183 | " pattern = r\"https://github.com/\\S+/(\\S+)\"\n",
184 | " match = re.search(pattern, ext_gitcloneline)\n",
185 | " if match:\n",
186 | " ext_name = match.group(1)\n",
187 | " if not ext_name == tunneltext:\n",
188 | " extensionlist.append(ext_name)\n",
189 | " # print(repo_name)\n",
190 | " pickledump(extensionlist, 'fullextensions')\n",
191 | "\n",
192 | " modelischosen = True\n",
193 | " 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",
194 | "\n",
195 | "def extensionschoose(modelthatischosen):\n",
196 | " extensionlist = []\n",
197 | " global colaboptions\n",
198 | " global extensionlines\n",
199 | " global additionalextension_names\n",
200 | " if modelthatischosen:\n",
201 | " colabfilename = modelthatischosen + '_webui_colab.ipynb'\n",
202 | " colaboptions[\"filename\"] = colabfilename\n",
203 | " chosencolabfilepath = os.path.join(everycolab, colabfilename)\n",
204 | " pickledump(colaboptions, 'colaboptions')\n",
205 | "\n",
206 | " !python /content/vcltools/extensioninstaller3.py\n",
207 | " extensionlines = pickleload(extensionlines, 'extensions')\n",
208 | "\n",
209 | " for ext_gitcloneline in extensionlines:\n",
210 | " pattern = r\"https://github.com/\\S+/(\\S+)\"\n",
211 | " match = re.search(pattern, ext_gitcloneline)\n",
212 | " if match:\n",
213 | " ext_name = match.group(1)\n",
214 | " if not ext_name == tunneltext:\n",
215 | " extensionlist.append(ext_name)\n",
216 | " # print(repo_name)\n",
217 | " pickledump(extensionlist, 'fullextensions')\n",
218 | " # extensionlist.sort()\n",
219 | " !python /content/vcltools/additionalextension.py\n",
220 | " templist = pickleload(None, 'tempext')\n",
221 | " chosenextension = pickleload(templist, 'chosenextensions')\n",
222 | "\n",
223 | " extensionlist = list(set(extensionlist) - set(additionalextension_names))\n",
224 | " extensionlist.sort()\n",
225 | " additionalextension_names.sort()\n",
226 | " # extensionlist.extend(chosenextension)\n",
227 | " for extname in additionalextension_names:\n",
228 | " extensionlist.append(extname)\n",
229 | "\n",
230 | " return gr.CheckboxGroup.update(choices=extensionlist, value=chosenextension, visible=True)\n",
231 | "\n",
232 | "def dumpchoice(extensionthatischosen):\n",
233 | " pickledump(extensionthatischosen, 'chosenextensions')\n",
234 | "\n",
235 | "with gr.Blocks() as vclcolab:\n",
236 | " with gr.Column():\n",
237 | " choose = gr.Dropdown(sortedcolabname, label=\"Choose Your Model\", interactive=True)\n",
238 | " confirm = gr.Button(\"Use This Model\", variant=\"primary\", visible=True)\n",
239 | " donetext = gr.Textbox(\"\", label=\"\", visible=False)\n",
240 | " extchooser = gr.CheckboxGroup([\"placeholder\"], label=\"Extensions\", info=\"Untick the checkboxes on those extensions that you want to disable\", visible=False, interactive=True)\n",
241 | " confirm.click(modelchosen, inputs=[choose, extchooser], outputs=[confirm, donetext, extchooser, choose])\n",
242 | " choose.change(extensionschoose, inputs=[choose], outputs=[extchooser])\n",
243 | " extchooser.change(dumpchoice, inputs=[extchooser])\n",
244 | "\n",
245 | "gr.close_all()\n",
246 | "if choose_models:\n",
247 | " tryport = 7860\n",
248 | " while True:\n",
249 | " tryport += 1\n",
250 | " try:\n",
251 | " 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",
252 | " 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",
253 | " print('\u001b[0m')\n",
254 | " vclcolab.launch(server_port=tryport)\n",
255 | " break\n",
256 | " except OSError:\n",
257 | " pass\n",
258 | "\n",
259 | " while True:\n",
260 | " try:\n",
261 | " if modelischosen:\n",
262 | " clear_output(wait=True)\n",
263 | " print(modelchosenmessage)\n",
264 | " print('\u001b[0m')\n",
265 | " vclcolab.close()\n",
266 | " break\n",
267 | " except KeyboardInterrupt:\n",
268 | " clear_output(wait=True)\n",
269 | " print(\"\u001b[1;33mGradio UI interrupted\")\n",
270 | " print('\u001b[0m')\n",
271 | " vclcolab.close()\n",
272 | " # sys.exit()\n",
273 | " # os._exit(1)\n",
274 | " break\n",
275 | "\n",
276 | "aria2c_lines = []\n",
277 | "colabfilename = ''\n",
278 | "chosencolabfilepath = os.path.join(everycolab, colaboptions[\"filename\"])\n",
279 | "\n",
280 | "if chosencolabname:\n",
281 | " colabfilename = chosencolabname + '_webui_colab.ipynb'\n",
282 | " colaboptions[\"filename\"] = colabfilename\n",
283 | " chosencolabfilepath = os.path.join(everycolab, colabfilename)\n",
284 | "\n",
285 | "if os.path.exists(chosencolabfilepath):\n",
286 | " print(\"\u001b[1;32mGathering aria2c code from \" + chosencolabfilepath + \"...\")\n",
287 | " print('\u001b[0m')\n",
288 | " with open(chosencolabfilepath, 'r', encoding='utf-8') as f:\n",
289 | " for line in f:\n",
290 | " stripped_line = line.strip()\n",
291 | " if stripped_line.startswith('\"!aria2c'):\n",
292 | " aria2c_lines.append(stripped_line)\n",
293 | "\n",
294 | "if aria2c_lines:\n",
295 | " pickledump(aria2c_lines, 'arialist')\n",
296 | "\n",
297 | "colaboptions[\"empty_model\"] = emptymodel\n",
298 | "\n",
299 | "pickledump(colaboptions, 'colaboptions')\n",
300 | "\n",
301 | "# !python /content/vcltools/camendurucolab.py {colabfilename} {repo_branch} part1\n",
302 | "!apt -y update -qq\n",
303 | "!python /content/vcltools/camendurucolab3.py #{colabfilename} {repo_branch} part2\n",
304 | "!python /content/vcltools/runaria3.py\n",
305 | "%cd /content/volatile-concentration-localux\n",
306 | "\n",
307 | "# if extensiontoremove and not emptymodel:\n",
308 | "# for ext in extensiontoremove:\n",
309 | "# extpath = os.path.join('/content/volatile-concentration-localux/extensions', ext)\n",
310 | "# if os.path.exists(extpath):\n",
311 | "# shutil.rmtree(extpath)\n",
312 | "# print(f\"removed {ext} extension\")\n",
313 | "\n",
314 | "# !python /content/vcltools/camendurucolab.py {colabfilename} {repo_branch} part3\n",
315 | "!sed -i -e '''/from modules import launch_utils/a\\import os''' /content/volatile-concentration-localux/launch.py\n",
316 | "!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",
317 | "!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",
318 | "\n",
319 | "print(\"\u001b[1;32mlaunching the webui...\")\n",
320 | "print('\u001b[0m')\n",
321 | "\n",
322 | "!python /content/vcltools/setuptimer.py\n",
323 | "!echo -n {start_colab} > /content/volatile-concentration-localux/static/colabTimer.txt\n",
324 | "!wget -q https://raw.githubusercontent.com/etherealxx/batchlinks-webui/main/notification.mp3 -P /content/volatile-concentration-localux\n",
325 | "\n",
326 | "!python launch.py --listen --xformers --enable-insecure-extension-access --theme dark --gradio-queue --multiple"
327 | ]
328 | },
329 | {
330 | "cell_type": "markdown",
331 | "metadata": {
332 | "id": "ZGlOpxFdEIB5"
333 | },
334 | "source": [
335 | "(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)"
336 | ]
337 | },
338 | {
339 | "cell_type": "markdown",
340 | "metadata": {
341 | "id": "dYiw0gLVRpTz"
342 | },
343 | "source": [
344 | "## ⠀"
345 | ]
346 | },
347 | {
348 | "cell_type": "markdown",
349 | "metadata": {
350 | "id": "0BEVRlWUcbj3"
351 | },
352 | "source": [
353 | " ### (debug area)"
354 | ]
355 | },
356 | {
357 | "cell_type": "code",
358 | "execution_count": null,
359 | "metadata": {
360 | "id": "ZokmtbXibfQf"
361 | },
362 | "outputs": [],
363 | "source": [
364 | "from google.colab import drive\n",
365 | "drive.mount('/content/drive')"
366 | ]
367 | },
368 | {
369 | "cell_type": "code",
370 | "execution_count": null,
371 | "metadata": {
372 | "id": "pij1YzxGDw7y"
373 | },
374 | "outputs": [],
375 | "source": [
376 | "%cd /content\n",
377 | "!git clone -b dev5 https://github.com/etherealxx/volatile-concentration-localux-colab /content/vcltools"
378 | ]
379 | },
380 | {
381 | "cell_type": "code",
382 | "execution_count": null,
383 | "metadata": {
384 | "id": "e-bXoxXtbgeY"
385 | },
386 | "outputs": [],
387 | "source": [
388 | "import os\n",
389 | "import shutil\n",
390 | "\n",
391 | "def copy_files(source_dir, destination_dir):\n",
392 | " # Create destination directory if it doesn't exist\n",
393 | " if not os.path.exists(destination_dir):\n",
394 | " os.makedirs(destination_dir)\n",
395 | " print(f\"Created directory: {destination_dir}\")\n",
396 | "\n",
397 | " # Get the list of files in the source directory\n",
398 | " files = os.listdir(source_dir)\n",
399 | "\n",
400 | " for file in files:\n",
401 | " source_file = os.path.join(source_dir, file)\n",
402 | " destination_file = os.path.join(destination_dir, file)\n",
403 | "\n",
404 | " # Copy the file to the destination directory\n",
405 | " shutil.copy2(source_file, destination_file)\n",
406 | "\n",
407 | " # Print success message with the filename\n",
408 | " print(f\"Successfully copied {file}.\")\n",
409 | "\n",
410 | "# Specify the source and destination directories\n",
411 | "folder_A = \"/content/volatile-concentration-localux/outputs/txt2img-images/xxx\"\n",
412 | "folder_B = \"/content/drive/MyDrive/xxx\"\n",
413 | "\n",
414 | "# Copy files from folder A to folder B\n",
415 | "copy_files(folder_A, folder_B)"
416 | ]
417 | },
418 | {
419 | "cell_type": "code",
420 | "execution_count": null,
421 | "metadata": {
422 | "id": "nSGdJN0OAqDL"
423 | },
424 | "outputs": [],
425 | "source": [
426 | "%cd /content\n",
427 | "!git clone https://github.com/etherealxx/volatile-concentration-localux-colab /content/colabtools"
428 | ]
429 | },
430 | {
431 | "cell_type": "code",
432 | "execution_count": null,
433 | "metadata": {
434 | "id": "g4UAZfaZ4wgo"
435 | },
436 | "outputs": [],
437 | "source": [
438 | "!rm -rf /content/volatile-concentration-localux\n",
439 | "!rm -rf /content/camendurus\n",
440 | "!rm /content/frpc_linux_amd64"
441 | ]
442 | },
443 | {
444 | "cell_type": "code",
445 | "execution_count": null,
446 | "metadata": {
447 | "id": "--HDCkoxCHnT"
448 | },
449 | "outputs": [],
450 | "source": [
451 | "import os, pickle\n",
452 | "\n",
453 | "toopen = '/content/vclvariables/extensions.pkl'\n",
454 | "\n",
455 | "if os.path.exists(toopen):\n",
456 | " with open(toopen, 'rb') as f:\n",
457 | " arialines2 = pickle.load(f)\n",
458 | "\n",
459 | "for line in arialines2:\n",
460 | " print(line)"
461 | ]
462 | },
463 | {
464 | "cell_type": "code",
465 | "execution_count": null,
466 | "metadata": {
467 | "id": "pE0A4A_jGXkR"
468 | },
469 | "outputs": [],
470 | "source": [
471 | "repo_branch = 'nightly' #@param [\"lite\", \"stable\", \"nightly\"]\n",
472 | "\n",
473 | "colaboptions = {\n",
474 | " \"branch\": repo_branch,\n",
475 | " \"filename\": \"stable_diffusion_1_5_webui_colab.ipynb\",\n",
476 | " \"part\": \"part2\"\n",
477 | "} #default\n",
478 | "\n",
479 | "\n",
480 | "print(colaboptions['branch'])"
481 | ]
482 | },
483 | {
484 | "cell_type": "code",
485 | "execution_count": null,
486 | "metadata": {
487 | "id": "ouZRtBpEMq3V"
488 | },
489 | "outputs": [],
490 | "source": [
491 | "with open('/content/camendurus/nightly/a_certain_model_webui_colab.ipynb', 'r', encoding='utf-8') as f:\n",
492 | " for line in f:\n",
493 | " stripped_line = line.strip()\n",
494 | " if stripped_line.startswith('\"!aria2c'):\n",
495 | " # aria2c_lines.append(stripped_line)\n",
496 | " print(\"\u001b[1;32m\" + stripped_line)\n",
497 | " print('\u001b[0m')\n",
498 | " else:\n",
499 | " print(stripped_line)"
500 | ]
501 | },
502 | {
503 | "cell_type": "code",
504 | "execution_count": null,
505 | "metadata": {
506 | "id": "jKUgiWbaN-TW"
507 | },
508 | "outputs": [],
509 | "source": [
510 | "checktest = None\n",
511 | "with open('/content/arialist.pkl', 'rb') as f:\n",
512 | " checktest = pickle.load(f)\n",
513 | "print(checktest)"
514 | ]
515 | },
516 | {
517 | "cell_type": "code",
518 | "execution_count": null,
519 | "metadata": {
520 | "id": "uYmGyckPbZaQ"
521 | },
522 | "outputs": [],
523 | "source": []
524 | }
525 | ],
526 | "metadata": {
527 | "accelerator": "GPU",
528 | "colab": {
529 | "collapsed_sections": [
530 | "e78dCt3JZ6UX",
531 | "0BEVRlWUcbj3"
532 | ],
533 | "include_colab_link": true,
534 | "private_outputs": true,
535 | "provenance": []
536 | },
537 | "gpuClass": "standard",
538 | "kernelspec": {
539 | "display_name": "Python 3",
540 | "language": "python",
541 | "name": "python3"
542 | },
543 | "language_info": {
544 | "name": "python",
545 | "version": "3.9.6"
546 | },
547 | "vscode": {
548 | "interpreter": {
549 | "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
550 | }
551 | }
552 | },
553 | "nbformat": 4,
554 | "nbformat_minor": 0
555 | }
556 |
--------------------------------------------------------------------------------