File size: 8,921 Bytes
060567a
 
 
 
 
 
c52f908
 
060567a
c52f908
060567a
eb9de50
c52f908
 
 
 
 
fe32590
 
 
 
 
 
 
c52f908
 
 
 
 
 
 
 
fe32590
 
c52f908
 
fe32590
c52f908
fe32590
c52f908
 
fe32590
 
 
 
 
 
 
c52f908
 
fe32590
c52f908
fe32590
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c52f908
 
 
 
fe32590
c52f908
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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/ComfyUI'#line:8
def gitDownload (OOO0000OOOOO000OO ,OOOOOOO0O00OOO0O0 ):#line:11
    if os .path .exists (OOOOOOO0O00OOO0O0 ):#line:12
        return #line:13
    get_ipython ().system (f'git clone {OOO0000OOOOO000OO} {OOOOOOO0O00OOO0O0}')#line:15
def installAdditional ():#line:18
    get_ipython ().system (f'git clone --recursive https://github.com/ssitu/ComfyUI_UltimateSDUpscale {wb}/custom_nodes/ComfyUI_UltimateSDUpscale')#line:20
    O00OO0000OO00000O =['https://github.com/ltdrdata/ComfyUI-Manager','https://github.com/pythongosssss/ComfyUI-Custom-Scripts','https://github.com/city96/SD-Latent-Upscaler','https://github.com/jags111/efficiency-nodes-comfyui','https://github.com/BlenderNeko/ComfyUI_ADV_CLIP_emb','https://github.com/ssitu/ComfyUI_NestedNodeBuilder','https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet','https://github.com/Fannovel16/comfyui_controlnet_aux','https://github.com/SLAPaper/ComfyUI-Image-Selector','https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes','https://github.com/FizzleDorf/ComfyUI_FizzNodes','https://github.com/WASasquatch/was-node-suite-comfyui','https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite','https://github.com/Gourieff/comfyui-reactor-node','https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation',]#line:39
    for O00OO00OOOO000OO0 in O00OO0000OO00000O :#line:40
        OOO0OOOOOOO00O000 =O00OO00OOOO000OO0 .split ('/')[-1 ]#line:42
        if 'github'in O00OO00OOOO000OO0 :#line:44
            get_ipython ().system (f'git clone --depth 1 {O00OO00OOOO000OO0} {wb}/custom_nodes/{OOO0OOOOOOO00O000}')#line:45
    get_ipython ().system (f'wget https://huggingface.co/pantat88/ui/resolve/main/embeddings.zip -O {wb}/models/embeddings/embeddings.zip')#line:48
    get_ipython ().system (f'unzip {wb}/models/embeddings/embeddings.zip -d {wb}/models/embeddings')#line:50
    get_ipython ().system (f'rm {wb}/models/embeddings/embeddings.zip')#line:51
    get_ipython ().system (f'wget https://civitai.com/api/download/models/150491 -O {wb}/models/embeddings/edgQuality.pt')#line:52
    clear_output ()#line:54
import subprocess #line:56
def sync_tmp_folder ():#line:58
    OOO00O0O0000O0OOO =[['rm','-rf','~/tmp/*','~/tmp','~/ComfyUI/models/checkpoints','~/ComfyUI/models/loras','~/ComfyUI/models/controlnet'],['ln','-vs','/tmp','~/tmp'],['ln','-vs','/tmp/models','~/ComfyUI/models/checkpoints'],['ln','-vs','/tmp/Lora','~/ComfyUI/models/loras'],['ln','-vs','/tmp/ControlNet','~/ComfyUI/models/controlnet']]#line:65
    for OOOOO0O000O00O000 in OOO00O0O0000O0OOO :#line:66
        OOO00O00OO0OO000O =[os .path .expanduser (OOOOOO0OO00O0OO0O )for OOOOOO0OO00O0OO0O in OOOOO0O000O00O000 ]#line:67
        subprocess .run (OOO00O00OO0OO000O ,check =True )#line:68
def run_command (O0OO00O0000OOOO00 ,O0OO0O0O0O0O000O0 ):#line:71
    print (f"Please wait, {O0OO0O0O0O0O000O0} is loading...")#line:72
    subprocess .run (O0OO00O0000OOOO00 ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL )#line:73
    print (f"{O0OO0O0O0O0O000O0} ok!")#line:74
