|
import sys |
|
import os |
|
from IPython import get_ipython |
|
from IPython .utils import capture |
|
from IPython .display import clear_output |
|
wb =f'/home/studio-lab-user/stable-diffusion-webui' |
|
def gitDownload (OOOO00O0O00OOOOO0 ,O0OOO0OOO0OO00O0O ): |
|
if os .path .exists (O0OOO0OOO0OO00O0O ): |
|
return |
|
get_ipython ().system (f'git clone {OOOO00O0O00OOOOO0} {O0OOO0OOO0OO00O0O}') |
|
def installAdditional (): |
|
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',] |
|
for OO0O0000O0OO000O0 in OOO00OOO0OO00OO0O : |
|
OO0OO0OO0OOO00O0O =OO0O0000O0OO000O0 .split ('/')[-1 ] |
|
if 'github'in OO0O0000O0OO000O0 : |
|
get_ipython ().system (f'git clone --depth 1 {OO0O0000O0OO000O0} {wb}/extensions/{OO0OO0OO0OOO00O0O}') |
|
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') |
|
clear_output () |
|
gitDownload (f'https://huggingface.co/embed/negative',f'{wb}/embeddings/negative') |
|
get_ipython ().system (f'rm -rf {wb}/embeddings/negative/.git') |
|
get_ipython ().system (f'rm {wb}/embeddings/negative/.gitattributes') |
|
gitDownload (f'https://huggingface.co/embed/lora',f'{wb}/models/Lora/positive') |
|
get_ipython ().system (f'rm -rf {wb}/models/Lora/positive/.git') |
|
get_ipython ().system (f'rm {wb}/models/Lora/positive/.gitattributes') |
|
gitDownload (f'https://github.com/DominikDoom/a1111-sd-webui-tagcomplete',f'{wb}/extensions/a1111-sd-webui-tagcomplete') |
|
get_ipython ().system (f'rm -rf {wb}/extensions/a1111-sd-webui-tagcomplete/tags/danbooru.csv') |
|
get_ipython ().system (f'wget https://huggingface.co/gmk123/colab/raw/main/danbooru.csv -O {wb}/extensions/a1111-sd-webui-tagcomplete/tags/danbooru.csv') |
|
gitDownload (f'https://github.com/s0md3v/sd-webui-roop',f'{wb}/extensions/sd-webui-roop') |
|
get_ipython ().system (f'pip install -q insightface==0.7.3 onnx') |
|
get_ipython ().system (f'mkdir -p {wb}/models/roop') |
|
get_ipython ().system (f'wget https://huggingface.co/ezioruan/inswapper_128.onnx/resolve/main/inswapper_128.onnx -O {wb}/models/roop/inswapper_128.onnx') |
|
print ('Roop换脸启用') |
|
import subprocess |
|
def sync_tmp_folder (): |
|
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']] |
|
for OOOO00O0O0O0O000O in OOO0OOO0OOOO0O0OO : |
|
OO0OOOOOOOOO0OO0O =[os .path .expanduser (OO0OO00OOO000O00O )for OO0OO00OOO000O00O in OOOO00O0O0O0O000O ] |
|
subprocess .run (OO0OOOOOOOOO0OO0O ,check =True ) |
|
def run_command (O0O00OO0000O00O0O ,O0000O00O0OO00OOO ): |
|
print (f"Please wait, {O0000O00O0OO00OOO} is loading...") |
|
subprocess .run (O0O00OO0000O00O0O ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL ) |
|
print (f"{O0000O00O0OO00OOO} ok!") |
|
def zrok (): |
|
try : |
|
O0OOOOOOO0000OOO0 ="/home/studio-lab-user/.zrok/bin" |
|
os .makedirs (O0OOOOOOO0000OOO0 ,exist_ok =True ) |
|
subprocess .run (["curl","-sLO","https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz"],check =True ) |
|
subprocess .run (["tar","-xzf","zrok_0.4.23_linux_amd64.tar.gz","-C",O0OOOOOOO0000OOO0 ,"--wildcards","*zrok"],check =True ) |
|
os .remove ("zrok_0.4.23_linux_amd64.tar.gz") |
|
except Exception as O0O0OO00OOO0O0O0O : |
|
print (f"An error occurred: {O0O0OO00OOO0O0O0O}") |
|
def initLocal (): |
|
run_command ('conda install -y conda glib psutil gperftools aria2 gdown wget','【 Installing Conda 】') |
|
run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】') |
|
run_command ('conda clean -y --all','【 Cleaning Conda 】') |
|
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 】') |
|
run_command ('pip install xformers==0.0.23.post1 triton==2.1.0','【 Installing xformers 】') |
|
get_ipython ().system ('pip install -q tqdm') |
|
clear_output () |
|
get_ipython ().run_line_magic ('cd','/home/studio-lab-user') |
|
with capture .capture_output ()as OO000000000O00OOO : |
|
def O000000OO0O0OOO00 (OO0O0OOOOOO0O00OO ,O0000O00O0OOO0000 ,O0O00000OO0OO00O0 ):O00O0OOOO0O0OOO00 =widgets .Button (description =OO0O0OOOOOO0O00OO ,disabled =True ,button_style =O0000O00O0OOO0000 ,layout =widgets .Layout (min_width =O0O00000OO0OO00O0 ));display (O00O0OOOO0O0OOO00 ) |
|
get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui {wb}') |
|
with capture .capture_output ()as OO000000000O00OOO : |
|
get_ipython ().run_line_magic ('cd',f'{wb}') |
|
get_ipython ().system ('pip install -q -r requirements.txt') |
|
get_ipython ().system (f'pip install -q basicsr') |
|
get_ipython ().system (f'pip install -q fake_useragent') |
|
sync_tmp_folder () |
|
clear_output () |
|
zrok () |
|
get_ipython ().system (f'wget https://huggingface.co/gmk123/run/raw/main/zrun.py -O {wb}/zrun.py') |
|
get_ipython ().system (f'wget https://huggingface.co/gmk123/run/raw/main/zrok.py -O {wb}/zrok.py') |
|
installAdditional () |
|
get_ipython ().system (f'rm -rf {wb}/config.json') |
|
get_ipython ().system (f'wget -O {wb}/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"') |
|
get_ipython ().system (f'wget -O {wb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"') |
|
clear_output () |
|
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') |
|
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') |
|
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') |
|
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" |
|
ngrok_token =os .environ .get ('NGROK_TOKEN') |
|
wise +=f" --ngrok {ngrok_token}" |
|
def run (O00OO0OO00OO00OOO ): |
|
clear_output () |
|
print (f'********机组号已记录,防转卖已开启') |
|
print (f'核对购买信息及授权联系telegram搜@Aiquyi8888888') |
|
get_ipython ().system (f'mkdir -p /tmp/ControlNet') |
|
get_ipython ().run_line_magic ('cd',f'{wb}') |
|
get_ipython ().system (f'python {O00OO0OO00OO00OOO} {wise}') |
|
if os .path .exists (f'{wb}'): |
|
run (f'webui.py') |
|
else : |
|
initLocal () |
|
run (f'launch.py') |
|
|