anym / Xl.py
unicord's picture
Upload Xl.py
00892a5
import argparse #line:1
import binascii #line:2
def str_to_bool (OO0O0000OOOOO0OO0 ):#line:5
if OO0O0000OOOOO0OO0 .lower ()in ('yes','true','t','y','1'):#line:6
return True #line:7
elif OO0O0000OOOOO0OO0 .lower ()in ('no','false','f','n','0'):#line:8
return False #line:9
else :#line:10
raise argparse .ArgumentTypeError ('Invalid boolean value: {}'.format (OO0O0000OOOOO0OO0 ))#line:11
parser =argparse .ArgumentParser ()#line:14
parser .add_argument ('--Version',type =str )#line:16
parser .add_argument ('--ControlNet',type =str_to_bool )#line:17
args =parser .parse_args ()#line:20
Version =args .Version #line:22
ControlNet =args .ControlNet #line:23
import sys #line:27
import os #line:28
import base64 #line:29
import importlib .util #line:30
from IPython import get_ipython #line:31
from IPython .display import clear_output #line:32
import tensorflow as tf #line:33
print ("TensorFlow version:",tf .__version__ )#line:35
if tf .test .gpu_device_name ():#line:36
print ("GPU is available")#line:37
else :#line:38
print ("GPU is NOT available")#line:39
raise Exception ("\n没有使用GPU,请在代码执行程序-更改运行时类型-设置为GPU!\n如果不能使用GPU,建议更换账号!")#line:40
w =base64 .b64decode (("d2VidWk=").encode ('ascii')).decode ('ascii')#line:42
sdw =base64 .b64decode (("c3RhYmxlLWRpZmZ1c2lvbi13ZWJ1aQ==").encode ('ascii')).decode ('ascii')#line:43
l =base64 .b64decode (("bGF1bmNo").encode ('ascii')).decode ('ascii')#line:44
wb =f'/content/drive/MyDrive/XL'#line:47
sai =binascii .a2b_uu ("=<W1A8FQE+61I9F9U<VEO;BUS=&%B:6QI='DM86D`").decode ('utf-8')#line:48
sd =binascii .a2b_uu ("04W1A8FQE+61I9F9U<VEO;@``").decode ('utf-8')#line:49
get_ipython ().run_line_magic ('cd','/content')#line:52
get_ipython ().run_line_magic ('env','TF_CPP_MIN_LOG_LEVEL=1')#line:53
def gitDownload (O0O0O00OO00OOO00O ,OOOO00O0OO0O0O00O ):#line:56
if os .path .exists (OOOO00O0OO0O0O00O ):#line:57
return #line:58
get_ipython ().system (f'git clone {O0O0O00OO00OOO00O} {OOOO00O0OO0O0O00O}')#line:60
def installAdditional ():#line:64
O0OOO0O0OOO0O00O0 =[f'https://github.com/camenduru/sd-{w}-tunnels',f'https://github.com/etherealxx/batchlinks-{w}',f'https://github.com/camenduru/sd-civitai-browser',f'https://github.com/AUTOMATIC1111/{sdw}-rembg',f'https://github.com/thomasasfk/sd-{w}-aspect-ratio-helper',f'https://github.com/hanamizuki-ai/{sdw}-localization-zh_Hans',f'https://github.com/camenduru/{sdw}-catppuccin',f'https://github.com/Physton/sd-{w}-prompt-all-in-one',]#line:79
for OO0OO0O0O000O0OO0 in O0OOO0O0OOO0O00O0 :#line:80
O00OOOOOOOOOO0O00 =OO0OO0O0O000O0OO0 .split ('/')[-1 ]#line:82
if 'github'in OO0OO0O0O000O0OO0 :#line:84
get_ipython ().system (f'git clone {OO0OO0O0O000O0OO0} {wb}/extensions/{O00OOOOOOOOOO0O00}')#line:85
get_ipython ().system (f'rm -rf {wb}/embeddings/negative')#line:87
gitDownload (f'https://huggingface.co/embed/negative',f'{wb}/embeddings/negative')#line:88
get_ipython ().system (f'rm -rf {wb}/embeddings/negative/.git')#line:89
get_ipython ().system (f'rm {wb}/embeddings/negative/.gitattributes')#line:90
gitDownload (f'https://github.com/DominikDoom/a1111-sd-{w}-tagcomplete',f'{wb}/extensions/a1111-sd-{w}-tagcomplete')#line:93
get_ipython ().system (f'rm -f {wb}/extensions/a1111-sd-{w}-tagcomplete/tags/danbooru.csv')#line:94
get_ipython ().system (f'wget https://beehomefile.oss-cn-beijing.aliyuncs.com/20210114/danbooru.csv -O {wb}/extensions/a1111-sd-{w}-tagcomplete/tags/danbooru.csv')#line:95
gitDownload (f'https://github.com/Bing-su/adetailer',f'{wb}/extensions/adetailer')#line:98
O00O00O000OOO00OO =['control_v11e_sd15_ip2p.pth','control_v11e_sd15_shuffle.pth','control_v11f1e_sd15_tile.pth','control_v11f1p_sd15_depth.pth','control_v11p_sd15_canny.pth','control_v11p_sd15_inpaint.pth','control_v11p_sd15_lineart.pth','control_v11p_sd15_mlsd.pth','control_v11p_sd15_normalbae.pth','control_v11p_sd15_openpose.pth','control_v11p_sd15_scribble.pth','control_v11p_sd15_seg.pth','control_v11p_sd15_softedge.pth','control_v11p_sd15s2_lineart_anime.pth',]#line:116
get_ipython ().system (f'rm -rf {wb}/extensions/sd-{w}-controlnet')#line:117
if ControlNet :#line:119
gitDownload (f'https://github.com/Mikubill/sd-{w}-controlnet',f'{wb}/extensions/sd-{w}-controlnet')#line:120
for O00OO0OO00OO0OO00 in O00O00O000OOO00OO :#line:121
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/{O00OO0OO00OO0OO00} -d {wb}/extensions/sd-{w}-controlnet/models -o {O00OO0OO00OO0OO00}')#line:122
print ("启用 ControlNet")#line:123
else :#line:124
print ("不启用 ControlNet")#line:125
def initLocal ():#line:135
get_ipython ().system (f'apt -y update -qq')#line:137
get_ipython ().system (f'wget https://huggingface.co/gmk123/colab/resolve/main/libtcmalloc_minimal.so.4 -O /content/libtcmalloc_minimal.so.4')#line:138
get_ipython ().run_line_magic ('env',f'LD_PRELOAD=/content/libtcmalloc_minimal.so.4')#line:139
get_ipython ().system (f'apt -y install -qq aria2 libcairo2-dev pkg-config python3-dev')#line:142
get_ipython ().system (f'pip install -q torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url https://download.pytorch.org/whl/cu118 -U')#line:143
get_ipython ().system (f'pip install -q xformers==0.0.20 triton==2.0.0 -U')#line:144
if Version =="XL":#line:147
get_ipython ().system (f'git clone -b master https://github.com/AUTOMATIC1111/{sdw} /root/main')#line:148
get_ipython ().system (f'git -C {wb}/repositories/{sai} reset --hard')#line:150
installAdditional ()#line:153
get_ipython ().system (f'wget -O {wb}/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:155
get_ipython ().system (f'wget -O {wb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:156
OO0OO00OOOOO00O0O =f"{wb}/models/{sd}"#line:159
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/chilloutmix/resolve/main/chilloutmix_NiPrunedFp32Fix.safetensors -d {OO0OO00OOOOO00O0O} -o chilloutmix_NiPrunedFp32Fix.safetensors')#line:161
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:164
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:167
def run (OOOOO0O0O00000OOO ):#line:173
clear_output ()#line:174
get_ipython ().run_line_magic ('cd',f'{wb}')#line:175
get_ipython ().system (f'python {OOOOO0O0O00000OOO} --share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --xformers --disable-console-progressbars --theme dark --cors-allow-origins=*')#line:176
if os .path .exists (f'{wb}'):#line:179
run (f'{w}.py')#line:180
else :#line:181
initLocal ()#line:183
run (f'{l}.py')