def zrok ():#line:77
    try :#line:78
        O00O000000OO00OOO ="/home/studio-lab-user/.zrok/bin"#line:79
        os .makedirs (O00O000000OO00OOO ,exist_ok =True )#line:80
        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:81
        subprocess .run (["tar","-xzf","zrok_0.4.23_linux_amd64.tar.gz","-C",O00O000000OO00OOO ,"--wildcards","*zrok"],check =True )#line:82
        os .remove ("zrok_0.4.23_linux_amd64.tar.gz")#line:83
    except Exception as OO0000000OOOO000O :#line:85
        print (f"An error occurred: {OO0000000OOOO000O}")#line:86
def initLocal ():#line:90
    run_command ('conda install -y conda glib gxx_linux-64 ffmpeg imageio imageio-ffmpeg av gst-libav psutil pyngrok gperftools aria2 gdown','【 Installing Conda 】')#line:92
    run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】')#line:93
    run_command ('conda clean -y --all','【 Cleaning Conda 】')#line:94
    get_ipython ().system ('pip install -q tqdm')#line:98
    clear_output ()#line:100
    get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:101
    with capture .capture_output ()as OO0OOOOO00OOOOOOO :#line:104
        def OOOOO00OOO0O00OOO (OOOO00OO0O0O0OOO0 ,OO0OOO000OO00OO0O ,OO0000OO0O00OOOOO ):O0000OO000O000000 =widgets .Button (description =OOOO00OO0O0O0OOO0 ,disabled =True ,button_style =OO0OOO000OO00OO0O ,layout =widgets .Layout (min_width =OO0000OO0O00OOOOO ));display (O0000OO000O000000 )#line:105
        get_ipython ().system (f'git clone -q https://github.com/comfyanonymous/ComfyUI {wb}')#line:107
    with capture .capture_output ()as OO0OOOOO00OOOOOOO :#line:109
        get_ipython ().run_line_magic ('cd',f'{wb}')#line:110
        get_ipython ().system ("pip install -q https://download.pytorch.org/whl/cu118/xformers-0.0.22.post4%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118")#line:112
        get_ipython ().system ('pip install -q -r requirements.txt')#line:113
        get_ipython ().system ('pip install -q opencv-python==4.7.0.72 transformers==4.26.1 tokenizers clip-interrogator')#line:114
        if os .path .isfile ("custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py"):#line:116
            get_ipython ().system ("python custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py > /dev/null")#line:117
        get_ipython ().system ("rm -rf ~/.cache/* ~/ComfyUI/custom_nodes/")#line:119
    get_ipython ().system (f'pip install -q basicsr')#line:121
    clear_output ()#line:123
    zrok ()#line:127
    get_ipython ().system (f'wget https://huggingface.co/gmk123/comfyui/raw/main/zrun.py -O {wb}/zrun.py')#line:128
    get_ipython ().system (f'wget https://huggingface.co/gmk123/comfyui/raw/main/zrok.py -O {wb}/zrok.py')#line:129
    installAdditional ()#line:132
    sync_tmp_folder ()#line:135
    clear_output ()#line:142
    get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/192916 -d {wb}/models/checkpoints -o MoyouArtificial_v1060.safetensors')#line:144
    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:146
    get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth -d {wb}/models/upscale_models -o 4x-UltraSharp.pth')#line:148
    get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth -d {wb}/models/upscale_models -o 4x-AnimeSharp.pth')#line:149
    get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth -d {wb}/models/upscale_models -o 8x_RealESRGAN.pth')#line:150
    get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth -d {wb}/models/upscale_models -o 4x_RealisticRescaler_100000_G.pth')#line:151
    get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x_NMKD-Superscale-SP_178000_G.pth -d {wb}/models/upscale_models -o 4x_NMKD-Superscale-SP_178000_G.pth')#line:152
    get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth -d {wb}/models/facerestore_models -o codeformer.pth')#line:154
    get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth -d {wb}/models/facerestore_models -o GFPGANv1.4.pth')#line:155
wise =" --dont-print-server --preview-method auto --use-pytorch-cross-attention"#line:157
zrok_token =os .environ .get ('ZROK_TOKEN')#line:160
wise +=f" {zrok_token}"#line:161
def run (O000OOO0000O0OO0O ):#line:164
    clear_output ()#line:165
    print (f'zrok部署,无需魔法,没有流量限制')#line:166
    get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:167
    get_ipython ().run_line_magic ('cd',f'{wb}')#line:169
    get_ipython ().system (f'python {O000OOO0000O0OO0O} {wise}')#line:170
if os .path .exists (f'{wb}'):#line:173
    run (f'zrun.py')#line:175
else :#line:176
    initLocal ()#line:178
    run (f'zrun.py')#line:181