TheLastBen
commited on
Commit
·
f99a3e8
1
Parent(s):
bbd3864
Upload 4 files
Browse files- Scripts/mainpaperspacev1.py +0 -2
- Scripts/mainpaperspacev2.py +0 -2
- Scripts/sdxllorapps.py +107 -67
Scripts/mainpaperspacev1.py
CHANGED
@@ -790,8 +790,6 @@ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password):
|
|
790 |
os.chdir('/notebooks')
|
791 |
clear_output()
|
792 |
|
793 |
-
if not os.path.exists('/usr/lib/node_modules/localtunnel'):
|
794 |
-
call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
|
795 |
|
796 |
call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
|
797 |
|
|
|
790 |
os.chdir('/notebooks')
|
791 |
clear_output()
|
792 |
|
|
|
|
|
793 |
|
794 |
call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
|
795 |
|
Scripts/mainpaperspacev2.py
CHANGED
@@ -838,8 +838,6 @@ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password):
|
|
838 |
os.chdir('/notebooks')
|
839 |
clear_output()
|
840 |
|
841 |
-
if not os.path.exists('/usr/lib/node_modules/localtunnel'):
|
842 |
-
call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
|
843 |
|
844 |
call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
|
845 |
|
|
|
838 |
os.chdir('/notebooks')
|
839 |
clear_output()
|
840 |
|
|
|
|
|
841 |
|
842 |
call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
|
843 |
|
Scripts/sdxllorapps.py
CHANGED
@@ -113,33 +113,6 @@ def ntbk():
|
|
113 |
|
114 |
|
115 |
|
116 |
-
def dwn2(url, dst, msg, auth):
|
117 |
-
|
118 |
-
if auth!="":
|
119 |
-
credentials = base64.b64encode(f"USER:{auth}".encode('utf-8')).decode('utf-8')
|
120 |
-
req = Request(url, headers={"User-Agent": "torch.hub", 'Authorization': f'Basic {credentials}'})
|
121 |
-
|
122 |
-
file_size = None
|
123 |
-
u = urlopen(req)
|
124 |
-
meta = u.info()
|
125 |
-
if hasattr(meta, 'getheaders'):
|
126 |
-
content_length = meta.getheaders("Content-Length")
|
127 |
-
else:
|
128 |
-
content_length = meta.get_all("Content-Length")
|
129 |
-
if content_length is not None and len(content_length) > 0:
|
130 |
-
file_size = int(content_length[0])
|
131 |
-
|
132 |
-
with tqdm(total=file_size, disable=False, mininterval=0.5,
|
133 |
-
bar_format=msg+' |{bar:20}| {percentage:3.0f}%') as pbar:
|
134 |
-
with open(dst, "wb") as f:
|
135 |
-
while True:
|
136 |
-
buffer = u.read(8192)
|
137 |
-
if len(buffer) == 0:
|
138 |
-
break
|
139 |
-
f.write(buffer)
|
140 |
-
pbar.update(len(buffer))
|
141 |
-
f.close()
|
142 |
-
|
143 |
|
144 |
def ntbks():
|
145 |
|
@@ -166,11 +139,11 @@ def done():
|
|
166 |
|
167 |
|
168 |
|
169 |
-
def mdlvxl(
|
170 |
|
171 |
os.chdir('/notebooks')
|
172 |
|
173 |
-
if os.path.exists('stable-diffusion-XL') and not os.path.exists('/notebooks/stable-diffusion-XL/unet/diffusion_pytorch_model.
|
174 |
call('rm -r stable-diffusion-XL', shell=True)
|
175 |
if not os.path.exists('stable-diffusion-XL'):
|
176 |
print('[1;33mDownlading SDXL model...')
|
@@ -178,21 +151,21 @@ def mdlvxl(Huggingface_token):
|
|
178 |
os.chdir('stable-diffusion-XL')
|
179 |
call('git init', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
180 |
call('git lfs install --system --skip-repo', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
181 |
-
call('git remote add -f origin https://
|
182 |
call('git config core.sparsecheckout true', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
183 |
call('echo -e "\nscheduler\ntext_encoder\ntext_encoder_2\ntokenizer\ntokenizer_2\nunet\nvae\nfeature_extractor\nmodel_index.json\n!*.safetensors\n!diffusion_pytorch_model.bin\n!pytorch_model.bin\n!*.fp16.bin" > .git/info/sparse-checkout', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
184 |
call('git pull origin main', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
call('rm -r .git', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
190 |
os.chdir('/notebooks')
|
191 |
clear_output()
|
192 |
-
while not os.path.exists('/notebooks/stable-diffusion-XL/unet/diffusion_pytorch_model.
|
193 |
print('[1;31mInvalid HF token, make sure you have access to the model')
|
194 |
time.sleep(8)
|
195 |
-
if os.path.exists('/notebooks/stable-diffusion-XL/unet/diffusion_pytorch_model.
|
196 |
print('[1;32mUsing SDXL model')
|
197 |
else:
|
198 |
print('[1;32mUsing SDXL model')
|
@@ -222,19 +195,19 @@ def downloadmodel_hfxl(Path_to_HuggingFace):
|
|
222 |
call("git config core.sparsecheckout true", shell=True)
|
223 |
call('echo -e "\nscheduler\ntext_encoder\ntokenizer\nunet\nvae\nfeature_extractor\nmodel_index.json\n!*.safetensors\n!*.fp16.bin" > .git/info/sparse-checkout', shell=True)
|
224 |
call("git pull origin main", shell=True)
|
225 |
-
if os.path.exists('unet/diffusion_pytorch_model.
|
226 |
call("rm -r .git", shell=True)
|
227 |
os.chdir('/notebooks')
|
228 |
clear_output()
|
229 |
done()
|
230 |
-
while not os.path.exists('/notebooks/stable-diffusion-custom/unet/diffusion_pytorch_model.
|
231 |
print('[1;31mCheck the link you provided')
|
232 |
os.chdir('/notebooks')
|
233 |
time.sleep(5)
|
234 |
|
235 |
|
236 |
|
237 |
-
def downloadmodel_link_xl(MODEL_LINK
|
238 |
|
239 |
import wget
|
240 |
import gdown
|
@@ -285,7 +258,7 @@ def downloadmodel_link_xl(MODEL_LINK, Huggingface_token):
|
|
285 |
|
286 |
os.chdir('/notebooks')
|
287 |
if src=='huggingface':
|
288 |
-
|
289 |
else:
|
290 |
call("gdown --fuzzy " +MODEL_LINK+ " -O "+modelname, shell=True)
|
291 |
|
@@ -338,7 +311,7 @@ def downloadmodel_path_xl(MODEL_PATH):
|
|
338 |
|
339 |
|
340 |
|
341 |
-
def dls_xl(
|
342 |
|
343 |
os.chdir('/notebooks')
|
344 |
|
@@ -353,22 +326,17 @@ def dls_xl(Huggingface_token, Path_to_HuggingFace, MODEL_PATH, MODEL_LINK):
|
|
353 |
|
354 |
elif MODEL_LINK !="":
|
355 |
|
356 |
-
downloadmodel_link_xl(MODEL_LINK
|
357 |
MODEL_NAMExl="/notebooks/stable-diffusion-custom"
|
358 |
|
359 |
else:
|
360 |
-
|
361 |
-
|
362 |
-
Huggingface_token=input('Your Huggingface Token: ')
|
363 |
-
mdlvxl(Huggingface_token)
|
364 |
-
MODEL_NAMExl="/notebooks/stable-diffusion-XL"
|
365 |
-
else:
|
366 |
-
mdlvxl('')
|
367 |
-
MODEL_NAMExl="/notebooks/stable-diffusion-XL"
|
368 |
|
369 |
return MODEL_NAMExl
|
370 |
|
371 |
|
|
|
372 |
def sess_xl(Session_Name, MODEL_NAMExl):
|
373 |
import gdown
|
374 |
import wget
|
@@ -623,7 +591,7 @@ def dbtrainxl(Resume_Training, UNet_Training_Epochs, UNet_Learning_Rate, dim, Of
|
|
623 |
call('rm -r '+CAPTIONS_DIR+'/.ipynb_checkpoints', shell=True)
|
624 |
|
625 |
|
626 |
-
while not Resume_Training and not os.path.exists(MODEL_NAME+'/unet/diffusion_pytorch_model.
|
627 |
print('[1;31mNo model found, use the "Model Download" cell to download a model.')
|
628 |
time.sleep(5)
|
629 |
|
@@ -696,7 +664,7 @@ def dbtrainxl(Resume_Training, UNet_Training_Epochs, UNet_Learning_Rate, dim, Of
|
|
696 |
|
697 |
|
698 |
|
699 |
-
def sdcmf(MDLPTH, Download_SDXL_Model
|
700 |
|
701 |
from slugify import slugify
|
702 |
from huggingface_hub import HfApi, CommitOperationAdd, create_repo
|
@@ -714,24 +682,20 @@ def sdcmf(MDLPTH, Download_SDXL_Model, Huggingface_token):
|
|
714 |
call('git pull', shell=True)
|
715 |
|
716 |
if os.path.exists(MDLPTH):
|
717 |
-
call('
|
718 |
|
719 |
-
if Download_SDXL_Model and not os.path.exists('
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
urllib.request.urlopen(req)
|
729 |
-
dwn2(mdllnk, 'models/checkpoints/sd_xl_base_0.9.safetensors','[1;33mDownloading the Model', Huggingface_token)
|
730 |
-
except urllib.error.HTTPError as e:
|
731 |
-
print('[1;31mThe token provided has no access to the model, skipping model download...[0m')
|
732 |
-
else:
|
733 |
print('[1;33mModel already exists, skipping download...[0m')
|
734 |
|
|
|
735 |
localurl="https://tensorboard-"+os.environ.get('PAPERSPACE_FQDN')
|
736 |
call("sed -i 's@print(\"To see the GUI go to: http://{}:{}\".format(address, port))@print(\"[32m\u2714 Connected\")\\n print(\"[1;34m"+localurl+"[0m\")@' /notebooks/ComfyUI/server.py", shell=True)
|
737 |
os.chdir('/notebooks')
|
@@ -739,6 +703,82 @@ def sdcmf(MDLPTH, Download_SDXL_Model, Huggingface_token):
|
|
739 |
|
740 |
|
741 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
|
743 |
def clean():
|
744 |
|
|
|
113 |
|
114 |
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
def ntbks():
|
118 |
|
|
|
139 |
|
140 |
|
141 |
|
142 |
+
def mdlvxl():
|
143 |
|
144 |
os.chdir('/notebooks')
|
145 |
|
146 |
+
if os.path.exists('stable-diffusion-XL') and not os.path.exists('/notebooks/stable-diffusion-XL/unet/diffusion_pytorch_model.safetensors'):
|
147 |
call('rm -r stable-diffusion-XL', shell=True)
|
148 |
if not os.path.exists('stable-diffusion-XL'):
|
149 |
print('[1;33mDownlading SDXL model...')
|
|
|
151 |
os.chdir('stable-diffusion-XL')
|
152 |
call('git init', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
153 |
call('git lfs install --system --skip-repo', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
154 |
+
call('git remote add -f origin https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
155 |
call('git config core.sparsecheckout true', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
156 |
call('echo -e "\nscheduler\ntext_encoder\ntext_encoder_2\ntokenizer\ntokenizer_2\nunet\nvae\nfeature_extractor\nmodel_index.json\n!*.safetensors\n!diffusion_pytorch_model.bin\n!pytorch_model.bin\n!*.fp16.bin" > .git/info/sparse-checkout', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
157 |
call('git pull origin main', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
158 |
+
dwn('https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/text_encoder/model.safetensors', 'text_encoder/model.safetensors', '1/4')
|
159 |
+
dwn('https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/text_encoder_2/model.safetensors', 'text_encoder_2/model.safetensors', '2/4')
|
160 |
+
dwn('https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/vae/diffusion_pytorch_model.safetensors', 'vae/diffusion_pytorch_model.safetensors', '3/4')
|
161 |
+
dwn('https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/unet/diffusion_pytorch_model.safetensors', 'unet/diffusion_pytorch_model.safetensors', '4/4')
|
162 |
call('rm -r .git', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
163 |
os.chdir('/notebooks')
|
164 |
clear_output()
|
165 |
+
while not os.path.exists('/notebooks/stable-diffusion-XL/unet/diffusion_pytorch_model.safetensors'):
|
166 |
print('[1;31mInvalid HF token, make sure you have access to the model')
|
167 |
time.sleep(8)
|
168 |
+
if os.path.exists('/notebooks/stable-diffusion-XL/unet/diffusion_pytorch_model.safetensors'):
|
169 |
print('[1;32mUsing SDXL model')
|
170 |
else:
|
171 |
print('[1;32mUsing SDXL model')
|
|
|
195 |
call("git config core.sparsecheckout true", shell=True)
|
196 |
call('echo -e "\nscheduler\ntext_encoder\ntokenizer\nunet\nvae\nfeature_extractor\nmodel_index.json\n!*.safetensors\n!*.fp16.bin" > .git/info/sparse-checkout', shell=True)
|
197 |
call("git pull origin main", shell=True)
|
198 |
+
if os.path.exists('unet/diffusion_pytorch_model.safetensors'):
|
199 |
call("rm -r .git", shell=True)
|
200 |
os.chdir('/notebooks')
|
201 |
clear_output()
|
202 |
done()
|
203 |
+
while not os.path.exists('/notebooks/stable-diffusion-custom/unet/diffusion_pytorch_model.safetensors'):
|
204 |
print('[1;31mCheck the link you provided')
|
205 |
os.chdir('/notebooks')
|
206 |
time.sleep(5)
|
207 |
|
208 |
|
209 |
|
210 |
+
def downloadmodel_link_xl(MODEL_LINK):
|
211 |
|
212 |
import wget
|
213 |
import gdown
|
|
|
258 |
|
259 |
os.chdir('/notebooks')
|
260 |
if src=='huggingface':
|
261 |
+
dwn(MODEL_LINK, modelname,'[1;33mDownloading the Model')
|
262 |
else:
|
263 |
call("gdown --fuzzy " +MODEL_LINK+ " -O "+modelname, shell=True)
|
264 |
|
|
|
311 |
|
312 |
|
313 |
|
314 |
+
def dls_xl(Path_to_HuggingFace, MODEL_PATH, MODEL_LINK):
|
315 |
|
316 |
os.chdir('/notebooks')
|
317 |
|
|
|
326 |
|
327 |
elif MODEL_LINK !="":
|
328 |
|
329 |
+
downloadmodel_link_xl(MODEL_LINK)
|
330 |
MODEL_NAMExl="/notebooks/stable-diffusion-custom"
|
331 |
|
332 |
else:
|
333 |
+
mdlvxl()
|
334 |
+
MODEL_NAMExl="/notebooks/stable-diffusion-XL"
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
|
336 |
return MODEL_NAMExl
|
337 |
|
338 |
|
339 |
+
|
340 |
def sess_xl(Session_Name, MODEL_NAMExl):
|
341 |
import gdown
|
342 |
import wget
|
|
|
591 |
call('rm -r '+CAPTIONS_DIR+'/.ipynb_checkpoints', shell=True)
|
592 |
|
593 |
|
594 |
+
while not Resume_Training and not os.path.exists(MODEL_NAME+'/unet/diffusion_pytorch_model.safetensors'):
|
595 |
print('[1;31mNo model found, use the "Model Download" cell to download a model.')
|
596 |
time.sleep(5)
|
597 |
|
|
|
664 |
|
665 |
|
666 |
|
667 |
+
def sdcmf(MDLPTH, Download_SDXL_Model):
|
668 |
|
669 |
from slugify import slugify
|
670 |
from huggingface_hub import HfApi, CommitOperationAdd, create_repo
|
|
|
682 |
call('git pull', shell=True)
|
683 |
|
684 |
if os.path.exists(MDLPTH):
|
685 |
+
call('ln -s '+MDLPTH+' models/loras', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
686 |
|
687 |
+
if Download_SDXL_Model and not os.path.exists('/notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors'):
|
688 |
+
mdllnk= 'https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors'
|
689 |
+
dwn(mdllnk, '/notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors','[1;33mDownloading the Model')
|
690 |
+
if not os.path.exists('models/checkpoints/sd_xl_base_1.0.safetensors'):
|
691 |
+
call('ln -s /notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors models/checkpoints', shell=True)
|
692 |
+
|
693 |
+
elif Download_SDXL_Model and os.path.exists('/notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors'):
|
694 |
+
if not os.path.exists('models/checkpoints/sd_xl_base_1.0.safetensors'):
|
695 |
+
call('ln -s /notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors models/checkpoints', shell=True)
|
|
|
|
|
|
|
|
|
|
|
696 |
print('[1;33mModel already exists, skipping download...[0m')
|
697 |
|
698 |
+
|
699 |
localurl="https://tensorboard-"+os.environ.get('PAPERSPACE_FQDN')
|
700 |
call("sed -i 's@print(\"To see the GUI go to: http://{}:{}\".format(address, port))@print(\"[32m\u2714 Connected\")\\n print(\"[1;34m"+localurl+"[0m\")@' /notebooks/ComfyUI/server.py", shell=True)
|
701 |
os.chdir('/notebooks')
|
|
|
703 |
|
704 |
|
705 |
|
706 |
+
def test(MDLPTH, User, Password, Download_SDXL_Model):
|
707 |
+
|
708 |
+
|
709 |
+
auth=f"--gradio-auth {User}:{Password}"
|
710 |
+
if User =="" or Password=="":
|
711 |
+
auth=""
|
712 |
+
|
713 |
+
os.chdir('/notebooks')
|
714 |
+
if not os.path.exists('/notebooks/sd/stablediffusiond'): #reset later
|
715 |
+
call('wget -q -O sd_mrep.tar.zst https://huggingface.co/TheLastBen/dependencies/resolve/main/sd_mrep.tar.zst', shell=True)
|
716 |
+
call('tar --zstd -xf sd_mrep.tar.zst', shell=True)
|
717 |
+
call('rm sd_mrep.tar.zst', shell=True)
|
718 |
+
|
719 |
+
os.chdir('/notebooks/sd')
|
720 |
+
if not os.path.exists('stable-diffusion-webui'):
|
721 |
+
call('git clone -q --depth 1 --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui', shell=True)
|
722 |
+
|
723 |
+
os.chdir('/notebooks/sd/stable-diffusion-webui/')
|
724 |
+
call('git reset --hard', shell=True, stdout=open('/dev/null', 'w'))
|
725 |
+
print('[1;32m')
|
726 |
+
call('git checkout master', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
727 |
+
call('git pull', shell=True, stdout=open('/dev/null', 'w'))
|
728 |
+
os.chdir('/notebooks')
|
729 |
+
clear_output()
|
730 |
+
|
731 |
+
|
732 |
+
if os.path.exists(MDLPTH):
|
733 |
+
call('mkdir models/Lora', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
734 |
+
call('ln -s '+MDLPTH+' models/Lora', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
735 |
+
|
736 |
+
if Download_SDXL_Model and not os.path.exists('/notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors'):
|
737 |
+
mdllnk= 'https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors'
|
738 |
+
dwn(mdllnk, '/notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors','[1;33mDownloading the Model')
|
739 |
+
if not os.path.exists('models/Stable-diffusion/sd_xl_base_1.0.safetensors'):
|
740 |
+
call('ln -s /notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors models/Stable-diffusion', shell=True)
|
741 |
+
|
742 |
+
elif Download_SDXL_Model and os.path.exists('/notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors'):
|
743 |
+
if not os.path.exists('models/Stable-diffusion/sd_xl_base_1.0.safetensors'):
|
744 |
+
call('ln -s /notebooks/Fast-Dreambooth/sd_xl_base_1.0.safetensors models/Stable-diffusion', shell=True)
|
745 |
+
print('[1;33mModel already exists, skipping download...[0m')
|
746 |
+
|
747 |
+
call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
|
748 |
+
|
749 |
+
localurl="tensorboard-"+os.environ.get('PAPERSPACE_FQDN')
|
750 |
+
|
751 |
+
for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
|
752 |
+
if line.strip().startswith('self.server_name ='):
|
753 |
+
line = f' self.server_name = "{localurl}"\n'
|
754 |
+
if line.strip().startswith('self.protocol = "https"'):
|
755 |
+
line = ' self.protocol = "https"\n'
|
756 |
+
if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
|
757 |
+
line = ''
|
758 |
+
if line.strip().startswith('else "http"'):
|
759 |
+
line = ''
|
760 |
+
sys.stdout.write(line)
|
761 |
+
|
762 |
+
|
763 |
+
os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
|
764 |
+
|
765 |
+
call("sed -i 's@possible_sd_paths =.*@possible_sd_paths = [\"/notebooks/sd/stablediffusion\"]@' /notebooks/sd/stable-diffusion-webui/modules/paths.py", shell=True)
|
766 |
+
call("sed -i 's@\.\.\/@src/@g' /notebooks/sd/stable-diffusion-webui/modules/paths.py", shell=True)
|
767 |
+
call("sed -i 's@src\/generative-models@generative-models@g' /notebooks/sd/stable-diffusion-webui/modules/paths.py", shell=True)
|
768 |
+
|
769 |
+
call("sed -i 's@-> Network | None@@g' /notebooks/sd/stable-diffusion-webui/extensions-builtin/Lora/network.py", shell=True)
|
770 |
+
call("sed -i 's@from scipy.ndimage.filters@from scipy.ndimage@g' /usr/local/lib/python3.9/dist-packages/basicsr/metrics/niqe.py", shell=True)
|
771 |
+
|
772 |
+
call("sed -i 's@\"quicksettings\": OptionInfo(.*@\"quicksettings\": OptionInfo(\"sd_model_checkpoint, sd_vae, CLIP_stop_at_last_layers, inpainting_mask_weight, initial_noise_multiplier\", \"Quicksettings list\"),@' /notebooks/sd/stable-diffusion-webui/modules/shared.py", shell=True)
|
773 |
+
os.chdir('/notebooks/sd/stable-diffusion-webui')
|
774 |
+
clear_output()
|
775 |
+
|
776 |
+
configf="--disable-console-progressbars --no-gradio-queue --upcast-sampling --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --port 6006 --listen --skip-version-check "+auth
|
777 |
+
|
778 |
+
return configf
|
779 |
+
|
780 |
+
|
781 |
+
|
782 |
|
783 |
def clean():
|
784 |
|