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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#@markdown # Install/Update AUTOMATIC1111 repo
|
| 2 |
+
from IPython.utils import capture
|
| 3 |
+
from IPython.display import clear_output
|
| 4 |
+
from subprocess import getoutput
|
| 5 |
+
import ipywidgets as widgets
|
| 6 |
+
import sys
|
| 7 |
+
import fileinput
|
| 8 |
+
import os
|
| 9 |
+
import time
|
| 10 |
+
import base64
|
| 11 |
+
import gdown
|
| 12 |
+
from gdown.download import get_url_from_gdrive_confirmation
|
| 13 |
+
import requests
|
| 14 |
+
from urllib.request import urlopen, Request
|
| 15 |
+
from urllib.parse import urlparse, parse_qs, unquote
|
| 16 |
+
from tqdm import tqdm
|
| 17 |
+
import six
|
| 18 |
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
blsaphemy=base64.b64decode(("ZWJ1aQ==").encode('ascii')).decode('ascii')
|
| 21 |
+
|
| 22 |
+
if not os.path.exists("/content/gdrive"):
|
| 23 |
+
print('[1;31mGdrive not connected, using temporary colab storage ...')
|
| 24 |
+
time.sleep(4)
|
| 25 |
+
mainpth="MyDrive"
|
| 26 |
+
!mkdir -p /content/gdrive/$mainpth
|
| 27 |
+
Shared_Drive=""
|
| 28 |
+
|
| 29 |
+
if Shared_Drive!="" and not os.path.exists("/content/gdrive/Shareddrives"):
|
| 30 |
+
print('[1;31mShared drive not detected, using default MyDrive')
|
| 31 |
+
mainpth="MyDrive"
|
| 32 |
+
|
| 33 |
+
with capture.capture_output() as cap:
|
| 34 |
+
def inf(msg, style, wdth): inf = widgets.Button(description=msg, disabled=True, button_style=style, layout=widgets.Layout(min_width=wdth));display(inf)
|
| 35 |
+
fgitclone = "git clone --depth 1"
|
| 36 |
+
%mkdir -p /content/gdrive/$mainpth/sd
|
| 37 |
+
%cd /content/gdrive/$mainpth/sd
|
| 38 |
+
!git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-w$blsaphemy
|
| 39 |
+
!mkdir -p /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/cache/
|
| 40 |
+
os.environ['TRANSFORMERS_CACHE']=f"/content/gdrive/{mainpth}/sd/stable-diffusion-w"+blsaphemy+"/cache"
|
| 41 |
+
os.environ['TORCH_HOME'] = f"/content/gdrive/{mainpth}/sd/stable-diffusion-w"+blsaphemy+"/cache"
|
| 42 |
+
|
| 43 |
+
with capture.capture_output() as cap:
|
| 44 |
+
%cd /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/
|
| 45 |
+
!git reset --hard
|
| 46 |
+
!git checkout master
|
| 47 |
+
time.sleep(1)
|
| 48 |
+
!rm webui.sh
|
| 49 |
+
!git pull
|
| 50 |
+
clear_output()
|
| 51 |
+
inf('\u2714 Done','success', '50px')
|
| 52 |
+
|
| 53 |
+
#@markdown ---
|
| 54 |
+
|
| 55 |
+
#@markdown # Requirements
|
| 56 |
+
|
| 57 |
+
print('[1;32mInstalling requirements...')
|
| 58 |
+
|
| 59 |
+
with capture.capture_output() as cap:
|
| 60 |
+
%cd /content/
|
| 61 |
+
!wget -q -i https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dependencies/A1111.txt
|
| 62 |
+
!dpkg -i *.deb
|
| 63 |
+
if not os.path.exists('/content/gdrive/'+mainpth+'/sd/stablediffusiond'): #restore later
|
| 64 |
+
!tar -C /content/gdrive/$mainpth --zstd -xf sd_mrep.tar.zst
|
| 65 |
+
!tar -C / --zstd -xf gcolabdeps.tar.zst
|
| 66 |
+
!rm *.deb | rm *.zst | rm *.txt
|
| 67 |
+
if not os.path.exists('gdrive/'+mainpth+'/sd/libtcmalloc/libtcmalloc_minimal.so.4'):
|
| 68 |
+
%env CXXFLAGS=-std=c++14
|
| 69 |
+
!wget -q https://github.com/gperftools/gperftools/releases/download/gperftools-2.5/gperftools-2.5.tar.gz && tar zxf gperftools-2.5.tar.gz && mv gperftools-2.5 gperftools
|
| 70 |
+
!wget -q https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/Patch
|
| 71 |
+
%cd /content/gperftools
|
| 72 |
+
!patch -p1 < /content/Patch
|
| 73 |
+
!./configure --enable-minimal --enable-libunwind --enable-frame-pointers --enable-dynamic-sized-delete-support --enable-sized-delete --enable-emergency-malloc; make -j4
|
| 74 |
+
!mkdir -p /content/gdrive/$mainpth/sd/libtcmalloc && cp .libs/libtcmalloc*.so* /content/gdrive/$mainpth/sd/libtcmalloc
|
| 75 |
+
%env LD_PRELOAD=/content/gdrive/$mainpth/sd/libtcmalloc/libtcmalloc_minimal.so.4
|
| 76 |
+
%cd /content
|
| 77 |
+
!rm *.tar.gz Patch && rm -r /content/gperftools
|
| 78 |
+
else:
|
| 79 |
+
%env LD_PRELOAD=/content/gdrive/$mainpth/sd/libtcmalloc/libtcmalloc_minimal.so.4
|
| 80 |
+
|
| 81 |
+
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
| 82 |
+
os.environ['PYTHONWARNINGS'] = 'ignore'
|
| 83 |
+
!sed -i 's@text = _formatwarnmsg(msg)@text =\"\"@g' /usr/lib/python3.10/warnings.py
|
| 84 |
+
|
| 85 |
+
clear_output()
|
| 86 |
+
inf('\u2714 Done','success', '50px')
|
| 87 |
+
|
| 88 |
+
#@markdown ---
|
| 89 |
+
#@markdown # ControlNet
|
| 90 |
+
from torch.hub import download_url_to_file
|
| 91 |
+
from urllib.parse import urlparse
|
| 92 |
+
import re
|
| 93 |
+
from subprocess import run
|
| 94 |
+
|
| 95 |
+
XL_Model = "None" #@param [ "None", "All", "Canny", "Depth", "Sketch", "OpenPose", "Recolor"]
|
| 96 |
+
|
| 97 |
+
v1_Model = "None" #@param [ "None", "All (21GB)", "Canny", "Depth", "Lineart", "MLSD", "Normal", "OpenPose", "Scribble", "Seg", "ip2p", "Shuffle", "Inpaint", "Softedge", "Lineart_Anime", "Tile", "T2iadapter_Models"]
|
| 98 |
+
|
| 99 |
+
v2_Model = "None" #@param [ "None", "All", "Canny", "Depth", "HED", "OpenPose", "Scribble"]
|
| 100 |
+
|
| 101 |
+
#@markdown - Download/update ControlNet extension and its models
|
| 102 |
+
|
| 103 |
+
def download(url, model_dir):
|
| 104 |
+
|
| 105 |
+
filename = os.path.basename(urlparse(url).path)
|
| 106 |
+
pth = os.path.abspath(os.path.join(model_dir, filename))
|
| 107 |
+
if not os.path.exists(pth):
|
| 108 |
+
print('Downloading: '+os.path.basename(url))
|
| 109 |
+
download_url_to_file(url, pth, hash_prefix=None, progress=True)
|
| 110 |
+
else:
|
| 111 |
+
print(f"[1;32mThe model {filename} already exists[0m")
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
Canny='https://huggingface.co/lllyasviel/sd_control_collection/resolve/main/diffusers_xl_canny_mid.safetensors'
|
| 115 |
+
Depth='https://huggingface.co/lllyasviel/sd_control_collection/resolve/main/diffusers_xl_depth_mid.safetensors'
|
| 116 |
+
Sketch='https://huggingface.co/lllyasviel/sd_control_collection/resolve/main/sai_xl_sketch_256lora.safetensors'
|
| 117 |
+
OpenPose='https://huggingface.co/lllyasviel/sd_control_collection/resolve/main/thibaud_xl_openpose_256lora.safetensors'
|
| 118 |
+
Recolor='https://huggingface.co/lllyasviel/sd_control_collection/resolve/main/sai_xl_recolor_128lora.safetensors'
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
with capture.capture_output() as cap:
|
| 122 |
+
%cd /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/extensions
|
| 123 |
+
if not os.path.exists('sd-w'+blsaphemy+'-controlnet'):
|
| 124 |
+
!git clone https://github.com/Mikubill/sd-w$blsaphemy-controlnet.git
|
| 125 |
+
%cd /content
|
| 126 |
+
else:
|
| 127 |
+
%cd sd-w$blsaphemy-controlnet
|
| 128 |
+
!git reset --hard
|
| 129 |
+
!git pull
|
| 130 |
+
%cd /content
|
| 131 |
+
|
| 132 |
+
mdldir='/content/gdrive/'+mainpth+'/sd/stable-diffusion-w'+blsaphemy+'/extensions/sd-w'+blsaphemy+'-controlnet/models'
|
| 133 |
+
for filename in os.listdir(mdldir):
|
| 134 |
+
if "_sd14v1" in filename:
|
| 135 |
+
renamed = re.sub("_sd14v1", "-fp16", filename)
|
| 136 |
+
os.rename(os.path.join(mdldir, filename), os.path.join(mdldir, renamed))
|
| 137 |
+
|
| 138 |
+
!wget -q -O CN_models.txt https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/CN_models.txt
|
| 139 |
+
!wget -q -O CN_models_v2.txt https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/CN_models_v2.txt
|
| 140 |
+
!wget -q -O CN_models_XL.txt https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/CN_models_XL.txt
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
with open("CN_models.txt", 'r') as f:
|
| 144 |
+
mdllnk = f.read().splitlines()
|
| 145 |
+
with open("CN_models_v2.txt", 'r') as d:
|
| 146 |
+
mdllnk_v2 = d.read().splitlines()
|
| 147 |
+
with open("CN_models_XL.txt", 'r') as d:
|
| 148 |
+
mdllnk_XL = d.read().splitlines()
|
| 149 |
+
|
| 150 |
+
!rm CN_models.txt CN_models_v2.txt CN_models_XL.txt
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
if XL_Model == "All":
|
| 154 |
+
for lnk_XL in mdllnk_XL:
|
| 155 |
+
download(lnk_XL, mdldir)
|
| 156 |
+
clear_output()
|
| 157 |
+
inf('\u2714 Done','success', '50px')
|
| 158 |
+
|
| 159 |
+
elif XL_Model == "None":
|
| 160 |
+
pass
|
| 161 |
+
clear_output()
|
| 162 |
+
inf('\u2714 Done','success', '50px')
|
| 163 |
+
|
| 164 |
+
else:
|
| 165 |
+
download(globals()[XL_Model], mdldir)
|
| 166 |
+
clear_output()
|
| 167 |
+
inf('\u2714 Done','success', '50px')
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
Canny='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny.pth'
|
| 171 |
+
Depth='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth.pth'
|
| 172 |
+
Lineart='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart.pth'
|
| 173 |
+
MLSD='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd.pth'
|
| 174 |
+
Normal='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae.pth'
|
| 175 |
+
OpenPose='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose.pth'
|
| 176 |
+
Scribble='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble.pth'
|
| 177 |
+
Seg='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg.pth'
|
| 178 |
+
ip2p='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p.pth'
|
| 179 |
+
Shuffle='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle.pth'
|
| 180 |
+
Inpaint='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint.pth'
|
| 181 |
+
Softedge='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge.pth'
|
| 182 |
+
Lineart_Anime='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime.pth'
|
| 183 |
+
Tile='https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile.pth'
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
with capture.capture_output() as cap:
|
| 187 |
+
cfgnames=[os.path.basename(url).split('.')[0]+'.yaml' for url in mdllnk_v2]
|
| 188 |
+
%cd /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/extensions/sd-w$blsaphemy-controlnet/models
|
| 189 |
+
for name in cfgnames:
|
| 190 |
+
run(['cp', 'cldm_v21.yaml', name])
|
| 191 |
+
%cd /content
|
| 192 |
+
|
| 193 |
+
if v1_Model == "All (21GB)":
|
| 194 |
+
for lnk in mdllnk:
|
| 195 |
+
download(lnk, mdldir)
|
| 196 |
+
clear_output()
|
| 197 |
+
|
| 198 |
+
elif v1_Model == "T2iadapter_Models":
|
| 199 |
+
mdllnk=list(filter(lambda x: 't2i' in x, mdllnk))
|
| 200 |
+
for lnk in mdllnk:
|
| 201 |
+
download(lnk, mdldir)
|
| 202 |
+
clear_output()
|
| 203 |
+
|
| 204 |
+
elif v1_Model == "None":
|
| 205 |
+
pass
|
| 206 |
+
clear_output()
|
| 207 |
+
|
| 208 |
+
else:
|
| 209 |
+
download(globals()[v1_Model], mdldir)
|
| 210 |
+
clear_output()
|
| 211 |
+
|
| 212 |
+
Canny='https://huggingface.co/thibaud/controlnet-sd21/resolve/main/control_v11p_sd21_canny.safetensors'
|
| 213 |
+
Depth='https://huggingface.co/thibaud/controlnet-sd21/resolve/main/control_v11p_sd21_depth.safetensors'
|
| 214 |
+
HED='https://huggingface.co/thibaud/controlnet-sd21/resolve/main/control_v11p_sd21_hed.safetensors'
|
| 215 |
+
OpenPose='https://huggingface.co/thibaud/controlnet-sd21/resolve/main/control_v11p_sd21_openposev2.safetensors'
|
| 216 |
+
Scribble='https://huggingface.co/thibaud/controlnet-sd21/resolve/main/control_v11p_sd21_scribble.safetensors'
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
if v2_Model == "All":
|
| 220 |
+
for lnk_v2 in mdllnk_v2:
|
| 221 |
+
download(lnk_v2, mdldir)
|
| 222 |
+
clear_output()
|
| 223 |
+
inf('\u2714 Done','success', '50px')
|
| 224 |
+
|
| 225 |
+
elif v2_Model == "None":
|
| 226 |
+
pass
|
| 227 |
+
clear_output()
|
| 228 |
+
inf('\u2714 Done','success', '50px')
|
| 229 |
+
|
| 230 |
+
else:
|
| 231 |
+
download(globals()[v2_Model], mdldir)
|
| 232 |
+
clear_output()
|
| 233 |
+
inf('\u2714 Done','success', '50px')
|
| 234 |
+
|
| 235 |
+
#@markdown ---
|
| 236 |
+
#@markdown # Start Stable-Diffusion
|
| 237 |
+
from IPython.utils import capture
|
| 238 |
+
import time
|
| 239 |
+
import sys
|
| 240 |
+
import fileinput
|
| 241 |
+
from pyngrok import ngrok, conf
|
| 242 |
+
import re
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
Use_Cloudflare_Tunnel = False #@param {type:"boolean"}
|
| 246 |
+
#@markdown - Offers better gradio responsivity
|
| 247 |
+
|
| 248 |
+
Ngrok_token = "" #@param {type:"string"}
|
| 249 |
+
|
| 250 |
+
#@markdown - Input your ngrok token if you want to use ngrok server
|
| 251 |
+
|
| 252 |
+
User = "" #@param {type:"string"}
|
| 253 |
+
Password= "" #@param {type:"string"}
|
| 254 |
+
#@markdown - Add credentials to your Gradio interface (optional)
|
| 255 |
+
|
| 256 |
+
auth=f"--gradio-auth {User}:{Password}"
|
| 257 |
+
if User =="" or Password=="":
|
| 258 |
+
auth=""
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
with capture.capture_output() as cap:
|
| 262 |
+
%cd /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/modules/
|
| 263 |
+
!wget -q -O extras.py https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-w$blsaphemy/master/modules/extras.py
|
| 264 |
+
!wget -q -O sd_models.py https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-w$blsaphemy/master/modules/sd_models.py
|
| 265 |
+
!wget -q -O /usr/local/lib/python3.10/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py
|
| 266 |
+
%cd /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/
|
| 267 |
+
|
| 268 |
+
!sed -i 's@shared.opts.data\["sd_model_checkpoint"] = checkpoint_info.title@shared.opts.data\["sd_model_checkpoint"] = checkpoint_info.title;model.half()@' /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/modules/sd_models.py
|
| 269 |
+
#!sed -i 's@ui.create_ui().*@ui.create_ui();shared.demo.queue(concurrency_count=999999,status_update_rate=0.1)@' /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/webui.py
|
| 270 |
+
!sed -i "s@map_location='cpu'@map_location='cuda'@" /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/modules/extras.py
|
| 271 |
+
|
| 272 |
+
!sed -i 's@possible_sd_paths =.*@possible_sd_paths = [\"/content/gdrive/{mainpth}/sd/stablediffusion\"]@' /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/modules/paths.py
|
| 273 |
+
!sed -i 's@\.\.\/@src/@g' /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/modules/paths.py
|
| 274 |
+
!sed -i 's@src/generative-models@generative-models@g' /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/modules/paths.py
|
| 275 |
+
|
| 276 |
+
!sed -i 's@print(\"No module.*@@' /content/gdrive/$mainpth/sd/stablediffusion/ldm/modules/diffusionmodules/model.py
|
| 277 |
+
!sed -i 's@\["sd_model_checkpoint"\]@\["sd_model_checkpoint", "sd_vae", "CLIP_stop_at_last_layers", "inpainting_mask_weight", "initial_noise_multiplier"\]@g' /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/modules/shared.py
|
| 278 |
+
|
| 279 |
+
share=''
|
| 280 |
+
if Ngrok_token!="":
|
| 281 |
+
ngrok.kill()
|
| 282 |
+
srv=ngrok.connect(7860, pyngrok_config=conf.PyngrokConfig(auth_token=Ngrok_token) , bind_tls=True).public_url
|
| 283 |
+
|
| 284 |
+
for line in fileinput.input('/usr/local/lib/python3.10/dist-packages/gradio/blocks.py', inplace=True):
|
| 285 |
+
if line.strip().startswith('self.server_name ='):
|
| 286 |
+
line = f' self.server_name = "{srv[8:]}"\n'
|
| 287 |
+
if line.strip().startswith('self.protocol = "https"'):
|
| 288 |
+
line = ' self.protocol = "https"\n'
|
| 289 |
+
if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
|
| 290 |
+
line = ''
|
| 291 |
+
if line.strip().startswith('else "http"'):
|
| 292 |
+
line = ''
|
| 293 |
+
sys.stdout.write(line)
|
| 294 |
+
|
| 295 |
+
elif Use_Cloudflare_Tunnel:
|
| 296 |
+
with capture.capture_output() as cap:
|
| 297 |
+
!pkill cloudflared
|
| 298 |
+
time.sleep(4)
|
| 299 |
+
!nohup cloudflared tunnel --url http://localhost:7860 > /content/srv.txt 2>&1 &
|
| 300 |
+
time.sleep(4)
|
| 301 |
+
with open('/content/srv.txt', "r") as file: text = file.read()
|
| 302 |
+
srv= re.findall(r"https?://(?:\S+?\.)?trycloudflare\.com\S*", text)[0]
|
| 303 |
+
|
| 304 |
+
for line in fileinput.input('/usr/local/lib/python3.10/dist-packages/gradio/blocks.py', inplace=True):
|
| 305 |
+
if line.strip().startswith('self.server_name ='):
|
| 306 |
+
line = f' self.server_name = "{srv[8:]}"\n'
|
| 307 |
+
if line.strip().startswith('self.protocol = "https"'):
|
| 308 |
+
line = ' self.protocol = "https"\n'
|
| 309 |
+
if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
|
| 310 |
+
line = ''
|
| 311 |
+
if line.strip().startswith('else "http"'):
|
| 312 |
+
line = ''
|
| 313 |
+
sys.stdout.write(line)
|
| 314 |
+
|
| 315 |
+
!rm /content/srv.txt
|
| 316 |
+
|
| 317 |
+
else:
|
| 318 |
+
share='--share'
|
| 319 |
+
|
| 320 |
+
ckptdir=''
|
| 321 |
+
if os.path.exists('/content/temp_models'):
|
| 322 |
+
ckptdir='--ckpt-dir /content/temp_models'
|
| 323 |
+
|
| 324 |
+
try:
|
| 325 |
+
model
|
| 326 |
+
if os.path.isfile(model):
|
| 327 |
+
!python /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --ckpt "$model" --xformers $auth --disable-console-progressbars --upcast-sampling $ckptdir
|
| 328 |
+
else:
|
| 329 |
+
!python /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --ckpt-dir "$model" --xformers $auth --disable-console-progressbars --upcast-sampling
|
| 330 |
+
except:
|
| 331 |
+
!python /content/gdrive/$mainpth/sd/stable-diffusion-w$blsaphemy/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --xformers $auth --disable-console-progressbars --upcast-sampling $ckptdir
|