import sys #line:1 import os #line:2 from IPython import get_ipython #line:3 from IPython .utils import capture #line:4 from IPython .display import clear_output #line:5 wb =f'/home/studio-lab-user/stable-diffusion-webui'#line:8 def gitDownload (OOOO00O0O00OOOOO0 ,O0OOO0OOO0OO00O0O ):#line:11 if os .path .exists (O0OOO0OOO0OO00O0O ):#line:12 return #line:13 get_ipython ().system (f'git clone {OOOO00O0O00OOOOO0} {O0OOO0OOO0OO00O0O}')#line:15 def installAdditional ():#line:18 OOO00OOO0OO00OO0O =['https://github.com/AlUlkesh/stable-diffusion-webui-images-browser','https://github.com/etherealxx/batchlinks-webui','https://github.com/camenduru/sd-civitai-browser','https://github.com/thomasasfk/sd-webui-aspect-ratio-helper','https://github.com/fkunn1326/openpose-editor','https://github.com/nonnonstop/sd-webui-3d-open-pose-editor','https://github.com/Physton/sd-webui-prompt-all-in-one','https://github.com/Bing-su/adetailer','https://github.com/picobyte/stable-diffusion-webui-wd14-tagger','https://github.com/Mikubill/sd-webui-controlnet','https://github.com/IDEA-Research/DWPose','https://github.com/Tencent/LightDiffusionFlow','https://github.com/thisjam/sd-webui-oldsix-prompt','https://github.com/continue-revolution/sd-webui-segment-anything','https://github.com/hanamizuki-ai/stable-diffusion-webui-localization-zh_Hans','https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111',]#line:60 for OO0O0000O0OO000O0 in OOO00OOO0OO00OO0O :#line:61 OO0OO0OO0OOO00O0O =OO0O0000O0OO000O0 .split ('/')[-1 ]#line:63 if 'github'in OO0O0000O0OO000O0 :#line:65 get_ipython ().system (f'git clone --depth 1 {OO0O0000O0OO000O0} {wb}/extensions/{OO0OO0OO0OOO00O0O}')#line:66 get_ipython ().system (f'wget https://raw.githubuserhome/studio-lab-user.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py -O {wb}/scripts/run_n_times.py')#line:68 clear_output ()#line:70 gitDownload (f'https://huggingface.co/embed/negative',f'{wb}/embeddings/negative')#line:72 get_ipython ().system (f'rm -rf {wb}/embeddings/negative/.git')#line:73 get_ipython ().system (f'rm {wb}/embeddings/negative/.gitattributes')#line:74 gitDownload (f'https://huggingface.co/embed/lora',f'{wb}/models/Lora/positive')#line:76 get_ipython ().system (f'rm -rf {wb}/models/Lora/positive/.git')#line:77 get_ipython ().system (f'rm {wb}/models/Lora/positive/.gitattributes')#line:78 gitDownload (f'https://github.com/DominikDoom/a1111-sd-webui-tagcomplete',f'{wb}/extensions/a1111-sd-webui-tagcomplete')#line:81 get_ipython ().system (f'rm -rf {wb}/extensions/a1111-sd-webui-tagcomplete/tags/danbooru.csv')#line:82 get_ipython ().system (f'wget https://huggingface.co/gmk123/colab/raw/main/danbooru.csv -O {wb}/extensions/a1111-sd-webui-tagcomplete/tags/danbooru.csv')#line:83 gitDownload (f'https://github.com/s0md3v/sd-webui-roop',f'{wb}/extensions/sd-webui-roop')#line:86 get_ipython ().system (f'pip install -q insightface==0.7.3 onnx')#line:87 get_ipython ().system (f'mkdir -p {wb}/models/roop')#line:88 get_ipython ().system (f'wget https://huggingface.co/ezioruan/inswapper_128.onnx/resolve/main/inswapper_128.onnx -O {wb}/models/roop/inswapper_128.onnx')#line:89 print ('Roop换脸启用')#line:90 import subprocess #line:92 def sync_tmp_folder ():#line:94 OOO0OOO0OOOO0O0OO =[['rm','-rf','~/tmp/*','~/tmp','~/stable-diffusion-webui/models/Stable-diffusion/tmp_models','~/stable-diffusion-webui/models/ControlNet','~/stable-diffusion-webui/models/sam'],['ln','-vs','/tmp','~/tmp'],['ln','-vs','/tmp/models','~/stable-diffusion-webui/models/Stable-diffusion/tmp_models'],['ln','-vs','/tmp/ControlNet','~/stable-diffusion-webui/models/ControlNet'],['ln','-vs','/tmp/sam','~/stable-diffusion-webui/models/sam']]#line:101 for OOOO00O0O0O0O000O in OOO0OOO0OOOO0O0OO :#line:103 OO0OOOOOOOOO0OO0O =[os .path .expanduser (OO0OO00OOO000O00O )for OO0OO00OOO000O00O in OOOO00O0O0O0O000O ]#line:104 subprocess .run (OO0OOOOOOOOO0OO0O ,check =True )#line:105 def run_command (O0O00OO0000O00O0O ,O0000O00O0OO00OOO ):#line:108 print (f"Please wait, {O0000O00O0OO00OOO} is loading...")#line:109 subprocess .run (O0O00OO0000O00O0O ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL )#line:110 print (f"{O0000O00O0OO00OOO} ok!")#line:111 def zrok ():#line:114 try :#line:115 O0OOOOOOO0000OOO0 ="/home/studio-lab-user/.zrok/bin"#line:116 os .makedirs (O0OOOOOOO0000OOO0 ,exist_ok =True )#line:117 subprocess .run (["curl","-sLO","https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz"],check =True )#line:118 subprocess .run (["tar","-xzf","zrok_0.4.23_linux_amd64.tar.gz","-C",O0OOOOOOO0000OOO0 ,"--wildcards","*zrok"],check =True )#line:119 os .remove ("zrok_0.4.23_linux_amd64.tar.gz")#line:120 except Exception as O0O0OO00OOO0O0O0O :#line:122 print (f"An error occurred: {O0O0OO00OOO0O0O0O}")#line:123 def initLocal ():#line:127 run_command ('conda install -y conda glib psutil gperftools aria2 gdown wget','【 Installing Conda 】')#line:129 run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】')#line:130 run_command ('conda clean -y --all','【 Cleaning Conda 】')#line:131 run_command ('pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121','【 Installing Torch 】')#line:132 run_command ('pip install xformers==0.0.23.post1 triton==2.1.0','【 Installing xformers 】')#line:133 get_ipython ().system ('pip install -q tqdm')#line:135 clear_output ()#line:137 get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:138 with capture .capture_output ()as OO000000000O00OOO :#line:141 def O000000OO0O0OOO00 (OO0O0OOOOOO0O00OO ,O0000O00O0OOO0000 ,O0O00000OO0OO00O0 ):O00O0OOOO0O0OOO00 =widgets .Button (description =OO0O0OOOOOO0O00OO ,disabled =True ,button_style =O0000O00O0OOO0000 ,layout =widgets .Layout (min_width =O0O00000OO0OO00O0 ));display (O00O0OOOO0O0OOO00 )#line:142 get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui {wb}')#line:144 with capture .capture_output ()as OO000000000O00OOO :#line:146 get_ipython ().run_line_magic ('cd',f'{wb}')#line:147 get_ipython ().system ('pip install -q -r requirements.txt')#line:149 get_ipython ().system (f'pip install -q basicsr')#line:151 get_ipython ().system (f'pip install -q fake_useragent')#line:152 sync_tmp_folder ()#line:155 clear_output ()#line:157 zrok ()#line:161 get_ipython ().system (f'wget https://huggingface.co/gmk123/run/raw/main/zrun.py -O {wb}/zrun.py')#line:162 get_ipython ().system (f'wget https://huggingface.co/gmk123/run/raw/main/zrok.py -O {wb}/zrok.py')#line:163 installAdditional ()#line:166 get_ipython ().system (f'rm -rf {wb}/config.json')#line:169 get_ipython ().system (f'wget -O {wb}/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:170 get_ipython ().system (f'wget -O {wb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:171 clear_output ()#line:173 get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/wageguagua/sdmodels/resolve/main/蛙哥专属.safetensors -d {wb}/models/Stable-diffusion -o long9.safetensors')#line:153 get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/coco233/colab/resolve/main/ZR888.safetensors -d {wb}/models/Stable-diffusion -o zr888.safetensors') get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors -d {wb}/models/VAE -o vae-ft-mse-840000-ema-pruned.safetensors')#line:177 get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth -d {wb}/models/ESRGAN -o 4x-UltraSharp.pth')#line:179 get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/coco233/moxing/raw/main/JingYe.safetensors -d {wb}/models/Lora -o jy.safetensors') wise ="--xformers --enable-insecure-extension-access --theme dark --disable-console-progressbars --upcast-sampling"#line:181 ngrok_token =os .environ .get ('NGROK_TOKEN')#line:184 wise +=f" --ngrok {ngrok_token}"#line:185 def run (O00OO0OO00OO00OOO ):#line:188 clear_output ()#line:189 print (f'********机组号已记录,防转卖已开启')#line:190 print (f'核对购买信息及授权联系telegram搜@Aiquyi8888888')#line:191 get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:192 get_ipython ().run_line_magic ('cd',f'{wb}')#line:194 get_ipython ().system (f'python {O00OO0OO00OO00OOO} {wise}')#line:195 if os .path .exists (f'{wb}'):#line:198 run (f'webui.py')#line:200 else :#line:201 initLocal ()#line:203 run (f'launch.py')#line:206