【修復(fù)更新】重啟AI繪畫(huà)云盤(pán)版,生命不息免費(fèi)不止~


這啥情況
#@markdown # 4、開(kāi)始運(yùn)行Stable-Diffusion(默認(rèn)開(kāi)啟xformers)
from IPython.utils import capture
import time
import sys
import fileinput
from pyngrok import ngrok, conf
import base64
blasphemy0=base64.b64decode(("c3RhYmxlLWRpZmZ1c2lvbi13ZWJ1aQ==").encode('ascii')).decode('ascii')
blasphemy=base64.b64decode(("d2VidWk=").encode('ascii')).decode('ascii')
blasphemy2=base64.b64decode(("c3RhYmxlLWRpZmZ1c2lvbg==").encode('ascii')).decode('ascii')
blasphemy3=base64.b64decode(("c3RhYmxlZGlmZnVzaW9u").encode('ascii')).decode('ascii')
#@markdown - 使用內(nèi)網(wǎng)穿透,原則上好于gradio,不好用取消勾選
Use_Cloudflare_Tunnel = True #@param {type:"boolean"}
Ngrok_token = ""
User = "" #@param {type:"string"}
Password= "" #@param {type:"string"}
#@markdown - 為連接添加賬戶密碼,無(wú)特殊需要默認(rèn)保持空即可
auth=f"--gradio-auth {User}:{Password}"
if User =="" or Password=="":
?auth=""
%cd /content/
with capture.capture_output() as cap:
?%cd /content/gdrive/$mainpth/sd/$blasphemy0/modules/
?if Use_Latest_Working_Commit:
??!wget -q -O paths.py https://github.com/TheLastBen/fast-$blasphemy2/raw/5632d2ef7fffd940976538d270854ec4faf26855/AUTOMATIC1111_files/paths.py
??!wget -q -O extras.py https://github.com/AUTOMATIC1111/$blasphemy0/raw/a9eab236d7e8afa4d6205127904a385b2c43bb24/modules/extras.py
??!wget -q -O sd_models.py https://github.com/AUTOMATIC1111/$blasphemy0/raw/a9eab236d7e8afa4d6205127904a385b2c43bb24/modules/sd_models.py
??!wget -q -O /usr/local/lib/python3.10/dist-packages/gradio/blocks.py https://github.com/TheLastBen/fast-$blasphemy2/raw/7ff88eaa1fb4997bacd9845bd487f9a14335d625/AUTOMATIC1111_files/blocks.py?
?else:
??!wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-$blasphemy2/main/AUTOMATIC1111_files/paths.py
??!wget -q -O extras.py https://raw.githubusercontent.com/AUTOMATIC1111/$blasphemy0/master/modules/extras.py
??!wget -q -O sd_models.py https://raw.githubusercontent.com/AUTOMATIC1111/$blasphemy0/master/modules/sd_models.py
??!wget -q -O /usr/local/lib/python3.10/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-$blasphemy2/main/AUTOMATIC1111_files/blocks.py
?%cd /content/gdrive/$mainpth/sd/$blasphemy0/
?!sed -i "s@os.path.splitext(checkpoint_file)@os.path.splitext(checkpoint_file); map_location='cuda'@" /content/gdrive/$mainpth/sd/$blasphemy0/modules/sd_models.py
?!sed -i 's@ui.create_ui().*@ui.create_ui();shared.demo.queue(concurrency_count=999999,status_update_rate=0.1)@' /content/gdrive/$mainpth/sd/$blasphemy0/$blasphemy.py
?!sed -i "s@map_location='cpu'@map_location='cuda'@" /content/gdrive/$mainpth/sd/$blasphemy0/modules/extras.py
?!sed -i 's@/content/gdrive/MyDrive/sd/'+blasphemy3+'@/content/gdrive/{mainpth}/sd/'+blasphemy3+'@' /content/gdrive/$mainpth/sd/$blasphemy0/modules/paths.py
?!sed -i 's@print(\"No module.*@@' /content/gdrive/$mainpth/sd/$blasphemy3/ldm/modules/diffusionmodules/model.py
?!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"),@' /content/gdrive/$mainpth/sd/blasphemy0/modules/shared.py
share=''
if Ngrok_token!="":
?ngrok.kill()
?srv=ngrok.connect(7860, pyngrok_config=conf.PyngrokConfig(auth_token=Ngrok_token) , bind_tls=True).public_url
?for line in fileinput.input('/usr/local/lib/python3.10/dist-packages/gradio/blocks.py', inplace=True):
??if line.strip().startswith('self.server_name ='):
????line = f'??????self.server_name = "{srv[8:]}"\n'
??if line.strip().startswith('self.protocol = "https"'):
????line = '??????self.protocol = "https"\n'
??if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
????line = ''
??if line.strip().startswith('else "http"'):
????line = ''
??sys.stdout.write(line)
elif Use_Cloudflare_Tunnel:
?with capture.capture_output() as cap:
??!pkill cloudflared
??time.sleep(4)
??!nohup cloudflared tunnel --url http://localhost:7860 > /content/srv.txt 2>&1 &
??time.sleep(4)
??!grep -o 'https[^[:space:]]*\.trycloudflare.com' /content/srv.txt >/content/srvr.txt
??time.sleep(2)
??srv= getoutput('cat /content/srvr.txt')
??for line in fileinput.input('/usr/local/lib/python3.10/dist-packages/gradio/blocks.py', inplace=True):
???if line.strip().startswith('self.server_name ='):
?????line = f'??????self.server_name = "{srv[8:]}"\n'
???if line.strip().startswith('self.protocol = "https"'):
?????line = '??????self.protocol = "https"\n'
???if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
?????line = ''
???if line.strip().startswith('else "http"'):
?????line = ''
???sys.stdout.write(line)
???????
??!rm /content/srv.txt /content/srvr.txt
else:
?share='--share'
try:
?model
?if os.path.isfile(model):
??!python /content/gdrive/$mainpth/sd/$blasphemy0/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
?else:
??!python /content/gdrive/$mainpth/sd/$blasphemy0/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
except:
??!python /content/gdrive/$mainpth/sd/$blasphemy0/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --xformers $auth --disable-console-progressbars